Skip to content

Instantly share code, notes, and snippets.

@mijndert
Last active May 14, 2020 12:02
Show Gist options
  • Select an option

  • Save mijndert/bfdf615ef69f5847652e140726f7b122 to your computer and use it in GitHub Desktop.

Select an option

Save mijndert/bfdf615ef69f5847652e140726f7b122 to your computer and use it in GitHub Desktop.
1. Create and start an EC2 instance with the same OS (+version)
2. Create a snapshot of the original root volume
3. Create a new volume from the snapshot (source)
4. Create a new larger/smaller volume (target)
5. Connect the source as xvdf
6. Connect the target as xvdg
Run these commands:
e2fsck -f /dev/xvdf1
resize2fs -M -p /dev/xvdf1
Note: save the amount of blocks this results in to calculate the new blocks:
(result) * 4 / 1024 = (new blocks)
dd bs=1M if=/dev/xvdf of=/dev/xvdg count=new blocks
e2fsck -f /dev/xvdg1
Connect the target volume to the original instance as /dev/sda1 and boot from the newly created volume.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment