Tuesday 29 September 2015

Resize EC2 instance EBS root device

Today I stumbled upon the problem that resizing the root EBS volume of a just launched EC2 instance (running CentOS 6) did not work.

I tried to run the following command:"resize2fs /dev/xvde1"
This returned with:The filesystem is already x blocks long. Nothing to do!

However I was pretty sure that there was still roughly 1TB extra available for me. I figured out how to resolve this, with the following commands:
1. Connect to the instance over ssh2. "fdisk /dev/xvde1"3. Press "p" + ENTER to view the current partitions, remember the ID of your partition4. Fill in "d 999", where 999 represents the partition ID from step 3, hit ENTER (this will delete your partition)5. Press "n" + ENTER to start creating a new partition6. Press "p" + ENTER to mark it as a primary partition7. Select the first cylinder by entering "1" and hitting ENTER8. Your start and end block can be default (e.g. 1 and 1234567)9. Press "a" to mark the partition as bootable10. Now we're done press "w" to write the partition table, this will cause you to get an error, don't worry11. Reboot your instance to reload the partition table (as mentioned in the error you received on step 10)12. Connect to your instance again over ssh13. Run "resize2fs /dev/xvde1", this might take a while, it performs an online grow of the partition14. Once the resize2fs command has finished you can validate the results by running "df -h"
Good luck with resizing your EC2 instance root devices!

Source : http://www.robinverlangen.nl/index/view/5035f20d64fa0-d74cc2/resize-ec2-instance-ebs-root-device.html

Versi lain
=========
1. Stop the instance
 2. Create a snapshot from the volume
 3. Create a new volume based on the snapshot increasing the size
 4. Check and remember the current's volume mount point (i.e. /dev/sda1)
 5. Detach current volume
 6. Attach the recently created volume to the instance, setting the exact mount point
 7. Restart the instance
 8. Access via SSH to the instance and run fdisk /dev/xvde
 9. Hit **p** to show current partitions
 10. Hit **d** to delete current partitions (if there are more than one, you have to delete one at a time) NOTE: Don't worry data is not lost
 11. Hit **n** to create a new partition
 12. Hit **p** to set it as primary
 13. Hit **1** to set the first cylinder
 14. Set the desired new space (if empty the whole space is reserved)
 15. Hit **a** to make it bootable
 16. Hit **1** and **w** to write changes
 17. Reboot instance
 18. Log via SSH and run resize2fs /dev/xvde1
 19. Finally check the new space running df -h
Source : http://stackoverflow.com/questions/11014584/ec2-cant-resize-volume-after-increasing-size

No comments:

Post a Comment