Skip to content

Instantly share code, notes, and snippets.

@D4R4
Created May 14, 2019 03:11
Show Gist options
  • Save D4R4/b3b853d536bfaf8335c377e7e3efcfe1 to your computer and use it in GitHub Desktop.
Save D4R4/b3b853d536bfaf8335c377e7e3efcfe1 to your computer and use it in GitHub Desktop.
extend a partition with a LVM and the contained physical volume and logical volume
1. Resize the partition (again, you can do this with the system running). GParted is easy to use and supports resizing.
You can also use a lower level tool such as fdisk. But you'll have to delete the partition and recreate it. Just make sure when doing so that the new partition starts at the exact same location.
2. partprobe or Reboot. Since the partition table was modified on the running system, it won't take effect until a reboot.
3. Run pvresize /dev/sdXY to have LVM pick up the new space.
4. Resize the logical volume with lvextend. If you want to use the whole thing, lvextend -r -l +100%FREE /dev/VGNAME/LVNAME. The -r will resize the filesystem as well.
Though I always recommend against using the entire volume group. You never know what you'll need in the future. You can always expand later, you can't shrink.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment