Incomplete info for shrinking raw disk

stra4d

Well-Known Member
Mar 1, 2012
80
0
46
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:
df_before.JPG

(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
3. Reboot to confirm size, screen shot of the df after:
df_after.JPG
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
(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?
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!