How to wipe a signature from a disk device on Linux with wipefs command

I recently decommissioned Debian Linux based nas server and moved disk from my nas server to Linux-powered desktop. However, when I run fdisk command, I am getting the following error:
    /dev/sdb: device contains a valid ‘LVM2_member’ signature; it is strongly recommended to wipe the device with wipefs(8) if this is unexpected, in order to avoid possible collisions
What is a wipefs and how do I use it on Linux?

Each disk and partition has some sort of signature and metadata/magic strings on it. The metadata used by operating system to configure disks or attach drivers and mount disks on your system. You can view such partition-table signatures/metadata/magic strings using the wipefs command. The same command can erase filesystem, raid or partition-table signatures/metadata.

Display or show current signatures

Type the following command:
$ sudo wipefs /dev/sda
$ sudo wipefs /dev/sda1
Sample outputs:

Fig.01: Display current disk or partition signatures or magic strings

Be Careful: With just a few keystrokes, wipefs can wipe out part or all of your hard disk signature or working partition. Make sure you use correct device names with the wipefs command.

How do I erase current signatures from /dev/vdb?

The syntax is
$ sudo wipefs --all --force /dev/vdb
You can create a signature backup to the file $HOME/wipefs-{devname}-{offset}.bak:
$ sudo wipefs --all --force --backup /dev/vdb
Sample outputs:

/dev/vdb: 8 bytes were erased at offset 0x00000218 (LVM2_member): 4c 56 4d 32 20 30 30 31

Restores an ext2 signature from the backup file ~/wipefs-sdb-0x00000438.bak

You will also find a signature backup file with the following ls command:
$ sudo ls -l ~/wipefs-*.bak
Sample outputs:

-rw------- 1 root root 8 Feb 27 18:54 /root/wipefs-vdb-0x00000218.bak

To restore, run:
$ sudo dd if=~/wipefs-vdb-0x00000218.bak of=/dev/vdb seek=$((0x00000218)) bs=1 conv=notrunc
Sample outputs:

8+0 records in
8+0 records out
8 bytes copied, 0.00404186 s, 2.0 kB/s

Wiping the entire disk using dd command

You can also use the dd commandt o wipe out a signature from a disk device using the following syntax. The dd command works on Linux, FreeBSD, MacOS and Unix-like operating system. The syntax is:
$ sudo dd if=/dev/zero of=/dev/vdb bs=1M
Sample outputs:

4806672384 bytes (4.8 GB, 4.5 GiB) copied, 18.0002 s, 267 MB/s
dd: error writing '/dev/vdb': No space left on device
5121+0 records in
5120+0 records out
5368709120 bytes (5.4 GB, 5.0 GiB) copied, 18.5783 s, 289 MB/s

OR do secure erase with dd command showing progress bar:
$ sudo dd if=/dev/urandom of=/dev/vdb bs=1M status=progress
Sample outputs:

5348786176 bytes (5.3 GB, 5.0 GiB) copied, 249.005 s, 21.5 MB/s 
dd: error writing '/dev/vdb': No space left on device
5121+0 records in
5120+0 records out
5368709120 bytes (5.4 GB, 5.0 GiB) copied, 250.069 s, 21.5 MB/s

To wipe out just partitions:
$ sudo if=/dev/zero of=/dev/vdb1 bs=1M
To wipe out just the Master boot record (MBR), run:
$ sudo d if=/dev/zero of=/dev/vdb bs=446 count=1

See also

Posted by: SXI ADMIN

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.


Start your Bitcoin Exchange with our Software

Start your Bitcoin Exchange with our Software Setup your white label bitcoin exchange right away. Or create your own cryptocurrency using...

How to KVM, QEMU start or stop virtual machine from command line (CLI)

KVM or Kernel Based Virtual Machine is a popular virtualization technology. It allows you to run virtual guest machines over a host machine. To start...

How to Docker backup Saving and restoring your volumes

Running a Docker volume backup First, we spin up a temporary container, and we mount the backup folder and the target Docker volume to this container....