Shrink guest on hosted platform: Difference between revisions
Jump to navigation
Jump to search
Line 33: | Line 33: | ||
cat /dev/zero > /home/zero.fill;sync;sleep 1;sync;rm -f /home/zero.fill | cat /dev/zero > /home/zero.fill;sync;sleep 1;sync;rm -f /home/zero.fill | ||
===== Zero out a part of your disk ===== | |||
If your machine cannot be taken down and you do not want to shut down services that might end up corrupting files because of the "No space left on the device" problem then an idea that might work is to zero out a part of your partition. | |||
This for example creates a 100MB size file filled with zero's | |||
# dd if=/dev/zero of=zero.fill bs=1024 count=102400 | |||
102400+0 records in | |||
102400+0 records out | |||
104857600 bytes (105 MB) copied, 0.3839 s, 273 MB/s | |||
So if you want to zero out 10GB instead, add two more zero's to the count parameter, eg: count=10240000 | |||
If you want to fill up in steps, just change the output file name from "zero.fill" into "zero.fill2" etcetera.. | |||
Then run the "sync; sleep 1; sync" from above and remove the zero.fill files. | |||
If this is a vSphere VM you can then migrate the VM to NFS storage and back and the zero'd out data has been reclaimed. | |||
==== Zero out unused space on a Windows VM ==== | ==== Zero out unused space on a Windows VM ==== |