lvmではないパーティションをオンライン拡張する(parted)
partedでlvmではないパーティションをオンライン拡張する
手順
1. partedでパーティションを確認する
対象のデバイス(sda)は何らかの方法で特定しておくこと。
sudo parted /dev/sda help print
実行ログ:
user@debian:~$ sudo parted /dev/sda GNU Parted 3.2 Using /dev/sda Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) help align-check TYPE N check partition N for TYPE(min|opt) alignment help [COMMAND] print general help, or help on COMMAND mklabel,mktable LABEL-TYPE create a new disklabel (partition table) mkpart PART-TYPE [FS-TYPE] START END make a partition name NUMBER NAME name partition NUMBER as NAME print [devices|free|list,all|NUMBER] display the partition table, available devices, free space, all found partitions, or a particular partition quit exit program rescue START END rescue a lost partition near START and END resizepart NUMBER END resize partition NUMBER rm NUMBER delete partition NUMBER select DEVICE choose the device to edit disk_set FLAG STATE change the FLAG on selected device disk_toggle [FLAG] toggle the state of FLAG on selected device set NUMBER FLAG STATE change the FLAG on partition NUMBER toggle [NUMBER [FLAG]] toggle the state of FLAG on partition NUMBER unit UNIT set the default unit to UNIT version display the version number and copyright information of GNU Parted (parted) print Model: ATA SanDisk SD???????? (scsi) Disk /dev/sda: 256GB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags 1 1049kB 17.2GB 17.2GB primary linux-swap(v1) 2 17.2GB 34.4GB 17.2GB primary 3 34.4GB 172GB 137GB primary ext4
2. リサイズする
partedでディスクのサイズを拡張する。
終端サイズを指定するため、注意。あらかじめ、必要なサイズを計算すること。(実行ログでは32GBの拡張)
※「resizepart 3 204GB」では「parted: invalid token: 204GB」と言われてしまうので、次の手順とした
resize 3
yes
204GB
実行ログ:
(parted) resizepart 3 Warning: Partition /dev/sda3 is being used. Are you sure you want to continue? Yes/No? yes End? [172GB]? 204GB (parted)
3. リサイズ後の確認
print
quit
実行ログ:
(parted) print Model: ATA SanDisk SD???????? (scsi) Disk /dev/sda: 256GB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags 1 1049kB 17.2GB 17.2GB primary linux-swap(v1) 2 17.2GB 34.4GB 17.2GB primary 3 34.4GB 204GB 170GB primary ext4 (parted) quit Information: You may need to update /etc/fstab. user@debian:~$
4. ファイルシステムのリサイズ
オンラインリサイズに対応しているファイルシステムに限ります。(今回はext3/ext4)
※xfsの場合はxfs_growfs
sudo resize2fs /dev/sda3
df -h
実行ログ:
user@debian:~$ sudo resize2fs /dev/sda3 resize2fs 1.42.12 (29-Aug-2014) Filesystem at /dev/sda3 is mounted on /vmfs/hdd; on-line resizing required old_desc_blocks = 8, new_desc_blocks = 10 The filesystem on /dev/sda3 is now 41415823 (4k) blocks long. user@debian:~$ df -h Filesystem Size Used Avail Use% Mounted on /dev/dm-0 440G 14G 404G 4% / udev 10M 0 10M 0% /dev tmpfs 6.3G 708M 5.6G 12% /run tmpfs 16G 8.0K 16G 1% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 16G 0 16G 0% /sys/fs/cgroup /dev/sda3 156G 120G 29G 81% /vmfs/hdd tmpfs 3.2G 0 3.2G 0% /run/user/1000