磁盘分区:fdisk 命令

[root@lob1 /]# df /                            《==查看磁盘文件名
Filesystem           1K-blocks    Used Available Use% Mounted on
/dev/mapper/VolGroup-lv_root
                      19235284 1179492  17078692   7% /
[root@lob1 /]# fdisk /dev/sda      《==磁盘分区格式 ,我的机器是sda硬盘模式

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): m     《==输入m后,可以看到下面这些命令
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   《==不储存,离开fdisk程序
   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): p       《==再屏幕上显示分区表

Disk /dev/sda: 21.6 GB, 21580873728 bytes
255 heads, 63 sectors/track, 2623 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: 0x000e6242

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        2624    20561920   8e  Linux LVM

Command (m for help): d      《==删除第一个分区
Partition number (1-4): 1

Command (m for help): p        《==再屏幕上显示分区表   

Disk /dev/sda: 21.6 GB, 21580873728 bytes
255 heads, 63 sectors/track, 2623 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: 0x000e6242

   Device Boot      Start         End      Blocks   Id  System
/dev/sda2              64        2624    20561920   8e  Linux LVM

Command (m for help): d     《==删除第二个分区
Selected partition 2

Command (m for help): 2
2: unknown command
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): p    《==再屏幕上显示分区表

Disk /dev/sda: 21.6 GB, 21580873728 bytes
255 heads, 63 sectors/track, 2623 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: 0x000e6242

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): n     《==新增一个分区
Command action
   e   extended
   p   primary partition (1-4)
p    《==新增主分区
Partition number (1-4): 1      《==新增名称为“1”的主分区
First cylinder (1-2623, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-2623, default 2623): +512M  《==设置“1”的主分区的大小

格式 “+XXXM,+ 连字符 ,XXX代表数字,M是大小,个人理解”

Command (m for help): p  

Disk /dev/sda: 21.6 GB, 21580873728 bytes
255 heads, 63 sectors/track, 2623 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: 0x000e6242

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1          66      530113+  83  Linux

Command (m for help): n  《==显示分区表

   e   extended
   p   primary partition (1-4)
p  《==新增的是主分区
Partition number (1-4): 2     《==新增名字为“2”的主分区

First cylinder (67-2623, default 67):
Using default value 67
Last cylinder, +cylinders or +size{K,M,G} (67-2623, default 2623): +512M 《==设置“2”的主分区的大小

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
e     《==新增的是扩展分区
Partition number (1-4): 3    《==新增名字为“3”的扩展分区

First cylinder (133-2623, default 133):
Using default value 133
Last cylinder, +cylinders or +size{K,M,G} (133-2623, default 2623):     《==不写代表是默认,直接enter默认下一步,剩余所有空间全部分配给扩展分区“3”
Using default value 2623

Command (m for help): p     《==查看分区列表

Disk /dev/sda: 21.6 GB, 21580873728 bytes
255 heads, 63 sectors/track, 2623 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: 0x000e6242

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1          66      530113+  83  Linux
/dev/sda2              67         132      530145   83  Linux
/dev/sda3             133        2623    20008957+   5  Extended

Command (m for help): n    《==新增一个分区
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
p  《==新增主分区
Selected partition 4
No free sectors available 《==没有空余空间不能新增主分区

Command (m for help): n  《新增一个分区
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l   《==新增逻辑分区,因为是PPE已经分配完所有空间,如果再分配新区只能是L 逻辑分区
First cylinder (133-2623, default 133):
Using default value 133
Last cylinder, +cylinders or +size{K,M,G} (133-2623, default 2623): 512   《==逻辑分区大小

Command (m for help): p  《==查看分区列表

Disk /dev/sda: 21.6 GB, 21580873728 bytes
255 heads, 63 sectors/track, 2623 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: 0x000e6242

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1          66      530113+  83  Linux
/dev/sda2              67         132      530145   83  Linux
/dev/sda3             133        2623    20008957+   5  Extended
/dev/sda5             133         512     3052318+  83  Linux    《==逻辑分区默认为5,柱面在3扩展分区之内

Command (m for help): q  《==因为是测试所有按“q” 不保存退去。如果是正式的话则按“w”保存退出

[root@lob1 /]#