How to really erase a usb pendrive

10 posts / 0 new
Last post
mfox
mfox's picture
How to really erase a usb pendrive

I'm starting to notice that more of my USB pendrives are becoming "compromised" after putting live distros on them. What I mean by this is that you go to erase them with gparted and afterwards you see that some information has been retained from the previous loading. Most recently, I noticed that BunsenLabs Linux actually partitions your USB and even though erasure indicates that those structures are gone, it seems to retain the name and mount point from that installation. I don't know if this, then compromises the use of that USB for other live distros, but I do notice that several of my USB pendrives are no longer bootable after installing a live distro on them, erasing it and installing another one. Can anyone recommend a freeware erasure tool that really cleans off the pendrive and retains nothing from a previous installation?

Edited by: mfox on 2016-05-12 12:50
jasonw

What do you mean by name? Do you mean the label? Can you post an example name? If it's a label reformatting the disk in gparted doesn't remove it because it's part of the partition, not the filesystem. There should be an option to remove the label in gparted, probably via a right-click.

Not sure what you mean by "seems to retain... the mount point". The mount point is where the distribution mounts that drive. That's not going to change just because you reformat the drive. If you're referring to the name of the mount point, an random-appearing bunch of characters, I believe that's part of the firmware on the USB drive (I think). In any case, that's the distribution you're using (the host that accesses the USB drive) that decides what to call it.

If you want to remove all the things that are possible (and perhaps resusciate your un-bootable drives), you should delete all the partitions, then create a new FAT32 partition and filesystem and format it. You can do all this in gparted.

Jason

Computer enthusiast, beginner programmer, political geek.

mfox
mfox's picture

I did what you suggested in gparted; that's what I always do. That's why I was surprised that (a) it retained the name (label) of the drive (something like BunsenLabs-Linux-xx-yy-2016, and also a mount point (something like /media/BunsenLabs-Linux-xx-yy-2016). How that would persist beyond the destruction of all partitions showing in gparted, following by the creation of a new FAT32 partition, is beyond me. Maybe Bunsen puts a hidden partition on it that gparted can't get to?

Mac user running Ubuntu 16.04 (Unity, Gnome) on Dell XPS 13 (4gb RAM, 250gb SSD)
Ubuntu 16.04, Chromixium, Remix OS and Crunchbang++ on upgraded 11.6" Acer 1810TZ Olympic Edition (4gb RAM, 240 SSD)
Ubuntu 16.04 on Mac mini, iMac & Dell 7020

jasonw

I thought the label was part of the partitioning info but maybe not. Apparently, if you have GNOME Disks, you don't need to use gparted to change the label. You can use GNOME Disks. I believe you can also delete the label and leave it blank. Apparently some distros will not boot if there is a label there (which might be your problem).

http://askubuntu.com/questions/276911/how-to-rename-partitions

Jason

Computer enthusiast, beginner programmer, political geek.

mfox
mfox's picture

First of all, I just verified that the BunsenLabs live USB could not be erased without a trace by gparted. Next I tried Gnome Disks, and formatted the disk with full erasure. Took 7 minutes on the 16 GB, but it worked.

Mac user running Ubuntu 16.04 (Unity, Gnome) on Dell XPS 13 (4gb RAM, 250gb SSD)
Ubuntu 16.04, Chromixium, Remix OS and Crunchbang++ on upgraded 11.6" Acer 1810TZ Olympic Edition (4gb RAM, 240 SSD)
Ubuntu 16.04 on Mac mini, iMac & Dell 7020

jasonw

Interesting.

Jason

Computer enthusiast, beginner programmer, political geek.

William Park

dd if=/dev/zero of=/dev/sdx bs=4M oflag=direct
will definitely erase your USB stick.

jasonw

Are you sure about that last flag? I just tried it the new 8 GB disk that Bob bought me and it errored out with:

dd: error writing '/dev/sdc': No space left on device

There were two partitions on the drive, but I used /dev/sdc for it.

Just tried it again without the direct option. It seemed to do the same thing (same error). But this time, I removed it after and reinserted it. Can't mount it now but that could be because there's now no filesystem on it (if it actually worked correctly despite the error message.

Update: It works now, but I had to go into Disks and quick-format it.

Jason

Computer enthusiast, beginner programmer, political geek.

mfox
mfox's picture

I think that what I did in Disks is the same thing William recommended on the command line. I say this because the disk I treated that way didn't mount either until I added a partition in gparted. But what is interesting in the first place is that gparted was unable to clear the pendrive; at least gparted run from an internal drive.

Mac user running Ubuntu 16.04 (Unity, Gnome) on Dell XPS 13 (4gb RAM, 250gb SSD)
Ubuntu 16.04, Chromixium, Remix OS and Crunchbang++ on upgraded 11.6" Acer 1810TZ Olympic Edition (4gb RAM, 240 SSD)
Ubuntu 16.04 on Mac mini, iMac & Dell 7020

William Park

Yes, I'm pretty sure about "oflag=direct". :-) Compare the elapsed time with or without the flag.

Regarding the error, it should give you error, because you're writing until the end.