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'm currently running an Amazon EC2 - Medium Tier reserved instance for hosting client websites. Recently it seems space is starting to run low on /dev/sda1 - so I thought I'd better prepare..

df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1             8.0G  5.6G  2.5G  70% /
none                  848M  116K  848M   1% /dev
none                  853M     0  853M   0% /dev/shm
none                  853M   56K  853M   1% /var/run
none                  853M     0  853M   0% /var/lock
/dev/sda2             335G  195M  318G   1% /mnt

I've seen this Question : How to mount space in /dev/sda2 - which offers one solution, but how do you resize an active partition like sda1 so I don't have to change our current setup? Or is there better ways to utilize sda2?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

DO NOT USE THE SPACE IN /mnt! This is ephemeral storage and will not persist across reboots - if you put stuff in there IT WILL BE LOST. Some linux distros mount the ephemeral storage up for you as a convenience, use it for temp or swap.

You have a couple options.

Increase Root Drive Size

You can't resize /dev/sda1 on the fly. You can resize it on launch, however. This will require downtime, but what you can do is

  1. Snapshot the existing instance into an AMI. This should give you ami-yyyyyy (I hope you are doing this or something like it already to make backups over time!)

    ec2-stop-instances i-xxxxxx

    ec2-create-image --name my-image-name-v1.0 --description "My lovely Web Server" i-xxxxxxx

  2. Run a new instance of that image with a larger root drive size

    ec2-run-instances -k ssh-key -z us-east-1b -t c1.medium -b "/dev/sda1=:50" ami-yyyyyy

  3. Now you are running instance i-zzzzz. Depending on what Linux you are using you may need to then resize the file system to get the additional space. On Ubuntu, on the box:

    sudo resize2fs /dev/sdf

  4. Now swap in i-zzzzzz for i-xxxxxx in your elastic IP or ELB or DNS or however you're advertising it to the world.

Add A Second Drive

This is probably better - marginally more expensive, but best practice is NOT to put a bunch of stuff on your root drive, as if it fills up with logs or files you're going to crash and have a sad time of recovery.

  1. Create an EBS volume of the desired size, let's say 20 GB. This gives you a volume, vol-yyyyyy.

    ec2-create-volume -z us-east-1b -s 20

  2. Attach the volume to your instance

    ec2-attach-volume vol-yyyyyy -i i-xxxxxx -d /dev/sdf

  3. On the instance, create a filesystem on it and mount it

    sudo mkfs -t ext3 /dev/sdf

    sudo mkdir -p /web

    sudo mount /dev/sdf /web

  4. Move your web root over to there.

  5. Add the new drive permanently to /etc/mnttab

    /dev/sdf /opt/apps ext3 defaults,rw 0 0

  6. Snapshot your new image to AMI as in step 1 - always a good practice.

This also has the benefit of being able to back up that EBS separately by just snapshotting the volume, and also if you need to kill one server and bring up another, you can detach the /web EBS volume from one and attach it to the other, making data migration easy.

share|improve this answer

I'd bind mount things out of /mnt into / as required. It's not perfect, but it's better than nowt, and is minimally intrusive.

share|improve this answer
    
In AWS that space is ephemeral and is deleted on reboot! You should absolutely not use it for e.g. Web content. –  Ernest Mueller Aug 5 '11 at 14:08
    
This is news to nobody, of course all your storage gets wiped on reboot on EC2. The OP wants to know how to use /mnt, and I told him. –  womble Aug 5 '11 at 21:58
    
Your EBS storage doesn't. Read the question. he's using it for client website hosting. He didn't know that it was inappropriate for that use. –  Ernest Mueller Aug 10 '11 at 20:20
    
I don't automatically assume everyone is an idiot. Perhaps I should make an exception in some cases, though. –  womble Aug 10 '11 at 20:44

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.