wipefs should work in most cases to clean filesystems.
# View filesystem data from device wipefs /dev/<my_device> # Wipe any filesystem found wipefs --all /dev/<my_device>
wipefs can’t detect a filesystem, you can quickly wipe the header data of the device with
dd if=/dev/zero of=/dev/<my_device> bs=1M count=100 oflag=direct,dsync status=progress
You may need to restart your machine to make the filesystem deletion known to the OS, if your device is a “LVM2_member” for instance.
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=progress
To delete partitions,
sgdisk should work well.
sgdisk --zap-all /dev/<my_device>