Skip to content

Instantly share code, notes, and snippets.

@HelioCampos
Last active January 4, 2018 13:22
Show Gist options
  • Save HelioCampos/f75852c7777d3b68c30c to your computer and use it in GitHub Desktop.
Save HelioCampos/f75852c7777d3b68c30c to your computer and use it in GitHub Desktop.
Expand ext4 inside EBS without LVM
  1. Careful to stop Autoscaling procedures if necessary otherwise you may loose the machine and the disk;
  2. Stop the server;
  3. Umount the disk;
  4. Create a snapshot;
  5. Create a new volume with the wanted size using the snapshot;
  6. Mount the volume in a running machine;

Using fdisk

a. Execute: fdisk /dev/xvd? according to the name you gave in (5);

b. Type pto print the partition table;

c. Save the starting block and the Id of the partition you want to enlarge;

d. Type d to delete the partition;

e. Type pto ensure the partition was deleted;

f. Type nto create a new partition;

g. Type pto choose the new partition as primary;

h. Type <ENTER> to confirm it as the first partition;

i. Type the starting block number you saved in step (c);

j. Type <ENTER>to accept the default end partition. This will make it use all the disk;

k. Type p to see the new partition configuration and review everything;

l. Type w to permanently write the information to the disk;

Using parted

a. Execute: parted /dev/xvd? according to the name you gave in (5);

b. Type print;

c. Type fix to fix the problems encontered in the GPT partition;

d. Save the number of the partition you want to enlarge;

e. Type resizepart ? according with the number of the partition you wanted saved in (d);

f. Type yes to confirm;

g. Type the size you want the partition to have;

h. Type print;

i. Type quit;

  1. Mount the partition only to confirm the original partition is still working;
  2. Umount the partition;
  3. Execute partprobe to sync the new disk configuration to linux (You may also reboot Linux if you want);
  4. Execute e2fsck -f /dev/xvd?1 to check the disk for errors;
  5. Execute resize2fs /dev/xvd?1 to the disk so it will enlarge the partition to fit all disk as you configured;
  6. Mount the partition only to confirm the new partition is still working;
  7. Umount the partition;
  8. Detach the disk from the running server;
  9. Attach the disk to the old server as /dev/sda1;
  10. Start the server;
  11. Wait until the server is online;
  12. SSh to the server to confirm its all working;
  13. Restart the autoscaling procedures to allow the server to came back;
  14. Change the autoscaling configuration so you will use a new disk of the size you want;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment