Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I already have a ec2 instance running ubuntu on a micro instance. The hard drive is only 7gb. I am shutting down an old server and migrating it to this one. The old server has 15gb of data I need to transfer to the ec2 instance. How can I either a) increase the size of the root ebs drive or b) (the preferred method) add ANOTHER ebs drive so I can transfer the files over and later delete if i need to.

share|improve this question
add comment

3 Answers

up vote 8 down vote accepted

Amazon details the process of attaching EBS volumes, quite well in their documentation

Via the console:

  1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.
  2. Click Volumes in the Navigation pane.
  3. The console displays a list of current volumes.
  4. Select a volume and click Attach Volume.
  5. The Attach Volume dialog box appears.
  6. Select the instance to attach the volume to from the Instance list box (only instances in the same Availability Zone as the volume are displayed).
  7. Select how the device is exposed to the instance from the Device list box.
  8. Click Attach.

Via the command line:

ec2-attach-volume volume_id -i instance_id -d device

You can't resize an EBS volume live - the process entails creating a snapshot, and making a new, larger volume from that snapshot.

To resize a root EBS volume:

  • Stop the instance (not strictly required, but helps with consistency)
  • Take a snapshot of the EBS volume (e.g. ec2-create-snapshot vol-XXXXXXXX)
  • Create a new (larger) volume from the snapshot (e.g. ec2-create-volume --availability-zone XX-XXXX-XX --size XX --snapshot snap-XXXXXXXX)
  • Attach the new volume to an instance (e.g. ec2-attach-volume vol-XXXXXXXX -i i-XXXXXXXX -d /dev/sdXX)
  • check the volume (optional - e.g. e2fsck -f /dev/xvdXX)
  • resize the filesytem (e.g. e.g. resize2fs -p /dev/xvdXX)
  • check the filesystem again (optional)
  • tune the filesystem (optional - e.g. tune2fs -l /dev/xvdXX)
  • detach the EBS volume from the instance (e.g. ec2-detach-volume vol-XXXXXXXX)
  • detach the original root volume from your original instance, and attach the new volume
  • start your original instance and stop the extra one you started

Additionally, it is worth mentioning that /dev/sdXX is a symlink to /dev/xvdXX in recent versions of Linux. Many commands need to be run on /dev/xvdXX even though you tell EC2 to attach to /dev/sdXX.

Also keep in mind that you must pass your private key and certificate to almost all EC2 API commands, or alternatively, you can set (export) the EC2_PRIVATE_KEY and EC2_CERT environment variables so that you don't have to pass these values to every command.

The root volume will be automatically mounted (provided that you have it attached as the same device as the previous root volume). Other, additional EBS volumes that you attach are only made available as devices - they are not automatically mounted. You can get a list of the attached 'volumes' using cat /proc/partitions (as per this answer). To mount your volume, just run mount /dev/xvdXX /path/to/mountpoint.

share|improve this answer
    
I looked everywhere for something like "Volume", but I didn't see it till you said that. Thanks for the detailed explanation. Does that automatically mount it when it attaches? –  LordZardeck May 3 '12 at 17:45
    
No, you must still mount the volume - it simply attaches it to the instance and makes it available as a device. –  cyberx86 May 3 '12 at 17:46
    
awesome, thanks! –  LordZardeck May 3 '12 at 17:49
add comment

Increasing the size of root EBS drive is quite complicated and involves quite a bit of work.

The easier way is to add another EBS volume of desired size, mount and symlink.

share|improve this answer
    
exacly how would I do that? that's what I'm asking. –  LordZardeck May 3 '12 at 17:23
    
There are lots of tutorials on the internet for this. For example, try checking this: coderchris.com/linux/… –  Shyam Sundar C S May 3 '12 at 17:31
add comment

The easiest way to do this is to create another EBS volume of the desired size in the web interface and then attach it to the running instance with the old data. Then you can format the new drive, mount it and copy over the files.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.