fdisk工具简单使用介绍

###########################################################

#一个IDE硬盘只能建4个分区,如果要建多于四个的分区,就要拿出一个主分区做为 #
#扩展分区,再在扩展分区里面进行其它的分区操作。                                             #
###########################################################

[root@zhouqixiang ~]# fdisk /dev/sdb     #对磁盘/dev/sdb进行分区
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x68a3c8c6.
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): p      #打印分区表

Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 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: 0x68a3c8c6

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): h      #帮助
h: 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): n      #新增分区
Command action
   e   extended   #扩展分区
   p   primary partition (1-4)     #主分区
p
Partition number (1-4): 1     #第一个主分区,编号1
First cylinder (1-1305, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-1305, default 1305): +2G

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 2     #第二个主分区,编号2
First cylinder (263-1305, default 263):
Using default value 263
Last cylinder, +cylinders or +size{K,M,G} (263-1305, default 1305): +2G

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 3     #第三个主分区,编号3
First cylinder (525-1305, default 525):
Using default value 525
Last cylinder, +cylinders or +size{K,M,G} (525-1305, default 1305): +2G

Command (m for help): n      #扩展分区,编号4
Command action
   e   extended
   p   primary partition (1-4)
e        #这里选择扩展分区
Selected partition 4
First cylinder (787-1305, default 787):
Using default value 787
Last cylinder, +cylinders or +size{K,M,G} (787-1305, default 1305):
Using default value 1305

Command (m for help): p      #打印分区表

Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 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: 0x68a3c8c6

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         262     2104483+  83  Linux
/dev/sdb2             263         524     2104515   83  Linux
/dev/sdb3             525         786     2104515   83  Linux
/dev/sdb4             787        1305     4168867+   5  Extended

Command (m for help): n      #对扩展分区再建第一个逻辑分区
First cylinder (787-1305, default 787):
Using default value 787
Last cylinder, +cylinders or +size{K,M,G} (787-1305, default 1305): +2G

Command (m for help): n      #对扩展分区再建第二个逻辑分区
First cylinder (1049-1305, default 1049):
Using default value 1049
Last cylinder, +cylinders or +size{K,M,G} (1049-1305, default 1305):
Using default value 1305

Command (m for help): p      #打印分区表,有5个可用分区(扩展分区用来建逻辑分区)

Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 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: 0x68a3c8c6

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         262     2104483+  83  Linux
/dev/sdb2             263         524     2104515   83  Linux
/dev/sdb3             525         786     2104515   83  Linux
/dev/sdb4             787        1305     4168867+   5  Extended
/dev/sdb5             787        1048     2104483+  83  Linux
/dev/sdb6            1049        1305     2064321   83  Linux

Command (m for help): w      #保存分区表
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
#下面格式化分区,再进行手动挂载,把配置文件写入/etc/fstab
[root@zhouqixiang ~]# mkfs.ext4 /dev/sdb1

手动挂载分区请访问:

http://zqxiang.blog.51cto.com/2806551/1572652

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章