Skip to content

Instantly share code, notes, and snippets.

@Marshall-Hallenbeck
Last active December 26, 2024 23:41
Show Gist options
  • Save Marshall-Hallenbeck/057a8a8f26b8c3954e2145232a96050a to your computer and use it in GitHub Desktop.
Save Marshall-Hallenbeck/057a8a8f26b8c3954e2145232a96050a to your computer and use it in GitHub Desktop.
Extend running Linux/Ubuntu LV
#!/bin/bash
# extends default Ubuntu LV - update it to whatever LV you are trying to extend, or just write the commands manually
# of course before this you need to increase the capacity of the VM (I use ESXi and just update the size)
# just a reminder for ESXi, if you have any snapshots, the edit size dropdown/entry will be greyed out, so delete any existing snapshots
sudo cfdisk # expand your partition here
# sudo lsblk # do this if you dont know your partition #
sudo pvresize /dev/sda3 # like all of my vms default to sda3 but YMMV
sudo lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv # extend the lv inside the pv (lsblk should be updated now)
# sudo xfs_growfs /dev/system/nsm # resize lvm if you made it an lvm (use this for security onion)
sudo resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv # actually resize the ext partition (what you see via df -h)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment