Shrinking filesystem causes corruption

Fuggschen

New Member
Jan 16, 2023
11
1
3
Germany
krk-gaming.de
Hello,

I have a VM with too much space allocated and am trying to shrink it's disk from 200G to 100G.
Filesystem of VM is BTRFS and of Proxmox ZFS.

Steps I've done:
1) Boot into gparted and resize the btrfs partition from almost 200G to 95G (used partition space does not exceed 100G)
2) Shutdown VM
3) In proxmox shell: zfs set volsize=100G data/vm-101-disk-0 and qm rescan
4) Boot VM
VM boots with filesystem corruption error and dumps me into initramfs.

Can I shrink a BTRFS filesystem this way? I tried to google it and it worked for everyone else. They say to leave some space at the end of the disk (as I did) to avoid corruption, but it doesn't help.
What do I have to do to make it work?
 
Never did a shrink. Experience with btrfs: 0

But when I increase a disk I also adjust the information in the VM config file to match reality.

Also try a different version of gparted. Maybe your issue lies there.
Once I got an issue where I wasn't able to do what I wanted for some incompatible version/package that was used. Another version fixed that.

Remember: especially in virtualization it is always a good thing to size to lower limit.
 
But when I increase a disk I also adjust the information in the VM config file to match reality.
Thats what qm rescan does. Proxmox shows the new size correctly in the interface.
Also try a different version of gparted. Maybe your issue lies there.
Thougt the same. Had firstly used an old ISO and also tried with a new one. BTRFS support is present in both and shrinking works without problems.
Remember: especially in virtualization it is always a good thing to size to lower limit.
Yeah. Had to learn the hard way now. Backup Server is out of storage ans new backups fail. Forgot that VM disks are a 1:1 backup and not like container backups with deduplication.
 
Be aware of the 8% difference between GiB and GB. There might also be other partitions on that virtual disk like a 512MiB ESP. I suggest keeping a larger safe space than 5GB.
Gparted will always complain afterwards that the backup GPT (or MBR) are invalid at the end of the disk, which it normal. What kind of corruption are you seeing?

EDIT: Some tools use GB for GiB, so it's not always clear. I suggest using a larger margin for numeric errors.
 
Last edited:
Gparted will always complain afterwards that the backup GPT (or MBR) are invalid at the end of the disk, which it normal. What kind of corruption are you seeing?
So.. gparted just shrinks fine. No complains afterwards. Shows the new Filesystem and over a 100GB empty space. After shrinking the disk and booting, the OS shows "no filesystem found" with some other Text that it tried to find it and dumps me into initramfs.
Gparted then shows the boot partition and one unknown partition.
Be aware of the 8% difference between GiB and GB. There might also be other partitions on that virtual disk like a 512MiB ESP. I suggest keeping a larger safe space than 5GB.
GiB and GB.. but everything is in GB. gparted shows GB, the zfs resize command uses GB.. shouldn't it just be GB and not GiB? But will try this later.

Little Note: VM is running Ubuntu 22.04 if that can help someone
 
Okay. Gparted shows the sizes in GiB. Must have overlooked this the whole time. BUT zfs resize also works with GiB because gparted lists this disk as an 100GiB disk after resize.

So I tried with 90GiB instead of 95GiB but still the same issue. Can't go lower because I will hit the data.

Also have to correct that this is a ext4 filesystem and not BTRFS.. was confused because the error message in the VM says something with "Trying to mount BTRFS" (can't remember the whole line and didn't reproduced it).


Any other ideas? Can try to shrink it only to 150G but I think it won't change anything (but I still test this now).


UPDATE: Tested it with making the partition to 90GiB and shrinking the disk to 180G. Still corrupted :/
 
Last edited:
Okay so I took my datashovel and made some space. Created now a new smaller disk and used clonezilla to move the data.
Everythink works and seems to be the best solution if you have the extra space.

I'm happy to test if someone has any idea how to initially fix my issue.
 
  • Like
Reactions: leesteken

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!