Can I change the root EBS device of my Amazon EC2 instance?

I have an Amazon EC2 instance supported by EBS. I would like to change the root device on this instance. Could you advise a better way to do this?

I only find documentation about changing several block device attributes, but they don't seem to include installation as the root device. Thank you in advance.

+75
amazon-web-services amazon-ec2
Jun 16 2018-11-11T00:
source share
3 answers

Yes, he is dead easily:

  • Stop instance.
  • Disconnect the root volume of the EBS.
  • Attach an alternate EBS volume as root: /dev/sda1
  • Run the instance.

This assumes that your alternate EBS volume is bootable, of course - it must contain a bootable OS image.

+140
Jun 16 '11 at 10:15
source share

I do not have enough comments to add a comment to the selected answer, but I want to indicate that for me /dev/sda1 did not work (was not added as root), but using /dev/xvda worked (attached as root). The instance is one of the new t2.micro using HVM.

+33
Jul 24 '14 at 21:57
source share

In order to tell in detail about the comments of Diomidis Spinellis in the accepted answer to the answer, it is important to check the file system label of the device that you are trying to include as a new root device. Although, to fix the problem with my own server migration, I had to do the following before my instance boots up:

Use the e2label command to change the label of the ext2 / ext3 / ext4 file system that you created for the new root device.

First check the file system label for the current root device.

 $ sudo e2label /dev/xvda1 cloudimg-rootfs 

Install the new device on the same file system label.

 $ sudo e2label /dev/xvdg 'cloudimg-rootfs' 

In my case, the label was cloudimg-rootfs . Sometimes it will be simple.

It is important to understand how e2label works; check man e2label on your computer or visit http://linux.die.net/man/8/e2label for more information.

+12
Jan 09 '15 at 3:58
source share



All Articles