increase EC2 EBS volume after cloning - resize2fs not working

时光总嘲笑我的痴心妄想 提交于 2019-12-24 15:42:59

问题


This is a very similar problem to EC2 Can't resize volume after increasing size. However, I cannot resolve this manually using fdisk because I'm trying to get the whole process to run automatically.

I'm using a python boto (2.39) script (snippet) which takes a snapshot, registers a new AMI with the same block device mapping, and then creates an instance from it.

It's all working well. The new instance is created with a larger volume size. The new instance is loading ok. The only problem I see is that the partition size is kept at the original size instead of the full size.

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/xvda1      7.8G  2.4G  5.0G  33% /

when I run resize2fs it doesn't do anything

$ resize2fs /dev/xvda1
resize2fs 1.42.12 (29-Aug-2014)
The filesystem is already 2096128 (4k) blocks long.  Nothing to do!

Is there a way to run something automatically (scripted) to fix this, or something to do when cloning the image? I'm not using Amazon Linux AMI but rather a debian-based AMI.


回答1:


Amazon Linux will automatically resize the root filesystem to the full size of the volume. This was introduced in Amazon Linux AMI 2014.03.

From the release notes:

Cloud-Init 0.7.2

Cloud-Init has been updated to the 0.7 series, adding a number of useful features. One example is dracut-modules-growroot, which automatically resizes your root filesystem on boot.



来源:https://stackoverflow.com/questions/36666503/increase-ec2-ebs-volume-after-cloning-resize2fs-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!