Set EBS as root partition on EC2


We can replace main partition in EC2 using EBS for larger space. Make sure to use HVM instead of Paravirtual.
First thing, we need to create a new EBS and attach it into running instance. Now, we should login into our SSH server.

1. Copy old instance into new instance
Find what your root partition and new ebs partition by “sudo fdisk -l”. At this example, mine is “/dev/xvda1” for current main partition and new ebs at “/dev/xvde”. So, i need to clone from current main partition into new ebs.

1
dd bs=65536 if=/dev/xvda1 of=/dev/xvde

2. Check new partition

1
2
3
sudo fsck /dev/xvde
sudo e2fsck -f /dev/xvde
sudo resize2fs /dev/xvde

3. Installing
We need to stop the instance, detach all ebs partition. Then re-attach new ebs partition into instance with mount point into “/dev/sda1”. Re-associate your elastic IP (if any) and start instance.


Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.