1

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.

Community
  • 1
  • 1
gingerlime
  • 5,206
  • 4
  • 37
  • 66
  • Have you gone into the console and verified that the volume attached to the new instance is actually larger than 8GB? I would do that first to make sure it isn't a problem in the way you are creating the AMI or in the way you are launching the new instance. – Mark B Apr 16 '16 at 16:18
  • Yes, the attached volume is definitely the right size. I can also follow the manual fdisk process and resize it successfully. But every time I run it - the same thing happens. Looking for a way to automate the fix or avoiding the problem in the first place... – gingerlime Apr 16 '16 at 16:22
  • Ah! Thanks for the pointer, Mark B ! The volume was the right size, but the **snapshot** wasn't updated... Once I updated the snapshot, which had the right size and right partition table, the size was ok... I'm still curious about an automated way to do this fdisk, e.g. if I want to increase the volume size automatically though, but at least it's not a burning issue. – gingerlime Apr 16 '16 at 16:34
  • note - I edited the question to ask about the more general problem (increasing storage size and resizing automatically) rather than the specific problem I was facing. – gingerlime Apr 25 '16 at 17:35

1 Answers1

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.

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
  • 1
    That's good to know, but I'm not using Amazon Linux AMI (and perhaps users of other AMIs / distros would also be interested finding a way to resize the volume automatically?) – gingerlime Apr 17 '16 at 05:52