[ubuntu-cloud] Cannot resize root volume

Scott Moser smoser at ubuntu.com
Mon Jun 17 17:12:34 UTC 2013

On Sun, 16 Jun 2013, Darren Govoni wrote:

Hi, I tried to reproduce this using command line tools, but was not
successful.  Below is what I did.  Lines starting with '>' are your
initial steps, lines with '$' are shell commands executed to do that step.

> I launched a Ubuntu 13.04 Canonical AMI ami-e995e380.
$ ec2-run-instances --key=brickies ami-e995e380 --instance-type=t1.micro
$ inst=i-e891258d
$ hname=ec2-54-242-193-101.compute-1.amazonaws.com
$ ssh ubuntu@$hname 'sudo apt-get install pastebinit'

$ ec2-describe-instances $inst
$ rvolid=vol-05ff3f5f
$ az=us-east-1c

> Created a snapshot of the 8GB volume.
$ ec2-create-snapshot $rvolid
SNAPSHOT snap-31ee916f  vol-05ff3f5f   pending  2013-06-17T16:40:37.000Z
$ snapid=snap-31ee916f

> Created a new volume from that snapshot as 112GB
$ ec2-create-volume -z $az --snapshot $snapid --size 112
$ newvolid=vol-fb23e3a1

> Stopped the instance
$ ec2-stop-instances $inst

> Detached the 8GB volume
# wait til the instance is stopped and then
$ xc2 detach-volume $rvolid

# wait till 'describe-volumes $rvolid' shows the volume as not 'in-use'
# i actually did a subsequent 'detach-volume' here, but that should
# not be relevant/needed.

$ xc2 attach-volume --instance=$inst  --device=/dev/sda1 $newvolid

> Start the instance.
$ xc2 start-instances $inst
$ newhname=ec2-23-20-64-81.compute-1.amazonaws.com
# wait some

$ ssh ubuntu@$newhname 'grep Resiz /var/log/cloud-init.log; df -h /'
2013-06-17 16:38:09,152 - cc_resizefs.py[DEBUG]: Resizing / (ext4) using resize2fs /dev/disk/by-label/cloudimg-rootfs
2013-06-17 16:38:09,186 - cc_resizefs.py[DEBUG]: Resizing took 0.034 seconds
2013-06-17 16:38:09,187 - cc_resizefs.py[DEBUG]: Resized root filesystem (type=ext4, val=True)
2013-06-17 17:02:50,669 - cc_resizefs.py[DEBUG]: Resizing / (ext4) using resize2fs /dev/disk/by-label/cloudimg-rootfs
2013-06-17 17:02:52,742 - cc_resizefs.py[DEBUG]: Resizing took 2.073 seconds
2013-06-17 17:02:52,743 - cc_resizefs.py[DEBUG]: Resized root filesystem (type=ext4, val=True)
Filesystem      Size  Used Avail Use% Mounted on
/dev/xvda1      111G  740M  105G   1% /

> The instance tries to start, but goes back to stopped...it no longer starts.

As you an see, the instance started again, I ssh'd in, and the new root
filesystem was much larger than 8G.

> Also, I tried doing this with the latest 12.04 EBS 64bit AMI and was
> able to do it and create an AMI from the new instance. But the created
> AMI gets a kernel panic and will not launch.

I suspect that you attached the new volume as the wrong device name.
Based on nothing other than guesswork, I guess you used /dev/sda rather
than /dev/sda1.

The other potential possibility for error here is that you said you
snapshotted the system while it was booted.  snapshotting a live root
volume (even if you use something like 'ec2-consistent-snapshot'
(https://github.com/alestic/ec2-consistent-snapshot) could still have
issues.  The better way to do this would be to stop the instance, *then*
snapshot it.


More information about the Ubuntu-cloud mailing list