Skip to content

Instantly share code, notes, and snippets.

@bouroo
Created November 10, 2023 07:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bouroo/90d64e3a22cc1f41294103e03e7a9ebc to your computer and use it in GitHub Desktop.
Save bouroo/90d64e3a22cc1f41294103e03e7a9ebc to your computer and use it in GitHub Desktop.
linux extend disk partition script
#!/usr/bin/env bash
# find root path
ROOT_DEV=$(findmnt -n -o SOURCE /)
# rescan disk size
echo 1 | sudo tee /sys/block/sda/device/rescan
# grow partition that contains root
# extend partition size
growpart /dev/sda 3
# extend physical volume
pvresize /dev/sda3
# extend logical volume
lvextend -r -l +100%FREE ${ROOT_DEV}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment