fdisk命令说明

    fdisk是linux下的磁盘分区工具,能划分磁盘成为若干个区,同时也能为每个分区指定文件系统,比如linux、fat32、linux、linux swap、fat16格式等;
    当然我们用fdisk对磁盘分区后,还要使用mkfs命令对分区进行格式化才能挂载使用。
硬盘分区的表示:
在Linux 是通过hd*x或sd*x表示的,其中“*”表示的是a、b、c等等;x表示的数字 1、2、3等等;hd是IDE硬盘;sd是SCSI或移动存储。


# fdisk -l
Disk /dev/hda: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *           1         829     6658911    b  W95 FAT32
/dev/hda2             830       14593   110559330    f  W95 Ext'd (LBA)
/dev/hda5             830        3506    21502971    7  HPFS/NTFS
/dev/hda6            3507        4811    10482381   83  Linux
/dev/hda7            4812        4942     1052226   82  Linux swap
/dev/hda8            4943        6217    10241406   83  Linux
… …

Start
表示的一个分区从X cylinder(磁柱)开始;
End
表示一个分区到 Y cylinder(磁柱)结束;
id,System
表示分区类型,分区时通过指定id来确认分区类型,fdisk中通过t指定。
Blocks
分区的容量。


     通过“fdisk –l”可以查看机器所挂硬盘及分区情况。这个硬盘是120G的,有255个磁面;63个扇区;9729个柱面;每个 cylinder(柱面)的容量是 8225280 bytes。hda有两个主分区(包括扩展分区),分别是主分区 hda1和hda2(扩展分区);hda5以后是逻辑分区。硬盘总容量为主分区(包括扩展分区)总容量,而扩展分区为逻辑分区总容量之和。因此,通过上面的例子,我们可以得知 hda=hda1+hda2,其中hda3=hda5+hda6+hda7+hda8+... ...。


fdisk交互式分区操作


# fdisk /dev/sda
Command (m for help): 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         //不保存退出
   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)     //扩展功能

猜你喜欢

转载自sky425509.iteye.com/blog/1994821