July 23, 2020
Wipe any filesystem data and partitions from devices on Linux
wipefs should work in most cases to clean up filesystems.
# View filesystem data from a device
wipefs /dev/<my_device>
# Wipe any filesystem found
wipefs --all /dev/<my_device>If wipefs can’t detect a filesystem, you can quickly wipe the header data of the device with dd.
dd if=/dev/zero of=/dev/<my_device> bs=1M count=100 oflag=direct,dsync status=progressYou may need to restart your machine for the OS to recognize the filesystem deletion, for instance if your device is an “LVM2_member”.
Also, as a last resort, you can completely wipe the device.
dd if=/dev/zero of=/dev/<my_device> bs=1M count=5000000 oflag=direct,dsync status=progressTo delete partitions, sgdisk should work well.
sgdisk --zap-all /dev/<my_device>