AWSでEBSを動的に拡張する
EBSをオンラインで拡張する
[ec2-user@ip-172-31-6-252 ~]$ df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 488M 56K 488M 1% /dev tmpfs 497M 0 497M 0% /dev/shm /dev/xvda1 7.8G 1.1G 6.7G 14% /
EBSのメニューから
ボリュームの変更でサイズ変更
今回は8GB → 20GBに変更
5分しないぐらいで完了
※増やすことはできても減らすことは出来ないようだ
[ec2-user@ip-172-31-6-252 ~]$ sudo fdisk -l /dev/xvda Disk /dev/xvda: 21.5 GB, 21474836480 bytes, 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 label type: dos Disk identifier: 0x00000000 Device Boot Start End Blocks Id System /dev/xvda1 1 16777215 8388607+ ee GPT
リサイズ
[ec2-user@ip-172-31-6-252 ~]$ sudo resize2fs /dev/xvda resize2fs 1.42.12 (29-Aug-2014) resize2fs: Device or resource busy while trying to open /dev/xvda Couldn't find valid filesystem superblock.
起動ディスクなど、パーティション切られてるとちょっとめんどくさいみたい。
めんどくさいのでEBS作り直してもう一度
[root@ip-172-31-6-252 ~]# mount /dev/xvdf /tmp [root@ip-172-31-6-252 ~]# df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 488M 60K 488M 1% /dev tmpfs 497M 0 497M 0% /dev/shm /dev/xvda1 7.8G 1.1G 6.7G 14% / /dev/xvdf 4.8G 10M 4.6G 1% /tmp [root@ip-172-31-6-252 ~]# fdisk -l /dev/xvdf Disk /dev/xvdf: 5368 MB, 5368709120 bytes, 10485760 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
5GBのディスクを10GBに拡張する
[root@ip-172-31-6-252 ~]# fdisk -l /dev/xvdf Disk /dev/xvdf: 10.7 GB, 10737418240 bytes, 20971520 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 [root@ip-172-31-6-252 ~]# resize2fs /dev/xvdf resize2fs 1.42.12 (29-Aug-2014) Filesystem at /dev/xvdf is mounted on /tmp; on-line resizing required old_desc_blocks = 1, new_desc_blocks = 1 The filesystem on /dev/xvdf is now 2621440 (4k) blocks long. [root@ip-172-31-6-252 ~]# df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 488M 60K 488M 1% /dev tmpfs 497M 0 497M 0% /dev/shm /dev/xvda1 7.8G 1.1G 6.7G 14% / /dev/xvdf 9.8G 12M 9.3G 1% /tmp
増えとる!!
OS起動するディスクとか、パーティションが切ってあるEBSは安易に変更しないほうがいい
(当然かもしれないが)後々に拡張する可能性があるデータは別でディスクを用意するのが良い、パーティションは切らない
EBSは細かい容量でアタッチできるのでパーティション切るような運用はやめたほうがいいのかもしれない