These instructions on how to mount an Amazon EBS volume apply to CentOS Linux specifically but with little modification can be applied to all Linux distributions. By attaching EBS volumes (aka. disks) to your instance you can get around the majority file space issues that might encounter when hosting popular websites or those which contain a lot of data (e.g. image galleries, music sites, podcasts, etc.)

  1. Note down the instance id of the instance you want to add more storage to
  2. In your AWS account go to the volumes link (under Elastic Block Store) click the Create Volume Button and choose how big you want this device to be.
  3. Attach the new EBS volume to your instance by right clicking it and choosing Attach Volume. Select the instance id from the list that you noted down in step 1. and give the new device a name to reference it on the instance, e.g. /dev/sdf
  4. Login into your instance on the command line and do and run (# represents the command prompt):
    # ls /dev
    You should see that /dev/sdf has been created for you
  5. Format /dev/sdf by running:
    # mkfs.ext3 /dev/sdf
    It will warn you that this an entire device. You should type y to allow the process to continue unless you want to create specific partitions on this device
  6. Create a directory to mount your new drive as on the filesystem, for example we’ll use /files:
    # mkdir /files
  7. Add a reference in the fstab file to mount the newly formatted drive onto the /files directory by running the following command:
    #  echo "/dev/sdb /files ext3 noatime 0 0" >> /etc/fstab
  8. Mount the drive by running:
    # mount /files
  9. Check your drive has mounted correctly with the expected amount of file space by running:
    # df -h /files

It really is that simple, within a few cli commands you can simply add 1GB to 1TB of storage at the drop of a hat!

Questions? Leave me a comment and I’ll do my best to answer them for you icon smile How to mount an Amazon EBS disk as a drive in Linux (CentOS)





Related posts on coderchris.com:

  1. How to Mount a Linux LVM2 Partition in Windows
    I have a dual boot Windows Vista / Linux Laptop and recently I needed to...
  2. AWS Rolling Thunder In CentOS Linux
    I've been using a common technique to deploy source code updates to my Amazon EC2 instances for...
  3. Windows 7 doesn’t seem to like zip files
    On every other version of windows I've used over the last 12 years or so,...
  4. Installing Red5 Open Source Flash Media Server On CentOS 4.2
    After having no end of issues with the proprietary flash media server 2 from Adobe...
  5. Installing Flash Media Server 2 On Linux (CentOS 4.4)
    Recently I was asked by a client to look at purchasing and installing FMS2 on...