Skip to content

Instantly share code, notes, and snippets.

@Marshall-Hallenbeck
Created March 11, 2026 19:49
Show Gist options
  • Select an option

  • Save Marshall-Hallenbeck/eebcd72fef1278763df519a7387c9e4f to your computer and use it in GitHub Desktop.

Select an option

Save Marshall-Hallenbeck/eebcd72fef1278763df519a7387c9e4f to your computer and use it in GitHub Desktop.
dynamic online disk extension
#!/bin/bash
# for ROOT
LV=$(findmnt -no SOURCE /)
VG=$(lvs --noheadings -o vg_name "$LV" | xargs)
PV=$(pvs --noheadings -o pv_name --select "vg_name=$VG" | xargs)
DISK=/dev/$(lsblk -no PKNAME "$PV")
sudo sh -c "echo 1 > /sys/class/block/${DISK##*/}/device/rescan"
sudo cfdisk "$DISK"
sudo pvresize "$PV"
sudo lvextend -l +100%FREE -r "$LV"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment