Clean delete USB

Using XFCE.
I want to write nulls to a USB stick. When I plug it in PCManFM automatically mounts it, so I can’t…

#dd if=/dev/null of=/dev/sdb
0+0 records in
0+0 records out
0 bytes copied, 0.0078898 s, 0.0 kB/s

…so I…

#umount /dev/sdb1
localhost:/home/ion #dd if=/dev/null of=/dev/sdb
0+0 records in
0+0 records out
0 bytes copied, 0.00384992 s, 0.0 kB/s


#fdisk /dev/sdb

Welcome to fdisk (util-linux 2.33.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

fdisk: cannot open /dev/sdb: No such file or directory

It’s as if “you can’t get there from here.” Any suggestions would be appreciated.

/dev/null returns end-of-file immediately. You read nothing and you write nothing. If you want to overwrite something with zeroes, you need to use /dev/zero which returns endless stream of zero bytes.

Thank you. My frustrations are over.

That is fine!

I am still wondering. Assuming that your conclusion that /dev/sdb is indeed the mass-storage device you want to tackle.

You used /dev/sdb in your first CODE snippet. dd did NOT complain that it does not exist, but did what you asked for (though not what you wanted to do).

Then you umount /dev/sdb1. That is a bit late (better not overwrite a file system that is still mounted)., but again, no protest.

Then you use fdisk on that device and fdisk says there is no device file with that name???
Did you remove it (you say it connects through USB, thus I assume it is possible to remove it while the system is running), or what happened? I can not really understand this.


Yes, but, your original output from “#fdisk /dev/sdb” is a little bit puzzling …

I’m assuming that, you first, with the user “root”, executed “lsblk” and “lsblk --fs” – the expected output should be something like this – I’ve removed the output for the system drives – the USB stick/thumb-drive isn’t mounted:

 # lsblk 
sde      8:64   1   3,7G  0 disk 
└─sde1   8:65   1   3,7G  0 part 
sr0     11:0    1  1024M  0 rom  
sr1     11:1    1  1024M  0 rom  
 # lsblk --fs 
NAME   FSTYPE LABEL      UUID                                 FSAVAIL FSUSE% MOUNTPOINT
└─sde1 vfat              A853-E68B                                           

Then, “fdisk -l /dev/sde” produces the following output:

 # fdisk -l /dev/sde
Disk /dev/sde: 3.7 GiB, 3997171712 bytes, 7806976 sectors
Disk model: Trans-It Drive  
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x156052b6

Device     Boot Start     End Sectors  Size Id Type
/dev/sde1        8064 7806975 7798912  3.7G  b W95 FAT32

  • It’s a “nominal” 4GB stick but, “fdisk” reports “GiB” – “only” 3.7G …

[HR][/HR]So, now my question:

  • Does a “simple” ‘dd’ complete without a “can’t write past the end of the device
    ” error?
 # dd if=/dev/urandom of=/dev/sd? iflag=fullblock bs=512 status=progress
  • The “bs=” value should match to the “optimal” I/O value mentioned by “fdisk” – a value of ‘4096’ translates to “bs=4K” …

[HR][/HR]The reason for my question:

  • I’m erasing some old IDE HDDs before I drop them off at the local re-cycling depot and, I’m beginning to suspect that, I may have to use the “count=” parameter of “dd” …

dd? nah… >:)

Yes, of course or, an oxyacetylene torch …

Outdoors of course, else one may set off one’s smoke alarm. :wink:

Huh???!!! Since when is the use of welding equipment and forges in a workshop or smithy a smoke alarm issue? … …

Way off original topic now…

Depends what the flame is being played upon, if it’s generating smoke there’s the possibility an alarm would trigger.

I’ve set of a domestic smoke alarm, unintentionally, whilst simply using a portable propane torch when doing a little plumbing work, soldering 15mm copper water pipe fittings, presumably by smoke from the flux used. Made a change from the usual burnt toast alarm though…