Shrink guest on hosted platform: Difference between revisions

m
Line 15: Line 15:
  yum clean
  yum clean


Next, reboot your VM from a live CD and mount the file systems.
Next, shut down any services that depend on enough available disk space to run.


The reason we are doing this from a live CD is that we are going to write out zero's to the file system and we do not want any application - for example a database system like mySQL or postgreSQL - to run out of disk space while we are zeroing out the file system. If mySQL would try to write when your disk is full you risk a corrupted database. So this "reboot from a live CD" step is important!
The reason we are doing this is that we are going to write out zero's to the file system until the file system is full and we do not want any application - for example a database system like mySQL or postgreSQL - to run out of disk space while we are zeroing out the file system. If mySQL would try to write when your disk is full you risk a corrupted database. So this step is important!
 
from your live CD, check out the filesystem of your VM, for example:
 
fdisk -l
will show you:


Next run:


  cat /dev/zero > zero.fill;sync;sleep 1;sync;rm -f zero.fill
  cat /dev/zero > zero.fill;sync;sleep 1;sync;rm -f zero.fill
Line 29: Line 25:
to fill the unused space with zeros.
to fill the unused space with zeros.


As this command writes out zero's to the disk until it runs out of disk space, you will get an error "No space left on the device". This is expected and is also why we suggest to do this from a Live CD.
As this command writes out zero's to the disk until it runs out of disk space, you will get an error "No space left on the device". This is expected.
 
If you do not have a Live CD, then you can run the command to zero out the unused space as root, but remember to shut down services like databases first.


==== Zero out unused space on a Windows VM ====
==== Zero out unused space on a Windows VM ====
1,274

edits