【LINUX學習】磁碟分割之新建與刪除

楊奇龍發表於2010-11-28
磁碟分割
[root@localhost /]# fdisk -l --列出系統所有的裝置的partition都列出來
Disk /dev/sda: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14         522     4088542+  83  Linux

Disk /dev/sdb: 3221 MB, 3221225472 bytes
255 heads, 63 sectors/track, 391 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdb doesn't contain a valid partition table
Disk /dev/sdc: 3221 MB, 3221225472 bytes
255 heads, 63 sectors/track, 391 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1   *           1         131     1052226   82  Linux swap / Solaris

Disk /dev/sdd: 3221 MB, 3221225472 bytes
255 heads, 63 sectors/track, 391 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
---也可以指定裝置,
[root@localhost /]# fdisk -l /dev/sdc
Disk /dev/sdc: 3221 MB, 3221225472 bytes
255 heads, 63 sectors/track, 391 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1   *           1         131     1052226   82  Linux swap / Solaris
[root@localhost /]# fdisk -l /dev/sda
Disk /dev/sda: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14         522     4088542+  83  Linux
---建立一個主分割槽,如果使用預設值,會在建立第一個分割槽時就將整個磁碟使用完。
[root@localhost /]# fdisk /dev/sdd
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-391, default 1): 1
Last cylinder or +size or +sizeM or +sizeK (1-391, default 391): =直接按enter鍵預設391
Using default value 391
Command (m for help): p
Disk /dev/sdd: 3221 MB, 3221225472 bytes
255 heads, 63 sectors/track, 391 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1               1         391     3140676   83  Linux

Command (m for help): n --繼續新增
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 2
No free sectors available---沒有可用空間了!
--刪除剛才建立的那個分割槽。
Command (m for help): d
Selected partition 1
Command (m for help): p
Disk /dev/sdd: 3221 MB, 3221225472 bytes
255 heads, 63 sectors/track, 391 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   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
First cylinder (1-391, default 1): 
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-391, default 391): +50M
Command (m for help): p
Disk /dev/sdd: 3221 MB, 3221225472 bytes
255 heads, 63 sectors/track, 391 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1               1           7       56196   83  Linux

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (8-391, default 8): 
Using default value 8
Last cylinder or +size or +sizeM or +sizeK (8-391, default 391): +2^H
Command (m for help): p
Disk /dev/sdd: 3221 MB, 3221225472 bytes
255 heads, 63 sectors/track, 391 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1               1           7       56196   83  Linux
/dev/sdd2               8          10       24097+  83  Linux
Command (m for help): p
Disk /dev/sdd: 3221 MB, 3221225472 bytes
255 heads, 63 sectors/track, 391 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1               1           7       56196   83  Linux
/dev/sdd2               8          10       24097+  83  Linux
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (11-391, default 11): 
Using default value 11
Last cylinder or +size or +sizeM or +sizeK (11-391, default 391): 
Using default value 391
Command (m for help): p
Disk /dev/sdd: 3221 MB, 3221225472 bytes
255 heads, 63 sectors/track, 391 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1               1           7       56196   83  Linux
/dev/sdd2               8          10       24097+  83  Linux
/dev/sdd3              11         391     3060382+  83  Linux
--刪除第三個分割槽
Command (m for help): d
Partition number (1-4): 3
Command (m for help): p
Disk /dev/sdd: 3221 MB, 3221225472 bytes
255 heads, 63 sectors/track, 391 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1               1           7       56196   83  Linux
/dev/sdd2               8          10       24097+  83  Linux
--刪除第二個分割槽
Command (m for help): d
Partition number (1-4): 2 
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)
Command (m for help): d
Selected partition 1  --只有一個分割槽,系統幫我們選擇
Command (m for help): p
Disk /dev/sdd: 3221 MB, 3221225472 bytes
255 heads, 63 sectors/track, 391 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
Command (m for help): q
[root@localhost /]# 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/22664653/viewspace-680496/,如需轉載,請註明出處,否則將追究法律責任。

相關文章