Welcome to fdisk (util-linux 2.29.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command.
Command (m forhelp): d # 输入d回车,我只有一个分区,它自动选择了,如果你有多个分区,可以多次使用d Selected partition 1 Partition 1 has been deleted.
Command (m forhelp): n # 输入n会车,创建分区 Partition type p primary (0 primary, 0 extended, 4 free) e extended (container for logical partitions)
Select (default p): p # 选择p Partition number (1-4, default 1): # 输入 1 回车 First sector (2048-2065023, default 2048): # 回车 Last sector, +sectors or +size{K,M,G,T,P} (2048-2065023, default 2065023): # 回车 Created a new partition 1 of type'Linux' and of size 1007.3 MiB.
Command (m forhelp): w # 输入 w 回车,保存并退出 The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks.
经过以上的操作,你可以用 fdisk -l 命令查看U盘上是否只有一个 Linux 分区
fdisk -l # 找到你的设备 可以看到ID为83就对了 Disk /dev/sda: 30.7 GB, 30752000000 bytes 64 heads, 32 sectors/track, 29327 cylinders Units = cylinders of 2048 * 512 = 1048576 bytes Device Boot Start End Blocks Id System /dev/sda1 2 29327 30029824 83 Linux
格式化分区
分区已经有了,现在开始格式化
用 mkfs.ext4 命令格式化,并且设置卷标为 onmp
注意,如果下面的命令提示 /dev/sda1 is mounted,则需要先卸载 U 盘,和分区前卸载的方法一样
mke2fs 1.42.8 (20-Jun-2013) Filesystem label=onmp OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 1880480 inodes, 7507456 blocks 0 blocks (0.00%) reserved for the super user First data block=0 Maximum filesystem blocks=0 230 block groups 32768 blocks per group, 32768 fragments per group 8176 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000
Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done