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

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