wipefs

Wipe filesystem signatures from a device

Syntax: wipefs [options] device
Warning: wipefs can permanently destroy data. Always ensure you have backups and are working on the correct device before using this command.

Description

wipefs is used to erase filesystem, raid, or partition-table signatures (magic strings) from the specified device to make the signatures invisible for libblkid. It does not erase the filesystem itself or any other data from the device. When used without any options, wipefs lists all visible filesystems and the offsets of their basic signatures.

Command Options

Option Description
-a, --all Erase all available signatures
-b, --backup Create signature backup to $HOME/wipefs-<devname>-<offset>.bak
-f, --force Force erasure, even if filesystem is mounted
-n, --no-act Do everything except the actual write
-o, --offset <num> Specify the location of the signature
-p, --parsable Print parsable output
-q, --quiet Suppress output messages
-t, --types <list> Limit the set of filesystem types

Basic Usage

List filesystem signatures:
# Show all signatures on a device
wipefs /dev/sdb1

# Show signatures on multiple devices
wipefs /dev/sdb1 /dev/sdc1

# Parsable output for scripts
wipefs -p /dev/sdb1

Wiping Signatures

Erase all signatures:
# Wipe all signatures from device
wipefs -a /dev/sdb1

# Dry run - show what would be wiped
wipefs -n -a /dev/sdb1

# Force wipe even if mounted (dangerous)
wipefs -f -a /dev/sdb1
Selective signature removal:
# Wipe only specific filesystem types
wipefs -t ext4,xfs /dev/sdb1

# Wipe signature at specific offset
wipefs -o 0x1fe /dev/sdb1

# Wipe with backup
wipefs -b -a /dev/sdb1

Common Filesystem Signatures

Filesystem Signature Location Magic Bytes
ext2/3/4 0x438 0x53EF
XFS 0x0 XFSB
Btrfs 0x10040 _BHRfS_M
NTFS 0x3 NTFS
FAT32 0x52 FAT32

Practical Examples

Preparing disk for reuse:
# Check what's on the disk
wipefs /dev/sdb

# Sample output:
# DEVICE OFFSET TYPE UUID LABEL
# /dev/sdb 0x1fe dos
# /dev/sdb1 0x438 ext4 abc123... mydata

# Wipe all signatures
wipefs -a /dev/sdb

# Verify it's clean
wipefs /dev/sdb
Safe wiping with backup:
# Create backup before wiping
wipefs -b -a /dev/sdb1

# Backup files are created in home directory
# Example: ~/wipefs-sdb1-1080.bak

# If needed, restore from backup
dd if=~/wipefs-sdb1-1080.bak of=/dev/sdb1 bs=1 seek=1080

Working with RAID and LVM

Clean RAID signatures:
# Check for RAID signatures
wipefs /dev/sdb

# Remove RAID metadata
wipefs -a /dev/sdb

# For software RAID, also clean superblocks
mdadm --zero-superblock /dev/sdb
Clean LVM signatures:
# Remove LVM physical volume signature
wipefs -a /dev/sdb1

# Alternative using LVM tools
pvremove /dev/sdb1

Scripting with wipefs

Automated disk preparation:
#!/bin/bash

device="/dev/sdb"

# Check if device exists
if [ ! -b "$device" ]; then
    echo "Device $device not found"
    exit 1
fi

# Show current signatures
echo "Current signatures on $device:"
wipefs "$device"

# Confirm before wiping
read -p "Wipe all signatures? (y/N): " confirm
if [ "$confirm" = "y" ]; then
    wipefs -a "$device"
    echo "Signatures wiped from $device"
else
    echo "Operation cancelled"
fi

Integration with Other Tools

Complete disk preparation workflow:
# 1. Unmount if mounted
umount /dev/sdb1 2>/dev/null

# 2. Check current state
lsblk /dev/sdb
wipefs /dev/sdb

# 3. Wipe signatures
wipefs -a /dev/sdb

# 4. Create new partition table
parted /dev/sdb mklabel gpt

# 5. Create new partition
parted /dev/sdb mkpart primary ext4 1MiB 100%

# 6. Create new filesystem
mkfs.ext4 /dev/sdb1

Troubleshooting

Common issues and solutions:
# Device busy error
# Solution: Unmount and stop using processes
umount /dev/sdb1
fuser -km /dev/sdb1

# Permission denied
# Solution: Run as root or with sudo
sudo wipefs -a /dev/sdb1

# Signature not found
# Solution: Check device path and permissions
ls -l /dev/sdb1
wipefs -p /dev/sdb1

Recovery Operations

Restore from backup:
# List available backups
ls -la ~/wipefs-*

# Restore specific signature
# Format: wipefs--.bak
dd if=~/wipefs-sdb1-1080.bak of=/dev/sdb1 bs=1 seek=1080

# Verify restoration
wipefs /dev/sdb1

Security Considerations

Secure data removal:
# wipefs only removes signatures, not data
# For secure data removal, use additional tools

# Overwrite entire device with random data
dd if=/dev/urandom of=/dev/sdb bs=1M

# Or use shred
shred -vfz -n 3 /dev/sdb

# Then wipe signatures
wipefs -a /dev/sdb

Best Practices

  • Always backup: Use -b option to create signature backups
  • Verify device: Double-check device names before wiping
  • Unmount first: Unmount filesystems before wiping
  • Test with -n: Use dry-run mode to preview changes
  • Check dependencies: Ensure no RAID/LVM dependencies exist
  • Document changes: Keep records of wiped devices
  • Use appropriate tools: Consider filesystem-specific tools when available
  • Verify results: Check that signatures are actually removed

Common Use Cases

  • Disk preparation: Preparing disks for new filesystems
  • RAID cleanup: Removing old RAID signatures
  • LVM management: Cleaning LVM physical volumes
  • System migration: Preparing disks for new systems
  • Troubleshooting: Resolving filesystem detection issues
  • Security: Preventing accidental data access
  • Automation: Scripted disk preparation workflows
  • Recovery: Fixing corrupted partition tables

Alternatives and Related Commands

Similar functionality:
# Zero out partition table
dd if=/dev/zero of=/dev/sdb bs=512 count=1

# GNU parted
parted /dev/sdb mklabel gpt

# Secure erase
hdparm --user-master u --security-set-pass p /dev/sdb
hdparm --user-master u --security-erase p /dev/sdb

# RAID specific
mdadm --zero-superblock /dev/sdb
Related Commands: blkid, lsblk, parted, dd, mkfs