I am trying to shrink a VM raw disk but have so far not been able to find all the steps/pieces to make it actually work. I can get the LVM filesystem down to the desired size, but getting the actual raw disk file to shrink results in not being able to boot.
Here are the steps taken with what I have been able to find here and on google.
A screen shot of the df before:
(Steps 1-3 taken below from https://www.rootusers.com/lvm-resize-how-to-decrease-an-lvm-partition/)
1. Boot w/ live cd (I used Knoppix Live).
2. To shrink the root volume issued the following commands:
3. Reboot to confirm size, screen shot of the df after:
4. Next, and this is the part that causes it to not boot, resize the raw disk:
(taken from https://forum.proxmox.com/threads/resize-vm-hdd-to-800gb-and-my-real-hdd-has-only-80gb.24203/ and https://forum.proxmox.com/threads/shrink-disk-size.24808/)
How do I properly shrink the physical raw disk?
Here are the steps taken with what I have been able to find here and on google.
A screen shot of the df before:
(Steps 1-3 taken below from https://www.rootusers.com/lvm-resize-how-to-decrease-an-lvm-partition/)
1. Boot w/ live cd (I used Knoppix Live).
2. To shrink the root volume issued the following commands:
Code:
#Pick up the volumes:
vgchange -a y
# File system check:
e2fsck -fy /dev/mapper/vg_mtdemo-lv_root
# Shrink the filesystem:
resize2fs /dev/mapper/vg_mtdemo-lv_root 15G
# Shrink the logical volume - 1GB bigger just in case
lvreduce -L 16G /dev/mapper/vg_mtdemo-lv_root
# Extend the filesystem:
resize2fs /dev/mapper/vg_mtdemo-lv_root
4. Next, and this is the part that causes it to not boot, resize the raw disk:
Code:
# Resize to 22G just in case (root plus swap are about 20G)
qemu-img resize -f raw vm-102-disk-1.raw 22G
How do I properly shrink the physical raw disk?