Wednesday, March 2, 2011

start a 11.04 instance with a larger root filesystem

In order to fit inside the Amazon "Free Tier", Ubuntu made the decision to change its root volume size from 15G to 8G. That decision was made for all refreshed EBS root images. So, our current set of 10.04, 10.10 and 11.04 images have 8G root filesystems.

If you find that space somewhat limiting, it is easy to give yourself a larger root volume at instance creation time. Its easy


Launch the instance with appropriate block-device-mapping arguments


$ ec2-run-instances $AMI --key mykey --block-device-mapping /dev/sda1=:20

That will create you an instance with a 20G root volume. However the filesystem on that volume will still only occupy 8G of the space. Essentially, you'd have 12G of unused volume at the end of the disk.


Resize the root volume

if you've launched an 11.04 based image newer than alpha-2, this step is not necessary. Cloud-init will do it for you. It is just assumed that you want your root filesystem to fill all space on its partition. I honestly cannot think of a reason why you would not want that.

Now, if you are using 10.04 or 10.10 images, you can resize your root volume easily enough after the boot. Just login, and issue:


$ sudo resize2fs /dev/sda1

That operation should take only a few seconds or less, and you'll then have all the space you need.

5 comments:

  1. And now only Ubuntu xfs root volumes...

    ReplyDelete
  2. @Berend,
    I had previously blogged about how you can use xfs as your root filesystem at [1]. I have to say, XFS as the default filesystem for Ubuntu images is unlikely, but it seems that people expect btrfs might become the default sometime in the not too distant future.
    FWIW, if you do follow the blog entry and make an XFS root filesystem, cloud-init should resize it up for you on first boot in the same way. If you find out otherwise, please open a bug.


    --
    [1] http://ubuntu-smoser.blogspot.com/2010/11/create-image-with-xfs-root-filesystem.html

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. Is it possible to change this after creation, in case you just found out ;)

    Of course we can create new images and rebuild but it might be nice to avoid the migration work.

    ReplyDelete
  5. For what it's worth, I do run some Ubuntu instances with XFS on the root EBS volume.

    ReplyDelete