Using wipefs to remove signatures and metadata from hard drives.

Wipefs is a great tool for removing signatures and metadata from used hard drives that have been previously partitioned and formatted.

Removing metadata and signatures from previously used hard drives is important to ensure that when they are reused in a new system, they do not contain information that could interfere with the installation of an operating system and underlying file system and cause the process to fail.

To display the current signatures on a hard disk run the following command :

# wipefs /dev/sda

Or for a particular partition.

# wipefs /dev/sda1
DEVICE OFFSET TYPE UUID LABEL
sda    0x1fe  dos

Since wipefs does not work recursively running the command on an entire block device (e.g., /dev/sda), will not show the signatures of every partition on the device. For this we need to add an asterisk at the end of the device name as a wildcard.

# wipefs /dev/sda*
DEVICE OFFSET TYPE UUID                                 LABEL
sda    0x1fe  dos
sda1   0x438  ext3 c6f21ee2-ca37-43b8-99f3-8d3a7cd81b2a

To wipe the disk /dev/sda run the following command :

# wipefs -a -f /dev/sda

Note that “-a” and “-f” are the short versions of the “–all” and “–force” options, respectively.

You might want to create a back-up in case something goes wrong and you need to perform a restore. This can be done adding the “–backup” option or in short “-b”.

# wipefs -a -f -b /dev/sda

To restore first find the relevant back-up file.

# ls -l ~/wipefs-*.bak 
-rw------- 1 root root 8 Feb 27 18:54 /root/wipefs-sda-0x00000218.bak

And restore using the “dd” command.

# dd if=~/wipefs-vdb-0x00000218.bak of=/dev/sda seek=$((0x00000218)) bs=1 conv=notrunc 

If you want to remove the signatures and metadata of not just the entire block device but also the created partitions at once, you can do so by simply adding an asterisk to the device name.

# wipefs -a -f /dev/sda*

To remove only a specific signature you could use the “–offset” option or in short “-o”.

# wipefs -o 0x1fe /dev/sda

Same can be achieved using the “–type” option or in short “-t” .

# wipefs -a -t dos /dev/sda

Since wipefs does not erase the filesystem itself nor any other data from the device you will need to do this separately which is particularly of importance if you sell your hardware. Completely erasing all data on your entire hard disk can be achieved by overwriting all sectors with zero’s using the “cat” command

# cat /dev/zero >/dev/sda

It is important to repeat this command a few times to ensure all data is erased.

If you really want to wipe-out everything on your disk you might want to consider using a utility called DBan.