How to use the command "wipefs" (with examples)

How to use the command "wipefs" (with examples)

The wipefs command is used to wipe filesystem, raid, or partition-table signatures from a device. It can be used to remove any existing signatures or metadata on a device, which can be useful when preparing a device for a fresh installation or when encountering issues with existing signatures.

Use case 1: Display signatures for specified device

Code:

sudo wipefs /dev/sdX

Motivation: This use case is useful for quickly identifying if there are any existing signatures on a specific device. It allows you to check if a device has been previously used or contains any metadata that may interfere with the desired operation.

Explanation: The command sudo wipefs is used to wipe filesystem, raid, or partition-table signatures. The argument /dev/sdX specifies the device you want to check for signatures. Replace “sdX” with the appropriate device identifier.

Example output:

DEVICE                     OFFSET      TYPE              UUID                                LABEL
/dev/sdb1                   0x1fe       msdos                                                  
/dev/sdb2                   0x200       vfat             D115-475C                             NO_LABEL
/dev/sdb3                  0x7c00       msdos                                                  
/dev/sdb4                      0          isw_raid_member                                      
/dev/sdb5                      0          isw_raid_member                                      

Use case 2: Wipe all available signature types for a specific device with no recursion into partitions

Code:

sudo wipefs --all /dev/sdX

Motivation: This use case is helpful when you want to wipe all available signature types from a device without affecting any partitions on that device. It ensures that the device is clean and free from any metadata or signatures that may cause conflicts.

Explanation: The --all argument instructs the wipefs command to wipe all available signature types. The argument /dev/sdX specifies the device you want to wipe the signatures from. Replace “sdX” with the appropriate device identifier.

Example output:

/dev/sdX: 8 bytes were erased at offset 0x000001fe (dos): 55 aa 99 f2 .. .. .. ..
/dev/sdX: 512 bytes were erased at offset 0x000003e7 (dos): 09 e0 b6 4f .. .. .. ..
/dev/sdX: calling ioctl to re-read partition table: Success

Use case 3: Wipe all available signature types for the device and partitions using a glob pattern

Code:

sudo wipefs --all /dev/sdX*

Motivation: This use case is useful when you want to wipe all available signature types from both the device and its partitions. It ensures that the entire device and its associated partitions are clean and free from any metadata or signatures.

Explanation: The --all argument instructs the wipefs command to wipe all available signature types. The argument /dev/sdX* uses a glob pattern to specify the device and its partitions. Replace “sdX” with the appropriate device identifier.

Example output:

/dev/sdX: 8 bytes were erased at offset 0x000001fe (dos): 55 aa 99 f2 .. .. .. ..
/dev/sdX: 512 bytes were erased at offset 0x000003e7 (dos): 09 e0 b6 4f .. .. .. ..
/dev/sdX: calling ioctl to re-read partition table: Success
/dev/sdX1: 8 bytes were erased at offset 0x000001fe (dos): 55 aa 99 f2 .. .. .. ..
/dev/sdX1: calling ioctl to re-read partition table: Success

Use case 4: Perform dry run

Code:

sudo wipefs --all --no-act /dev/sdX

Motivation: This use case allows you to simulate the wiping process without actually modifying any signatures or metadata on the device. It provides a risk-free way of testing the command and understanding what changes would be made.

Explanation: The --all argument instructs the wipefs command to wipe all available signature types. The --no-act option is used to perform a dry run, meaning no changes will be made to the device. The argument /dev/sdX specifies the device you want to perform the dry run on. Replace “sdX” with the appropriate device identifier.

Example output:

/dev/sdX: 8 bytes were erased at offset 0x000001fe (dos): 55 aa 99 f2 .. .. .. ..
/dev/sdX: 512 bytes were erased at offset 0x000003e7 (dos): 09 e0 b6 4f .. .. .. ..

Use case 5: Force wipe, even if the filesystem is mounted

Code:

sudo wipefs --all --force /dev/sdX

Motivation: This use case is helpful when you want to forcefully wipe all signatures on a device, even if the filesystem is mounted. It overrides any safety checks that prevent modifying mounted filesystems, allowing you to clean the device regardless of its current state.

Explanation: The --all argument instructs the wipefs command to wipe all available signature types. The --force option is used to force the wipe, even if the filesystem is mounted. The argument /dev/sdX specifies the device you want to wipe the signatures from. Replace “sdX” with the appropriate device identifier.

Example output:

/dev/sdX: 8 bytes were erased at offset 0x000001fe (dos): 55 aa 99 f2 .. .. .. ..
/dev/sdX: 512 bytes were erased at offset 0x000003e7 (dos): 09 e0 b6 4f .. .. .. ..
/dev/sdX: calling ioctl to re-read partition table: Success

Conclusion:

The wipefs command is a versatile tool for wiping filesystem, raid, or partition-table signatures from a device. It allows you to remove existing signatures, ensuring a clean state for fresh installations or troubleshooting purposes. The different use cases illustrated above demonstrate the various scenarios in which wipefs can be utilized, including displaying signatures, wiping all signature types, performing dry runs, and force wiping despite mounted filesystems.

Related Posts

How to use the command partprobe (with examples)

How to use the command partprobe (with examples)

Partprobe is a command that allows the user to notify the operating system kernel of partition table changes.

Read More
aapt Examples (with examples)

aapt Examples (with examples)

Use Case 1: List files contained in an APK archive Code: aapt list path/to/app.

Read More
How to use the command 'lex' (with examples)

How to use the command 'lex' (with examples)

The ’lex’ command is a lexical analyzer generator that generates C code from a given specification for a lexical analyzer.

Read More