Tag Archives: virtual machine

Adding Instance Storage after upgrading a Micro instance on Amazon EC2

Cloud-Storage I recently upgraded a Micro (t1.micro) instance to a Small (m1.small) version on Amazon EC2. This was performed with no real trouble at all (Stop, Change Instance Type, Start). However, I noticed upon boot that I did not have any of the promised Instance Storage available to me. On the m1.small, 160 gigabytes is mentioned. Where was it?

It turns out that for EBS-backed AMIs (including Amazon Linux, the OS in use for this example) , the instance storage is not automatically baked in. It is possible to ensure it is added when starting a new VM, but I was never given an option to do this due to going down the upgrade path. It turns out it is not possible to add it to an instance that is already in operation. So, what to do?

Firstly, the official Amazon documentation: Adding Instance Store Volumes to an AMI.

These are the steps I needed to take, which I accomplished via the AWS Console rather than via the command line.

  1. Stop the Instance. You don’t have to do this prior to the next step, but for consistency, it is best you do.
  2. Create a Snapshot.
  3. Create a new AMI from the Snapshot (This is where the steps in the official guide linked above come into play). For the m1.small, I added two Instance Store Volumes (as you get a ‘swap’ partition as well).
  4. Create a new instance using your new AMI as the source.
  5. If relevant, re-assign any Elastic IP Address to the new instance.
  6. Start the new instance.
  7. You’re done!

Upon boot, Amazon Linux auto-detects the new available partitions.

The main storage partition:

$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/xvda1            7.9G  2.3G  5.6G  30% /
tmpfs                 829M     0  829M   0% /dev/shm
/dev/xvdb             147G  188M  140G   1% /media/ephemeral0

… and the swap partition:

[  169.078672] Adding 917500k swap on /dev/xvda3.  Priority:-1 extents:1 across:917500k SS


Note that by default, Amazon Linux formatted the storage partition as ext3. You may well want to convert it to ext4 (I just reformat it here, so don’t do it this way if you’ve put data there!)

$ sudo umount /dev/xvdb
$ sudo mke2fs -t ext4 /dev/xvdb
mke2fs 1.42.3 (14-May-2012)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
9773056 inodes, 39088128 blocks
1954406 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
1193 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
	4096000, 7962624, 11239424, 20480000, 23887872
Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done     
$ sudo mount /media/ephemeral0

One final and standard warning regarding Instance Storage on EC2: It will be erased upon your instance Terminating, which could include a failure condition. As a result, never use it for data you rely on (use EBS instead).