Recover data from a unbootable EC2 VPS with ubuntu

How to activate and mount a second HDD on EC2 Ubuntu VPS

On Amazon AWS EC2 VPS server it might be useful to mount a 2. hard disk drive.  Maybe your primary disk is full. This is how it’s done.

Recover data from a EC2 VPS instance with Ubuntu that won’t boot

Sometimes you need to restore files from a snapshot or a volume that wont boot. In this case the volume could be opened by mounting it as a 2. drive on a temporary EC2 instance. This procedure is useful if your EC2 instance is unable to boot. Then you can set up a new ECS VPS server and mount the non bootable disk as a second disk and extract the files from it. Need help? Don’t hesitate to contact me.

Sometimes you need to restore files from a snapshot or a volume that wont boot. In this case the volume could be opened by mounting it as a 2. drive on a temporary EC2 instance.

 

First see if the drive is attached with this command:

sudo fdisk –l

You will get a listing of available drives. If the drive already exist it will reveal itself with this line:

Disk /dev/xvdf: 10.7 GB, 10737418240 bytes

Now format the disk with this command, if you haven’t already done so:

sudo mkfs -t ext4 /dev/xvdf

Create a directory where the drive should be mounted:

mkdir /mnt

 

 

This is it. Now you can mount the drive with the command:

sudo mount /dev/xvdf /mnt

 

Check if the disk has been mounted correctly with this command:

mount -l

You should get this result:

/dev/xvdf on /mnt1 type ext4 (rw)

 

Mount on startup

Set the drive to mount automatically on system startup with adding a line to the configuration file:

sudo nano /etc/fstab

and add this line to the file:

/dev/xvdf /mnt1 auto defaults,nobootwait 0 0

Save the file and exit Nano.

 

Reboot the server to check that everything works correctly

After reboot you can access the  new drive with the command:

cd /mnt1

 

mkdir /www.tbt.no

That’s it.

 

Your new root folder for Apache is ready for use at the address:

/mnt/www.tbt.no/

Credits

Source for this article is Mikhael Plavskiy

 

Alternativ address:

http://www.tbt.no/ec2-mount-2-hd-to-retrieve-files/