Linux-HDDパーティションおよびパーティション化ツール(一)

9556 ワード

新しいハードウェアデバイスがLinuxに追加されると、システムは自動的に認識できますが、新しく追加されたハードディスクはパーティション化、フォーマット、マウントしてから使用する必要があります.

MBRパーティションとfdisk


システムのHDD情報の表示

fdisk -l
#  sda     :
#sda        sda1 sda3,  swap  sda2,      sda4,        sda5
Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders, total 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000e50ae

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      411647      204800   83  Linux
/dev/sda2          411648     4605951     2097152   82  Linux swap / Solaris
/dev/sda3         4605952     8701951     2048000   83  Linux
/dev/sda4         8701952    41943039    16620544    5  Extended
/dev/sda5         8704000    41943039    16619520   83  Linux

#  sdb   :8GB  ,   
Disk /dev/sdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders, total 16777216 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x740e36e3

   Device Boot      Start         End      Blocks   Id  System

ハードディスク(HDD)sdbのパーティションモードに入る

fdisk /dev/sdb
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').
#  u:   sector     
Command (m for help): u
Changing display/entry units to sectors

#     sdb1,   2GB  
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First sector (63-16777215, default 63): #    ,     
Using default value 63
Last sector, +sectors or +size{K,M,G} (63-16777215, default 16777215): +2G

#      sdb2,           
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
e
Partition number (1-4): 2
First sector (4194368-16777215, default 4194368): 
Using default value 4194368
Last sector, +sectors or +size{K,M,G} (4194368-16777215, default 16777215): 
Using default value 16777215

#      sdb5,   2GB    
Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l
First sector (4194431-16777215, default 4194431): 
Using default value 4194431
Last sector, +sectors or +size{K,M,G} (4194431-16777215, default 16777215): +2G

パーティション・スキーマを確認し、ディスク・パーティション・テーブルに書き込む

#  p:        (          sdb6        )
Command (m for help): p

Disk /dev/sdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders, total 16777216 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x740e36e3

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1              63     4194367     2097152+  83  Linux
/dev/sdb2         4194368    16777215     6291424    5  Extended
/dev/sdb5         4194431     8388735     2097152+  83  Linux
/dev/sdb6         8388799    16777215     4194208+  83  Linux

#  w:            
Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

p.s.

  • fdiskパーティションツールはインタラクティブ、すなわちシステム質問、ユーザー応答の方式でパーティション化を行う.
  • 簡単で分かりやすく、間違いにくいが、命令方式より遅く、効率が低い.
  • は、いつでもmコマンドを使用してhelpを呼び出すことができる.
  • パーティション終了は即時に有効ではなく、wコマンドを呼び出してパーティションスキームをディスクパーティションテーブルに書き込む.