自作amiなどからec2インスタンスを起動したら、設定したディスク容量よりも小さかった時の対応
結論、resize2fs する。
20GB 割り当てたはずなのに….
8GB程度しか割りあたってない...
[root@centos6-base ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/xvde 7.8G 2.1G 5.3G 29% / tmpfs 296M 0 296M 0% /dev/shm
ディスクサイズは20GB割り当てられていることがわかる。
[root@centos6-base ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT xvde 202:64 0 20G 0 disk /
結論目的のディスクをresize2fs してやればよかった。
[root@centos6-base ~]# resize2fs /dev/xvde resize2fs 1.41.12 (17-May-2010) Filesystem at /dev/xvde is mounted on /; on-line resizing required old desc_blocks = 1, new_desc_blocks = 2 Performing an on-line resize of /dev/xvde to 5242880 (4k) blocks. The filesystem on /dev/xvde is now 5242880 blocks long.
ディスク容量を確認する
[root@centos6-base ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/xvde 20G 2.1G 17G 12% / tmpfs 296M 0 296M 0% /dev/shm
resize2fs する前に調べたこと
fdisk しなきゃならないのかどうか、ひとまず確認
[root@centos6-base ~]# fdisk /dev/xvde Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel with disk identifier 0xe1b7a5f5. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won't be recoverable. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) 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'). Command (m for help): p Disk /dev/xvde: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0xe1b7a5f5 Device Boot Start End Blocks Id System
resize2fs 後のディスク
[root@centos6-base ~]# fdisk /dev/xvde -l Disk /dev/xvde: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000
Disk identifier が違うくらい..?
参考
http://blog.suz-lab.com/2012/11/cdp-snapshot-v2-ec2-linuxfsck-ec2.html