Skip to content

Instantly share code, notes, and snippets.

@aanari
Last active November 12, 2024 14:33
Show Gist options
  • Save aanari/dffd6d4f2cb933d4b6385e511b9e5460 to your computer and use it in GitHub Desktop.
Save aanari/dffd6d4f2cb933d4b6385e511b9e5460 to your computer and use it in GitHub Desktop.
Expand a Hard Disk with Ubuntu LVM
# So you're running an Ubuntu server in a virtual machine, and now you need to add 20 GB of disk space to root (/).
# There are quite a few ways to do this, and fortunately you're running the Logical Volume Manager (LVM) in Ubuntu,
# so the process isn't too bad.
# After you make the additional space available in VMWare/Xen/Hyper-V, first reboot your Ubuntu server so it can
# see the new free space (commenter Michal notes that you can avoid this restart by asking the kernel to rescan the
# disk with 'echo 1 > /sys/class/block/sda/device/rescan').
sudo growpart /dev/sda 3
pvdisplay
lvdisplay
pvresize /dev/sda3
lvextend -l+100%FREE /dev/ubuntu-vg/ubuntu-lv
resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
@williamwatts
Copy link

This worked great, thank you.

@aanari
Copy link
Author

aanari commented Mar 19, 2023

Happy to hear that!

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