Skip to content

Instantly share code, notes, and snippets.

@tspicer
Created February 14, 2014 14:23
Show Gist options
  • Save tspicer/9001801 to your computer and use it in GitHub Desktop.
Save tspicer/9001801 to your computer and use it in GitHub Desktop.
Resize Root Volume Linux on EC2
Stop the instance
Create a snapshot from the volume
Create a new volume based on the snapshot increasing the size
Check and remember the current's volume mount point (i.e. /dev/sda1)
Detach current volume
Attach the recently created volume to the instance
Access via SSH to the instance and run fdisk /dev/<volume>
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')
Hit p to show current partitions
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
Hit n to create a new partition
Hit p to set it as primary
Hit 1 to set the first cylinder
Set the desired new space (if empty the whole space is reserved)
Hit a to make it bootable
Hit 1 and w to write changes
Detach modified new root volume from running instance.
Detach old root volume from stopped instance
Attach new root volume to the instance you removed the old root volume
Attach new root volume as /dev/sda1
Restart
Finally check the new space running df -h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment