[wplug] Zeroing out a swap partition

Pat Barron pat at lectroid.com
Thu Jul 21 11:47:31 EDT 2016


Can anyone suggest an "easy" way to zero out the contents of a swap 
partition, without affecting the "formatting" of the partition?  (On 
RHEL / CentOS / Fedora, if that matters....)

I tried the "obvious" suggestion of "scrub -p zerofill 
/dev/<partition>", and that worked, as far as it went.  But then the 
system no longer "recognized" it as a swap partition.  So to solve that, 
I ran "mkswap" on the partition, and that too worked - but that changed 
the UUID of the partition, and it no longer matched what was in 
/etc/fstab, so the system didn't activate the swap partition on boot.  I 
fixed that by changing the UUID in /etc/fstab, and it all works now - 
but it's sort of a pain.

Is there a less complicated way to do this, or is this pretty much it?

(The reason I want to do this in the first place is that this is 
actually a VM, and I want to zero out all unallocated / unused space on 
the virtual disk so the VM's hard drive image compresses better, for 
purposes of sending it over the network to someone else....)

Thanks,
--Pat.



More information about the wplug mailing list