skip to Main Content

Add EBS VOLUME to Ubuntu EC2 Instance

Lets say we want to mount /var into new partition:

1. create new volume (leave snapshot id empty)
2. name new volume [var-vol] 3. attach volume to instance: right-click on volume/attach and choose the ec2 instance
4. format the instance: using ssh terminal:

mkfs.ext4 /dev/xvdv

5. mount the volume to the file system:

mkdir -m 000 /mnt/var.vol
echo "/dev/xvdv /mnt/var.vol auto noatime 0 0" >> /etc/fstab
mount /mnt/var.vol

6. now stop all possible processes

service --status-all |grep + to see what is running

8. sync /var to /mnt/var.vol using:

rsync -va /var/ /mnt/var.vol

7. rename /var into /var.old

mv /var /var.old

8. make a new var directory

mkdir /var

9. bind-mount the new var.vol to the new-empty /var directory just created:

mount -o bind /mnt/var.vol /var

10. update /etc/fstab to make bind-mount permanent:

echo "/mnt/var.vol /var none bind" >> /etc/fstab

11. cross your fingers and reboot

 

ref: serverfault.com

This Post Has 0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *



Back To Top