fdisk 磁盘分区命令

实例一、查看整块磁盘分区状况

[root@localhost ~]# fdisk -l


Disk /dev/hdc: 40.0 GB, 40020664320 bytes

16 heads, 63 sectors/track, 77545 cylinders

Units = cylinders of 1008 * 512 = 516096 bytes


   Device Boot      Start         End      Blocks   Id  System

/dev/hdc1   *           1         203      102280+  83  Linux

/dev/hdc2             204       77545    38980368   8e  Linux LVM


实例二、查看指定分区使用状况

[root@localhost ~]# fdisk -l /dev/hdc1


Disk /dev/hdc1: 104 MB, 104735232 bytes

16 heads, 63 sectors/track, 202 cylinders

Units = cylinders of 1008 * 512 = 516096 bytes


Disk /dev/hdc1 doesn't contain a valid partition table


================以下对磁盘进行分区操作=======================

一、对磁盘/dev/hdc分区

[root@localhost ~]# fdisk /dev/hdc


The number of cylinders for this disk is set to 77545.

There is nothing wrong with that, but this is larger than 1024,

and could in certain setups cause problems with:

1) software that runs at boot time (e.g., old versions of LILO)

2) booting and partitioning software from other OSs

   (e.g., DOS FDISK, OS/2 FDISK)


Command (m for help):

# Command (m for help): 提示键入m获取帮助菜单

二、fdisk帮助菜单

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  # 更改分区ID

   u   change display/entry units

   v   verify the partition table

   w   write table to disk and exit  # 保存分区操作

   x   extra functionality (experts only)


三、开始分区

[root@localhost ~]# fdisk /dev/sdb

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel with disk identifier 0x8c86b73c.

Changes will remain in memory only, until you decide to write them.

After that, of course, the previous content won't be recoverable.


Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)


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): n

Command action

   e   extended

   p   primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-130, default 1): 1

Last cylinder, +cylinders or +size{K,M,G} (1-130, default 130): +100M


Command (m for help):


四、各选项注释

   e   extended

扩展分区

   p   primary partition (1-4)

主分区

Partition number (1-4): 

分区号,1-4

First cylinder (1-130, default 1): 

起始柱

Last cylinder, +cylinders or +size{K,M,G} (1-130, default 130): 

分区大小


五、分区完成后会返回命令提示符

Command (m for help):

此时键入m即进入帮助菜单

键入w即保存分区操作,如不保存分区操作直接q退出,则视为放弃当前分区操作

你可能感兴趣的:(fdisk,磁盘分区命令)