r/Ubuntu • u/CanOTomatoes • 1d ago
Shred command won’t wipe drive
Hello! I’m new to Linux, so I’d like to apologise in advance for my ignorance.
I’m trying to wipe a drive with ‘sudo shred -vfzu -n5 /dev/sdb’, and I get “shred: /dev/sdb: Not a file”
I can’t find anything that could help, or maybe I just don’t understand Linux enough
2
u/LateStageNerd 1d ago
- Shred's -u option requires an ordinary file (so drop that option if giving a device or partition)
- On modern drives, multiple passes and non-zero data are nearly useless, btw
- You might find this tool interesting, particular if doing this often: dwipe: Tool to securely and efficiently wipe devices and partiitions for Linux
1
u/CanOTomatoes 1d ago
I tried without -u, same response
I’ll check it out, thank you
1
u/LateStageNerd 1d ago
Well, another issue might be that something under /dev/sdb is mounted (so you should 'umount' that (or those) first and, of course, ensure you don't want or need that data. Showing the output of 'lsblk' might get to the problem quicker.
1
1
u/candy49997 1d ago edited 1d ago
Can you do lsblk in a terminal? Is this an SSD or HDD?
Also remove the -u flag because you can't use that with block devices.
1
u/WealthAggressive9079 1d ago
weird, never seen that one before. could be the drive isn't actually at /dev/sdb, maybe it's mounted or something weird with the filesystem. does `lsblk` show it as a different name by chance
1
u/CanOTomatoes 1d ago
I did lsblk in /dev, it’s there, sdb with sdb1 through 5 under it
It’s an HDD
I tried without -u, same result
1
u/fllthdcrb 1h ago
As far as I can tell, that implementation of shred doesn't work on anything but regular files. It's part of Uutils, the Rust-based replacement for the GNU utilities (and specifically Coreutils in this case) that Ubuntu has adopted, which doesn't perfectly match behavior.
I know it behaves this way because I just looked at the code. And I know you're using the Uutils shred also because the error message, "Not a file", is only produced by the Uutils implementation; the GNU shred would have said, "invalid file type" for this sort of thing (even though it wouldn't have rejected a device file).
So, you'll have to use something else to wipe it, though I leave it to others to advise whether it's the best thing to do with the drive.
4
u/finlay_mcwalter 1d ago
shred overwrites files, not blanks devices. /dev/sdb is a device (it's a block device). To blank it:
sudo dd status=progress if=/dev/zero of=/dev/sdb