[iyunv@xpleaf ~]# fdisk /dev/sdb ===>直接接磁盘名就可以分区
Device contains neither a valid DOSpartition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with diskidentifier 0x7f3aa9cb.
Changes will remain in memory only,until you decide to write them.
After that, of course, the previouscontent won't be recoverable.
Warning: invalid flag 0x0000 ofpartition table 4 will be corrected by w(rite)
WARNING: DOS-compatible mode isdeprecated. It's strongly recommended to
switch off the mode (command 'c') andchange display units to
sectors (command 'u').
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibilityflag
d delete a partition ===>删除一个分区
l list known partition types ===>查看分区类型对应编号列表
m print this menu ===>打印此帮助菜单
n add a new partition ===>新建一个分区
o create a new empty DOSpartition table
p print the partition table ===>打印分区表
q quit without saving changes ===>退出但不保存更改
s create a new empty Sundisklabel
t change a partition's system id ===>更改分区类型(做LVM时需要)
u change display/entry units
v verify the partition table
w write table to disk and exit ===>将操作写入分区表并退出程序
x extra functionality (expertsonly)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p ===>新建一个主分区
Partition number (1-4): 1 ===>指定主分区的分区号码
First cylinder (1-130, default 1): ===>指定分区开始的柱面号
Usingdefault value 1
Last cylinder, +cylinders or+size{K,M,G} (1-130, default 130): +100M
===>指定分区结束的柱面号,或者指定分区大小,让fdisk自动判断结束柱面号
Command (m for help): p
Disk /dev/sdb: 1073 MB, 1073741824bytes
255 heads, 63 sectors/track, 130cylinders
Units = cylinders of 16065 * 512 =8225280 bytes
Sector size (logical/physical): 512bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes/ 512 bytes
Disk identifier: 0x7f3aa9cb
Device Boot Start End Blocks Id System
/dev/sdb1 1 14 112423+ 83 Linux
Command (m for help): n
Command action
e extended
p primary partition (1-4)
e ===>新建一个扩展分区
Partition number (1-4): 1
Partition 1 is already defined. Delete it before re-adding it.
===>由于前面已经使用了分区号码1,所以这里会提示错误
Command (m for help): n
Command action
e extended
p primary partition (1-4)
e
Partition number (1-4): 2
First cylinder (15-130, default 15):
Usingdefault value 15
Last cylinder, +cylinders or+size{K,M,G} (15-130, default 130):
Usingdefault value 130
===>分区的开始柱面号和结束柱面号都使用默认值,即把剩余磁盘空间分配给该分区
Command (m for help): p
Disk /dev/sdb: 1073 MB, 1073741824bytes
255 heads, 63 sectors/track, 130cylinders
Units = cylinders of 16065 * 512 =8225280 bytes
Sector size (logical/physical): 512bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes/ 512 bytes
Disk identifier: 0x7f3aa9cb
Device Boot Start End Blocks Id System
/dev/sdb1 1 14 112423+ 83 Linux
/dev/sdb2 15 130 931770 5 Extended
Command (m for help): n
Command action
l logical (5 or over) ===>由于扩展分区只能有一个,上面新建扩展分区后
p primary partition (1-4) 这里就显示逻辑分区了,也可以看到fdisk命令,
p 要想新建逻辑分区,需要先新建扩展分区
Partition number (1-4): 3
No free sectors available
===>这里还想再新建一个主分区,但是提示已经没有磁盘空间剩余
Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)
l ===>新建一个逻辑分区
First cylinder (15-130, default 15):
Usingdefault value 15
Last cylinder, +cylinders or+size{K,M,G} (15-130, default 130): +400M
Command (m for help): p
Disk /dev/sdb: 1073 MB, 1073741824bytes
255 heads, 63 sectors/track, 130cylinders
Units = cylinders of 16065 * 512 =8225280 bytes
Sector size (logical/physical): 512bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes/ 512 bytes
Disk identifier: 0x7f3aa9cb
Device Boot Start End Blocks Id System
/dev/sdb1 1 14 112423+ 83 Linux
/dev/sdb2 15 130 931770 5 Extended
/dev/sdb5 15 66 417658+ 83 Linux
Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)
l
First cylinder (67-130, default 67):
Usingdefault value 67
Last cylinder, +cylinders or+size{K,M,G} (67-130, default 130):
Usingdefault value 130
Command (m for help): p
Disk /dev/sdb: 1073 MB, 1073741824bytes
255 heads, 63 sectors/track, 130cylinders
Units = cylinders of 16065 * 512 =8225280 bytes
Sector size (logical/physical): 512bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes/ 512 bytes
Disk identifier: 0x7f3aa9cb
Device Boot Start End Blocks Id System
/dev/sdb1 1 14 112423+ 83 Linux
/dev/sdb2 15 130 931770 5 Extended
/dev/sdb5 15 66 417658+ 83 Linux
/dev/sdb6 67 130 514048+ 83 Linux
Command (m for help): w ===>保存更改
The partition table has been altered!
Calling ioctl() to re-read partitiontable.
Syncing disks.
[iyunv@xpleaf ~]# mkfs.ext4 /dev/sdb
sdb sdb1 sdb2 sdb5 sdb6
[iyunv@xpleaf ~]# mkfs.ext4 /dev/sdb1
……
This filesystem will be automaticallychecked every 31 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
最后面提示说系统会定时检查文件系统,这里不想系统检查,则可以使用下面的命令:
1
2
3
[iyunv@xpleaf ~]# tune2fs -c -1/dev/sdb1
tune2fs 1.41.12 (17-May-2010)
Setting maximal mount count to -1