amazon-ec2centosimage-resizingsnapshot

EC2 Can't resize volume after increasing size


I have followed the steps for resizing an EC2 volume

  1. Stopped the instance
  2. Took a snapshot of the current volume
  3. Created a new volume out of the previous snapshot with a bigger size in the same region
  4. Deattached the old volume from the instance
  5. Attached the new volume to the instance at the same mount point

Old volume was 5GB and the one I created is 100GB Now, when i restart the instance and run df -h I still see this

Filesystem            Size  Used Avail Use% Mounted on
/dev/xvde1            4.7G  3.5G 1021M  78% /
tmpfs                 296M     0  296M   0% /dev/shm

This is what I get when running

sudo resize2fs /dev/xvde1

The filesystem is already 1247037 blocks long.  Nothing to do!

If I run cat /proc/partitions I see

 202       64  104857600 xvde
 202       65    4988151 xvde1
 202       66     249007 xvde2

From what I understand if I have followed the right steps xvde should have the same data as xvde1 but I don't know how to use it

How can I use the new volume or umount xvde1 and mount xvde instead?

I cannot understand what I am doing wrong

I also tried sudo ifs_growfs /dev/xvde1

xfs_growfs: /dev/xvde1 is not a mounted XFS filesystem

By the way, this a linux box with centos 6.2 x86_64


Solution

  • Thank you Wilman your commands worked correctly, small improvement need to be considered if we are increasing EBSs into larger sizes

    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

      WARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c') and change display units to sectors (command 'u')

    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 OR use partprobe (from the parted package) to tell the kernel about the new partition table
    18. Log via SSH and run resize2fs /dev/xvde1
    19. Finally check the new space running df -h