Skip to content

Instantly share code, notes, and snippets.

@withakay
Last active February 4, 2021 17:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save withakay/2c7c2bb055bf2046974ede380dd4f937 to your computer and use it in GitHub Desktop.
Save withakay/2c7c2bb055bf2046974ede380dd4f937 to your computer and use it in GitHub Desktop.
Extend/Resize a partition and logic volume on Ubuntu Linux that was installed with LVM enabled
#!/usr/bin/env bash
# This script will extend the logical volume
# To use all the free space.
# Run this after increasing the size of the virtual disk.
# NOTE, run as sudo.
# Run `pvdisplay` to check your device numbers match up
# /dev/sda3 & ubuntu-vg & ubuntu-lv are the defaults
# if you chose LVM when installing Ubuntu
DEVICE=sda
PART=3
VG=ubuntu-vg
LV=ubuntu-lv
growpart /dev/$DEVICE $PART
pvresize /dev/$DEVICE$PART
lvextend -l +100%FREE /dev/$VG/$LV
resize2fs /dev/$VG/$LV
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment