fdisk command for observing the physical disk usage, but also on the hard disk partition.
[xuliangwei the root @ ~] # the fdisk / dev / sdb the Command (m for Help): m # input common commands listed m the Command Action A Toggle A Bootable In Flag # switching partition boot flag B Edit the disklabel BSD # edit sdb disk label c The dos compatibility In Flag Toggle # handover dos compatibility mode D A delete partition # delete partitions L List Known types partition # display partition types m the this mENU Print # display the help menu n-A new new partition the Add # new partition O the Create A new new empty DOS Partition the Table # Create a new empty partition table the p-Print at The Partition the Table # Display information partition table q quit the without Saving Changes # exit without saving S the Create A new new empty Sun disklabel # create a new Sun disk label t A System partitions id Change # modify a partition ID, can be viewed by id L U Change the display / entry units # edit unit of volume, cylinder or sectors V verify The partition table # test partition table W and Disk Write to table exit # save and exit Extra functions on this page the X-(Experts only) # expand functionality
fdisk create partition primary
The Command (m for Help): n- the Partition type: P Primary ( 0 Primary, Extended 0, Free. 4) # primary partition E Extended # extended partition the Select ( default P): P # choose to create a primary partition Partition number (1-4, default . 1): # default create the first primary partition first a sECTOR (2048-2097151, default 2048): # default sector Enter the Using default value 2048 Last a sECTOR, + + size sectors or {K, M, G} (2048 -2097151, default 2097151): + 50M # allocate 50MB
fdisk create an extended partition
The Command (m for Help): n- # new partition the Partition type: P Primary ( . 1 Primary, Extended 0,. 3 Free) E Extended the Select ( default P): E # Create extended partition the Partition Number (2-4, default 2 ): a SECTOR First ( 104448-2097151, default 104 448 ): the Using default value 104 448 Last a SECTOR, + + size sectors or {K, M, G} (104448-2097151, default 2097151): # space extended partition to give
fdisk create logical partitions
Command (m for help): n #新建分区 Partition type: p primary (1 primary, 1 extended, 2 free) l logical (numbered from 5) Select (default p): l #创建逻辑分区 Adding logical partition 5 First sector (106496-2097151, default 106496): Using default value 106496 Last sector, +sectors or +size{K,M,G} (106496-2097151, default 2097151): +100M #分配100MB空间
fdisk to check the partitions and save
Command (m for Help): the p- # view the partition created Device the Boot Start End Blocks Id System / dev / sdb1 2048 104 447 51200 83 Linux / dev / sdb2 104 448 2097151 996 352 5 Extended / dev / sdb5 106496 311 295 102400 83 Linux # save the partition Command (m for Help): W of The partition Table has been Altered ! the Calling the ioctl () to Re - . Read partition Table . Syncing disks # checks whether the MBR partition disk embodiment [xuliangwei the root @ ~] # the fdisk / dev / SDB -l | grep type Disk label type: dos