dotlinux blog

Wipefs Linux Command Tutorial with Examples

In the realm of Linux system administration, managing storage devices and filesystems is a common task. Whether you’re repurposing a disk, troubleshooting filesystem recognition issues, or preparing a drive for a new setup, you may encounter situations where you need to remove existing filesystem signatures from a storage device. This is where the wipefs command comes into play.

wipefs is a powerful utility designed to erase filesystem signatures (also called "magic strings") from a device or partition. These signatures are small pieces of data stored at specific offsets on the disk that help the operating system identify the filesystem type (e.g., ext4, NTFS, FAT32). By removing these signatures, wipefs makes the filesystem unrecognizable to the OS, allowing you to reformat the device or resolve conflicts caused by leftover signatures.

Important Note: wipefs does not securely erase data or wipe the entire disk. It only removes the metadata (signatures) that identify the filesystem. If you need to permanently delete data, use tools like shred or dd.

2026-01

Table of Contents#

  1. What is wipefs?
  2. Installation
  3. Basic Syntax
  4. Key Options
  5. Practical Examples
  6. Safety Considerations
  7. Conclusion
  8. References

What is wipefs?#

wipefs is part of the util-linux package, a collection of essential Linux utilities. Its primary function is to list or remove filesystem signatures from a storage device (e.g., hard drives, SSDs, USB drives) or partition.

Filesystem signatures are stored at specific offsets (locations) on the disk. For example:

  • ext4 signatures are often at offset 0x8000 (32768 bytes).
  • NTFS signatures are typically at offset 0x0 (the first sector).

When you run wipefs, it scans the device for these signatures and can either display them (with -i) or erase them (with -a or specific offsets). This is useful in scenarios like:

  • Reusing a disk that previously had multiple conflicting filesystems.
  • Fixing errors where the OS misidentifies a filesystem due to leftover signatures.
  • Preparing a device for a new filesystem without full reformatting.

Installation#

wipefs is pre-installed on most Linux distributions as part of the util-linux package. To verify if it’s installed, run:

wipefs --version

If missing, install util-linux using your distribution’s package manager:

  • Debian/Ubuntu:

    sudo apt update && sudo apt install util-linux
  • RHEL/CentOS:

    sudo yum install util-linux
  • Fedora:

    sudo dnf install util-linux
  • Arch Linux:

    sudo pacman -S util-linux

Basic Syntax#

The general syntax for wipefs is:

wipefs [options] <device>
  • <device>: The path to the storage device or partition (e.g., /dev/sda, /dev/sdb1, /dev/nvme0n1p2).
  • [options]: Flags to control behavior (see Key Options).

Key Options#

wipefs offers several options to customize its behavior. Here are the most useful ones:

OptionDescription
-a, --allErase all detected filesystem signatures from the device.
-f, --forceForce erase, even if the device is mounted (dangerous! Avoid using on mounted devices).
-i, --infoDisplay detailed information about detected signatures (does not erase anything).
-n, --dry-runSimulate the erase operation (shows what would be done without making changes).
-o, --offset <num>Erase the signature at a specific offset (in bytes). Use with --force if needed.
-t, --type <type>Target only signatures of a specific filesystem type (e.g., ext4, ntfs).
-v, --verboseEnable verbose output (shows detailed steps).

Practical Examples#

Let’s walk through common use cases with wipefs. Always back up data before modifying storage devices!

Example 1: List Signatures on a Device#

To view all filesystem signatures on a device (e.g., /dev/sdb1), use the -i (info) flag:

sudo wipefs -i /dev/sdb1

Sample Output:

DEVICE: /dev/sdb1
offset               type
----------------------------------------------------------------
0x0000000000000000   ntfs   [filesystem]
0x0000000000000400   ntfs   [filesystem]
0x0000000000008000   ext4   [filesystem]

This output shows:

  • The device path (/dev/sdb1).
  • Offsets (in hex) where signatures are found.
  • Filesystem types (ntfs, ext4).

Example 2: Dry Run Before Erasing#

Before making changes, use -n (dry run) to preview what wipefs would erase. For example, to simulate erasing all signatures on /dev/sdb1:

sudo wipefs -n -a /dev/sdb1

Sample Output:

/dev/sdb1: 8 bytes were erased at offset 0x0000000000000000 (ntfs): 4e54465320202020
/dev/sdb1: 8 bytes were erased at offset 0x0000000000000400 (ntfs): 4e54465320202020
/dev/sdb1: 8 bytes were erased at offset 0x0000000000008000 (ext4): 53ef

The dry run message confirms no actual changes were made. The hex strings (e.g., 4e544653...) are the signature bytes that would be overwritten (with zeros).

Example 3: Erase All Signatures#

To permanently erase all detected signatures on /dev/sdb1, use -a (all) with -v (verbose) for clarity:

sudo wipefs -v -a /dev/sdb1

Sample Output:

/dev/sdb1: 8 bytes were erased at offset 0x0000000000000000 (ntfs): 4e54465320202020
/dev/sdb1: 8 bytes were erased at offset 0x0000000000000400 (ntfs): 4e54465320202020
/dev/sdb1: 8 bytes were erased at offset 0x0000000000008000 (ext4): 53ef

Now, the OS will no longer recognize ext4 or ntfs on /dev/sdb1 until a new filesystem is created.

Example 4: Erase a Specific Signature#

If you only want to remove a single signature (e.g., the ext4 signature at offset 0x8000), use -o (offset):

sudo wipefs -v -o 0x8000 /dev/sdb1

Sample Output:

/dev/sdb1: 8 bytes were erased at offset 0x0000000000008000 (ext4): 53ef

This leaves other signatures (e.g., ntfs) intact.

Example 5: Erase Signatures of a Specific Filesystem Type#

Use -t (type) to target signatures of a particular filesystem. For example, erase only ntfs signatures on /dev/sdb1:

sudo wipefs -v -t ntfs /dev/sdb1

Sample Output:

/dev/sdb1: 8 bytes were erased at offset 0x0000000000000000 (ntfs): 4e54465320202020
/dev/sdb1: 8 bytes were erased at offset 0x0000000000000400 (ntfs): 4e54465320202020

Example 6: Wipe Signatures on a Whole Disk#

To wipe signatures from an entire disk (e.g., /dev/sdc, not just a partition), use:

sudo wipefs -v -a /dev/sdc

Warning: This affects the entire disk, including partition tables (e.g., MBR/GPT). Use only if you want to reset the disk to a "blank" state.

Safety Considerations#

wipefs is a powerful tool, but misuse can lead to permanent data loss. Follow these rules to stay safe:

  1. Double-Check the Device Path: Always verify the target device with lsblk or fdisk -l before running wipefs. For example:

    lsblk /dev/sdb  # Confirm this is the USB drive, not your main disk!
  2. Unmount the Device First: Never run wipefs on a mounted filesystem. Unmount it with:

    sudo umount /dev/sdb1
  3. Use Dry Run (-n) First: Always simulate the operation with -n to ensure you’re targeting the correct signatures.

  4. Avoid -f (Force): The -f flag allows erasing mounted devices, but this can corrupt data or crash the system. Only use it as a last resort.

  5. Back Up Data: If the device contains important data, back it up before using wipefs.

Conclusion#

The wipefs command is a versatile utility for managing filesystem signatures on Linux. It helps resolve recognition issues, repurpose storage devices, and prepare disks for new filesystems—all without fully erasing data. By mastering its options (like -i for info, -n for dry runs, and -a for erasing all signatures) and following safety best practices, you can use wipefs effectively while avoiding accidental data loss.

Remember: wipefs is for signature removal, not secure data deletion. For permanent data erasure, use tools like shred or dd if=/dev/zero of=/dev/sdX.

References#