I have a tiny EC2 instance for small experiments and needed to resize my the root EBS volume from 8G to 10G. There is a good official guide for this: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-modify-volume.html, but it didn’t quite work for me. Below is what I tried and how I solved it.
growpart error NOCHANGE
aws CLI tool is great and I was able to request the resize. The next step was to SSH into the VPS,
lsblk, and resize the first partition. Here’s what I got:
All the posts that I found online mostly reiterated the steps from the guide, there was nothing about such an error anywhere. The closest I could find is this thread on the AWS forum https://forums.aws.amazon.com/thread.jspa?threadID=293496 saying:
When I used the same instance type (c5.2xlarge) and the same OS (Debian Linux 8 (jessie)) as you, I faced the same issue as you. However, when I repeated the same test using Amazon Linux AMI and I wasn’t able to reproduce the issue. Hence the issue is related to the OS and its configuration, rather than the C5 instance type per-se.
In my case, I’m using an Arch Linux image from https://www.uplinklabs.net/projects/arch-linux-on-ec2/. Based on the guides, I should be able to resize the volume without detaching it, but that didn’t happen here; maybe the Linux kernel isn’t built with some necessary patches. I finally noticed that
lsblk still detected the old size:
1 2 3 4
And that’s obviously the cause of the error above.
growpart “failed to resize”
When I restarted the instance, the
nvme0n1 device was 10 GB indeed whereas the first partition was still 8 GB. Here we go:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
Uh-oh, it didn’t work.
growpart is mentioned in all the guides, I thought it was AWS-specific, but it’s actually a script from Debian as the
mkinitcpio-growrootfs package mentions here: https://github.com/GregSutcliffe/aur-projects/tree/master/mkinitcpio-growrootfs. This package was installed in the AMI by default, and the README also mentions the
grow hook for
mkinitcpio, which should resize the root FS at boot. The hook was already setup, but it clearly didn’t work.
https://aur.archlinux.org/packages/mkinitcpio-growrootfs/#comment-493684 has an old comment that the script doesn’t work with the newer
sfdisk, but the script from the fork didn’t work for me either. I couldn’t find much information about this.
resize2fs failed too of course.
cfdisk to the rescue
I was going to resort to the hassle of starting a new VPS, attaching the volume and resizing it there, when I launched
sudo cfdisk /dev/nvme0n1p1 — and it had an option to resize the partition to 10G, write the partition table, and done!
1 2 3 4 5 6 7 8 9 10
I tried to use
fdisk later, but apparently it can’t resize partitions.