1.命令行
查看你的设备的符号,显示结果通常如下:
- sudo fdisk -l
找到你的设备的盘符,我的是 /dev/sdb
- Disk /dev/sda: 500.1 GB, 500107862016 bytes
- 255 heads, 63 sectors/track, 60801 cylinders
- Units = cylinders of 16065 * 512 = 8225280 bytes
- Sector size (logical/physical): 512 bytes / 512 bytes
- I/O size (minimum/optimal): 512 bytes / 512 bytes
- Disk identifier: 0x000c4c5b
- Device Boot Start End Blocks Id System
- /dev/sda1 * 1 60065 482466816 83 Linux
- /dev/sda2 60065 60802 5917697 5 Extended
- /dev/sda5 60065 60802 5917696 82 Linux swap / Solaris
- Disk /dev/sdb: 1954 MB, 1954545664 bytes
- 255 heads, 63 sectors/track, 237 cylinders
- Units = cylinders of 16065 * 512 = 8225280 bytes
- Sector size (logical/physical): 512 bytes / 512 bytes
- I/O size (minimum/optimal): 512 bytes / 512 bytes
- Disk identifier: 0x00069760
- sudo umount /dev/sdb
在终端显示内容如下:
- sudo fdisk /dev/sdb
输入m得到帮助信息:
- Command (m for help):
开始分区
- Command action
- a toggle a bootable flag
- b edit bsd disklabel
- c toggle the dos compatibility flag
- d delete a partition
- l list known partition types
- m print this menu
- n add a new partition
- o create a new empty DOS partition table
- p print the partition table
- q quit without saving changes
- s create a new empty Sun disklabel
- t change a partition's system id
- u change display/entry units
- v verify the partition table
- w write table to disk and exit
- x extra functionality (experts only)
如果你的设备已经有分区,先删除你的分区:
- Command (m for help): d 删除命令
- Partition number (1-4): 1 删除地几个分区
创建新分区:
- 如果有多个分区,接着执行命令d,输入分区号
创建第二个分区:同上
- Command (m for help): n 创建分区命令
- Command action
- e extended
- p primary partition (1-4)
- p 选择分区的类型 e:扩展分区 p:主分区
- Partition number (1-4): 1 分区号 1:第一个分区
- First cylinder (1-237, default 1): 1
- Last cylinder, +cylinders or +size{K,M,G} (1-237, default 237): +512M 分区的大小
把第一个分区做为FAT32d 分区:
- Command (m for help): n
- Command action
- e extended
- p primary partition (1-4)
- p
- Partition number (1-4): 2
- First cylinder (67-237, default 67):
- Using default value 67
- Last cylinder, +cylinders or +size{K,M,G} (67-237, default 237): +512M
查看分区情况:
- Command (m for help): t 改变分区的id
- Partition number (1-4): 1 改变第一个分区
- Hex code (type L to list codes): c 变为dos兼容的格式
- Changed system type of partition 1 to c (W95 FAT32 (LBA))
- Command (m for help): p
- Disk /dev/sdb: 1954 MB, 1954545664 bytes
- 255 heads, 63 sectors/track, 237 cylinders
- Units = cylinders of 16065 * 512 = 8225280 bytes
- Sector size (logical/physical): 512 bytes / 512 bytes
- I/O size (minimum/optimal): 512 bytes / 512 bytes
- Disk identifier: 0x00069760
- Device Boot Start End Blocks Id System
- /dev/sdb1 1 66 530113+ c W95 FAT32 (LBA)
- /dev/sdb2 67 132 530145 83 Linux
保存写入上面的内容:
- Command (m for help): w
- The partition table has been altered!
- Calling ioctl() to re-read partition table.
- WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
- The kernel still uses the old table. The new table will be used at
- the next reboot or after you run partprobe(8) or kpartx(8)
- WARNING: If you have created or modified any DOS 6.x
- partitions, please see the fdisk manual page for additional
- information.
- Syncing disks.
格式化分区:
sudo mkfs.vfat -F 32 -n boot /dev/sdb1 //boot是为分区起的名字,就是在硬盘上显示的名字 格式化位fat32格式 第一个分区
sudo mkfs.ext3 -L linux_fs /dev/sdb2 // linux_fs 是第二个分区的名字,格式化位 ext3格式