Dan Craciun
asked on
Compact Linux guest virtual hard disk
Hi,
The situation: Windows Server 2012 Hyper-V host, with mixed CentOS 6.4 and Server 2012 guests.
What I'm trying to do: compact the virtual image of a CentOS VM, named XXX, with a vhdx of 43GB.
What I did:
Shut down the VM, booted SystemRescueCD 3.8.1.
Used pvscan to get logical volume information.
Changed /dev/mapper/vg_XXX-lv-root to active:
vgchange /dev/mapper/vg_XXX-lv-root -a y
Ran zerofill -v /dev/mapper/vg_XXX-lv-root
Ran zerofill -v /dev/mapper/vg_XXX-lv-home
Both successful.
Shut down the VM, then tried to compact it using Hyper-V Manager. No effect whatsoever. The vhdx is still at 43GB.
Any ideas what I did wrong and/or how I can successfully compact that VM?
Thanks.
Below you have the disk space usage, as reported by df -h. As you can see, the real space usage is at around 11GB.
The situation: Windows Server 2012 Hyper-V host, with mixed CentOS 6.4 and Server 2012 guests.
What I'm trying to do: compact the virtual image of a CentOS VM, named XXX, with a vhdx of 43GB.
What I did:
Shut down the VM, booted SystemRescueCD 3.8.1.
Used pvscan to get logical volume information.
Changed /dev/mapper/vg_XXX-lv-root
vgchange /dev/mapper/vg_XXX-lv-root
Ran zerofill -v /dev/mapper/vg_XXX-lv-root
Ran zerofill -v /dev/mapper/vg_XXX-lv-home
Both successful.
Shut down the VM, then tried to compact it using Hyper-V Manager. No effect whatsoever. The vhdx is still at 43GB.
Any ideas what I did wrong and/or how I can successfully compact that VM?
Thanks.
Below you have the disk space usage, as reported by df -h. As you can see, the real space usage is at around 11GB.
ASKER
Thank you for your reply.
Tried your commands. Still no effect after compact.
Which is strange. Creating the zero.out file should have increased the vhdx size, but that did not happen...
Tried your commands. Still no effect after compact.
Which is strange. Creating the zero.out file should have increased the vhdx size, but that did not happen...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Good to know! Are you running 2012 R2? May be this is the reason I couldn't reproduce this in my lab.
ASKER
Nope. Plain 2012. Will upgrade probably in March-June. Don't like being an early adopter\beta tester on production servers.
A tricky one to be sure. Still don't know why -Mode Quick did not work.
I even spent about 2 hours in a hex viewer, mapping the vhdx. I could see where the partitions ended, huge 0 filled blocks and some 11 GB of pure 0's at the end of the file, and still compact did not work.
Weird, but at least I found a solution.
A tricky one to be sure. Still don't know why -Mode Quick did not work.
I even spent about 2 hours in a hex viewer, mapping the vhdx. I could see where the partitions ended, huge 0 filled blocks and some 11 GB of pure 0's at the end of the file, and still compact did not work.
Weird, but at least I found a solution.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Had to do a lot of research to get around what I can only call "a bug" in Hyper-V compacting routines.
Thanks Mazdajai. Will try in R2 to see if the problem is solved.
Thanks Mazdajai. Will try in R2 to see if the problem is solved.
Open in new window