Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save speedlight/c3e0d5360e37f56e4de8 to your computer and use it in GitHub Desktop.
Save speedlight/c3e0d5360e37f56e4de8 to your computer and use it in GitHub Desktop.
# Copied from http://ttaportal.org/wp-content/uploads/2012/10/7-Reallocation-using-LVM.pdf
##
## Showing the problem: need to reallocate 32GB from /dev/mapper/pve-data to /dev/mapper/pve-root
##
df -h
# Filesystem Size Used Avail Use% Mounted on
# /dev/mapper/pve-root 37G 37G 0 100% /
# tmpfs 2.0G 0 2.0G 0% /lib/init/rw
# udev 10M 548K 9.5M 6% /dev
# tmpfs 2.0G 0 2.0G 0 /dev/shm
# /dev/mapper/pve-data 102G 19G 84G 19% /var/lib/vz
# /dev/sda1 504M 31M 448M 7% /boot
##
## shrinking /dev/mapper/pve-data
##
# unmount the file system from mount point /var/lib/vz
umount /var/lib/vz
# To check the file system
e2fsck -f /dev/mapper/pve-data
# e2fsck 1.41.3 (12-Oct-2008)
# Pass 1: Checking inodes, blocks, and sizes
# Pass 2: Checking directory structure
# Pass 3: Checking directory connectivity
# Pass 4: Checking reference counts
# Pass 5: Checking group summary information
# /dev/mapper/pve-data: 20/4587520 files (0.0% non-contiguous), 333981/18350080 blocks
# shrink the file system from 102G to 70G
resize2fs /dev/mapper/pve-data 70G
# Resizing the filesystem on /dev/mapper/pve-data to 18350080 (4k) blocks
# The filesystem on /dev/mapper/pve-data is now 18350080 blocks long
# reduce the logical volume /dev/mapper/pve-data with 32GB (102 – 32 = 70 GB)
lvreduce -L-32G /dev/mapper/pve-data
# remount the file system mounted on /var/lib/vz
mount /var/lib/vz
##
## extend /dev/mapper/pve-root
##
# extend the logical volume to fill 100% of the free space
lvextend -l +100% FREE /dev/mapper/pve-root
# expand the filesystem (by default performs on-line resizing!!!)
resize2fs /dev/mapper/pve-root
##
## checking the output
##
df -h
# Filesystem Size Used Avail Use% Mounted on
# /dev/mapper/pve-root 73G 31G 39G 45% /
# tmpfs 2.0G 0 2.0G 0% /lib/init/rw
# udev 10M 548K 9.5M 6% /dev
# tmpfs 2.0G 0 2.0G 0% /dev/shm
# /dev/sda1 504M 31M 448M 7% /boot
# /dev/mapper/pve-data 69G 404M 69G 1% /var/lib/vz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment