Red Hat Training

A Red Hat training course is available for Red Hat Enterprise Linux

13.5. fdisk でのパーティションのサイズ変更

fdisk ユーティリティーを使用すると、GPT、MBR、Sun、SGI、および BSD パーティションテーブルを作成および操作できます。GUID パーティションテーブル(GPT)のディスクでは、fdisk GPT サポートは実験的なフェーズであるため、parted ユーティリティーを使用することが推奨されます。
fdisk を使用してパーティションサイズを変更する唯一の方法は、パーティションを削除して再作成するため、パーティションのサイズを変更する前に、ファイルシステムに保存されているデータを バックアップ して手順をテストします。
重要
サイズを変更するパーティションは、特定ディスクの最後のパーティションにする必要があります。
Red Hat は、LVM パーティションの拡張とサイズ変更にのみ対応しています。

手順13.4 パーティションのサイズ変更

以下の手順は、参照用にのみ提供されています。 fdisk を使用してパーティションのサイズを変更するには、以下を実行します。
  1. デバイスをアンマウントします。
    # umount /dev/vda
  2. fdisk disk_name を実行します。以下に例を示します。
    # fdisk /dev/vda
    Welcome to fdisk (util-linux 2.23.2).
    
    Changes will remain in memory only, until you decide to write them. Be careful before using the write command.
    
    Command (m for help):
    
  3. p オプションを使用して、削除するパーティションの行番号を決定します。
    Command (m for help): p
    Disk /dev/vda: 16.1 GB, 16106127360 bytes, 31457280 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 label type: dos
    Disk identifier: 0x0006d09a
    
    Device    Boot      Start         End      Blocks   Id  System
    /dev/vda1   *        2048     1026047      512000   83  Linux
    /dev/vda2         1026048    31457279    15215616   8e  Linux LVM
    
  4. d オプションを使用してパーティションを削除します。複数のパーティションが利用可能な場合は、fdisk により、削除するパーティションの数を指定するようにプロンプトが表示されます。
    Command (m for help): d
    Partition number (1,2, default 2): 2
    Partition 2 is deleted
    
  5. n オプションを使用してパーティションを作成し、プロンプトに従います。今後サイズを変更する場合は、十分な領域を確保してください。fdisk のデフォルト動作( Enterを押す)は、デバイス上のすべての領域を使用することです。パーティションの終わりをセクターで指定するか、+ <size> <suffix> を使用して人間が判読できるサイズ を指定できます(例:+500M、または +10G)。
    fdisk はパーティションの終わりを物理セクターに合わせるため、すべての空き領域を使用しない場合は、人間が判読可能なサイズの指定を使用することを Red Hat は推奨しています。正確な数(セクター内)を指定してサイズを指定すると、fdisk はパーティションの終わりをあわせません。
    Command (m for help): n
    Partition type:
       p   primary (1 primary, 0 extended, 3 free)
       e   extended
    Select (default p): *Enter*
    Using default response p
    Partition number (2-4, default 2): *Enter*
    First sector (1026048-31457279, default 1026048): *Enter*
    Using default value 1026048
    Last sector, +sectors or +size{K,M,G} (1026048-31457279, default 31457279): +500M
    Partition 2 of type Linux and of size 500 MiB is set
    
  6. パーティションのタイプを LVM に設定します。
    Command (m for help): t
    Partition number (1,2, default 2): *Enter*
    Hex code (type L to list all codes): 8e
    Changed type of partition 'Linux' to 'Linux LVM'
    
  7. エラーが選択したパーティションで不安定になる可能性があるため、変更が正しい場合は、w オプションで変更を書き込みます。
  8. デバイスで e2fsck を実行して、整合性をチェックします。
    # e2fsck /dev/vda
    e2fsck 1.41.12 (17-May-2010)
    Pass 1:Checking inodes, blocks, and sizes
    Pass 2:Checking directory structure
    Pass 3:Checking directory connectivity
    Pass 4:Checking reference counts
    Pass 5:Checking group summary information
    ext4-1:11/131072 files (0.0% non-contiguous),27050/524128 blocks
    
  9. デバイスをマウントします。
    # mount /dev/vda
詳細は、fdisk(8) の man ページを参照してください。