Skip to content

Instantly share code, notes, and snippets.

@sxiii
Last active December 5, 2022 10:48
Show Gist options
  • Save sxiii/18dc63b2c0d9c97362771eec6923e462 to your computer and use it in GitHub Desktop.
Save sxiii/18dc63b2c0d9c97362771eec6923e462 to your computer and use it in GitHub Desktop.
Resize linux partition that was written by DD or similar instrument to use all available space

Please run the following commands to resize a partition.
IMPORTANT NOTE: Don't forget to change partition address from /dev/sdb2 to your actual partition!
CHANGES ARE DONE IN TWO OR THREE PLACES.
Example below are for /dev/sdb2 partition which is called like "/dev/sdb 2" for growpart
and like "/dev/sdb2" for resize2fs & e2fsck.
Requirements: * growpart; * resize2fs; * e2fsck if disk requires checking.
Install growpart in arch/manjaro: pikaur -S growpart (resize2fs and e2fsck are usually bundled with OS)

sudo growpart /dev/sdb 2
sudo resize2fs /dev/sdb2

Also run as a oneliner is possible:

sudo growpart /dev/sdb 2 && sudo resize2fs /dev/sdb2

If it asks for checking partition errors, use this:

sudo e2fsck -f /dev/sdb2

Or, as a oneliner:

sudo growpart /dev/sdb 2 && sudo e2fsck -f /dev/sdb2 && sudo resize2fs /dev/sdb2

NOTE: The following works for EXT4 parition. If your parition is F2FS, please use:

resize.f2fs /dev/sdb2

After issuing this command you might want also to run sudo gparted and check if your partition is now filled in full.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment