Backup Size

adamb

Famous Member
Mar 1, 2012
1,329
77
113
I have noticed that if I move a ton of data to a VM, remove it, then backup the VM, that the backup size pretty much increases to the size before I removed the data. I am guessing this is due to the data being placed at random locations on the disk. What is the best way to get this back under control. The VM is a CentOS5 box, I am thinking dd should be able to do it, not completely sure though.
 
dd if=/dev/zero of=zero.small.file bs=1024 count=102400
dd if=/dev/zero of=zero.file bs=1024
rm zero.small.file
sync ; sleep 60 ; sync
rm zero.file

why use two dd command ?
the second "dd if=/dev/zero of=zero.file bs=1024" is for what ?
 
The first one is just to create a relatively small file, the other is to fill the entire disk.
If you skip the first command, and you have a huge disk, when there is no more space and you remove the file it takes a lot, so your system would have "no more space available" for a lot of time.
With the trick of creating 2 files, you remove the first that does not take much time, and so your system has very quick free space available, and then remove the big file.
 
I guess you could observe if the backup size increases and the disk usage inside the VM doesn't then you could zero again..