Red Hat Training
A Red Hat training course is available for Red Hat Enterprise Linux
13.5. fdisk でのパーティションのサイズ変更
fdisk
ユーティリティーを使用すると、GPT、MBR、Sun、SGI、BSD パーティションテーブルを作成および操作できます。fdisk
GPT サポートは実験段階にあるため、GUID パーティションテーブル (GPT) を持つディスクでは、parted
ユーティリティーを使用することを推奨します。
fdisk
を使用してパーティションのサイズを変更する唯一の方法は、パーティションを削除して再作成することであるため、パーティションのサイズを変更する前に、ファイルシステムに保存されているデータを バックアップし、手順をテストしてください。
重要
サイズを変更するパーティションは、特定ディスクの最後のパーティションにする必要があります。
Red Hat は、LVM パーティションの拡張とサイズ変更にのみ対応しています。
手順13.4 パーティションのサイズ変更
以下の手順は、参照用にのみ提供されています。
fdisk
を使用してパーティションのサイズを変更するには:
- デバイスをアンマウントします。
#
umount /dev/vda - fdisk ディスク名 を実行します。以下に例を示します。
#
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): 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
- パーティションを削除するには、d オプションを使用します。使用可能なパーティションが複数ある場合、fdisk は 削除するパーティションの番号を指定するように求めます。
Command (m for help): d Partition number (1,2, default 2): 2 Partition 2 is deleted
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
- パーティションのタイプを 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'
- エラーが発生すると、選択したパーティションが不安定になる可能性があるため、変更が正しいことが確実な場合は、w オプションを使用して変更を書き込みます。
- デバイスで 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 - デバイスをマウントします。
#
mount /dev/vda
詳細は、fdisk(8) の man ページを参照してください。