new EBS volume for /var

Amazon EC2 AMIs have minimal amount of non-volatile disk space on its instances. You’re free to use it’s ethereal volume (/mnt) but bear in mind that in case the instance is stopped or rebooted a certain way, the contents of the volume will be wiped out.

One solution is to use EBS for additional storage. Taking it one step further, let’s mount the new EBS volume on /var and make the bigger disk space available to MySQL and apache httpd.

 1. Create new EC2 instance (ec2new)
 Note: I use the AMIs posted at http://cloud.ubuntu.com/ami/. Match the region and architecture with the version that you need.

2. Update ec2new
 # apt-get update && apt-get upgrade -y

3. Create the new EBS volume (ebsnew)
 Note: Use the AWS Management Console for Elastic Block Storage. Take note of the device label (i.e. /dev/xyz).

4. Check the device label for the new volume.
 # fdisk -l
 Note: /dev/xyz should match the new volume size.

4. Format ebsnew
 # mkfs.ext3 /dev/xyz

5. Temporarily mount ebsnew to /srv
 # mount /dev/xyz /srv

6. Backup /var to /srv
 # rsync -avr /var/ /srv/

7. Edit /etc/fstab
 /dev/xyz /var auto defaults,nobootwait,noatime 0 0

8. Reboot ec2new
 

Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.