fdisk -l
这里我需要对sda进行分区,所以要进到sda中
$ sudo fdisk /dev/sda Welcome to fdisk (util-linux 2.27.). Changes will remain in memory only, until you decide to write them. Be careful before using the write command.
Command (m for help): m Help: DOS (MBR) a toggle a bootable flag b edit nested BSD disklabel c toggle the dos compatibility flag Generic d delete a partition F list free unpartitioned space l list known partition types n add a new partition p print the partition table t change a partition type v verify the partition table i print information about a partition Misc m print this menu u change display/entry units x extra functionality (experts only) Script I load disk layout from sfdisk script file O dump disk layout to sfdisk script file Save & Exit w write table to disk and exit q quit without saving changes Create a new label g create a new empty GPT partition table G create a new empty SGI (IRIX) partition table o create a new empty DOS partition table s create a new empty Sun partition table Command (m for help): p Disk /dev/sda: 238.5 GiB, bytes, sectors Units: sectors of * = bytes Sector size (logical/physical): bytes / bytes I/O size (minimum/optimal): bytes / bytes Disklabel type: dos Disk identifier: 0x3370b165 Device Boot Start End Sectors Size Id Type /dev/sda1 * 100G HPFS/NTFS/exFAT
可以看到,在我的sda中,4096到209723391部分已经分给了sda1,剩余空间可以进行分区,剩余空间的起止:209723392到500118191.
Command (m for help): n Partition type p primary ( primary, extended, free) e extended (container for logical partitions) Select (default p): e Partition number (-, default ): First sector (-, default ): Last sector, +sectors or +size{K,M,G,T,P} (-, default ): Created a new partition of type 'Extended' and of size 138.5 GiB.
Command (m for help): p Disk /dev/sda: 238.5 GiB, bytes, sectors Units: sectors of * = bytes Sector size (logical/physical): bytes / bytes I/O size (minimum/optimal): bytes / bytes Disklabel type: dos Disk identifier: 0x3370b165 Device Boot Start End Sectors Size Id Type /dev/sda1 * 100G HPFS/NTFS/exFAT /dev/sda2 .5G Extended
注意,以上部分是更新的分区表,并未真正进行物理的分区,需要 键入 “w” 保存退出后才正式生效。
报错:
$ sudo mkfs -t ext4 /dev/sda2 mke2fs 1.42. (-May-) Found a dos partition table in /dev/sda2 Proceed anyway? (y,n) y mkfs.ext4: inode_size () * inodes_count () too big for a filesystem with blocks, specify higher inode_ratio (-i) or lower inode count (-N).
原因:原类型为extend,需要改为Linux。
change type:
$ sudo fdisk /dev/sda Welcome to fdisk (util-linux 2.27.). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Command (m for help): p Disk /dev/sda: 238.5 GiB, bytes, sectors Units: sectors of * = bytes Sector size (logical/physical): bytes / bytes I/O size (minimum/optimal): bytes / bytes Disklabel type: dos Disk identifier: 0x3370b165 Device Boot Start End Sectors Size Id Type /dev/sda1 * 100G HPFS/NTFS/exFAT /dev/sda2 .5G Extended Command (m for help): t Partition number (,, default ): Partition type (type L to list all types): Changed type of partition 'Extended' to 'Linux'. Command (m for help): w The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks.
之后可以格式化为 ext4
$ sudo mkfs -t ext4 /dev/sda2 mke2fs 1.42. (-May-) Found a dos partition table in /dev/sda2 Proceed anyway? (y,n) y Discarding device blocks: done Creating filesystem with 4k blocks and inodes Filesystem UUID: bc630198-ae61-45af-a0c2-75e8e97cb5bd Superblock backups stored on blocks: , , , , , , , , , , , , , Allocating group tables: done Writing inode tables: done Creating journal ( blocks): done Writing superblocks and filesystem accounting information: done
$ sudo fsck -f /dev/sda2 fsck from util-linux 2.27. e2fsck 1.42. (-May-) Pass : Checking inodes, blocks, and sizes Pass : Checking directory structure Pass : Checking directory connectivity Pass : Checking reference counts Pass : Checking group summary information /dev/sda2: / files (0.0% non-contiguous), / blocks
自己可以新建一个文件作为挂载点,我在自己的home下 mkdir了new这个文件夹,将这块分区挂载在这里。
$sudo mount /dev/sda2 /home/lsy/new
如果觉得挂载错了,想重新挂载,可以用
$ umount /dev/sda2
之后再用之前的mount命令重新挂载即可。虽然挂载点变了,但是sda2中已经保存的内容不会改变的。
以上就是[ubuntu] 外挂硬盘的详细内容,更多关于[ubuntu] 外挂硬盘的资料请关注九品源码其它相关文章!