Freelance Technical Digital Media Consultant
How to mount an Amazon EBS disk as a drive in Linux (CentOS)
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.)
- Note down the instance id of the instance you want to add more storage to
- 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.
- 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
- 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 - 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 - Create a directory to mount your new drive as on the filesystem, for example we’ll use /files:
# mkdir /files - 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 - Mount the drive by running:
# mount /files - 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
Related posts on coderchris.com:
- How to Mount a Linux LVM2 Partition in Windows
I have a dual boot Windows Vista / Linux Laptop and recently I needed to... - AWS Rolling Thunder In CentOS Linux
I've been using a common technique to deploy source code updates to my Amazon EC2 instances for... - 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,... - 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... - 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...
| Print article | This entry was posted by Chris on January 31, 2011 at 3:10 pm, and is filed under AWS, CentOS, Linux. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |

about 1 year ago
great help. works like a charm.
about 1 year ago
This all works great until I reach step 7. then it tells me, “-bash: /etc/fstab: Permission denied” even if I precede command with sudo. Any ideas?
about 1 year ago
The step you’re referring to is a quick way of writing that line into /etc/fstab – try opening /etc/fstab with a text editor (vi, nano…) and adding the line manually
about 10 months ago
Thanks for the instructions! Helped me a lot.
about 5 months ago
Great Help! Many Thanks!
about 4 months ago
Hi,
In the step 7, is correct # echo “/dev/sdb … OR # echo “/dev/sdf …?? Thanks!
about 3 months ago
Hey friend, I just want to tell you thank you for this tip!
Hey pal!
Try it logged as root or:
# sudo echo “/dev/sdb /files ext3 noatime 0 0″ >> /etc/fstab
all the best