Erasing FreeBSD USB stick

Recently I installed FreeBSD 14.2 on a USB stick. The idea was that I have a Windows laptop that has to remain intact, but I wanted to run FreeBSD. Eventually I gave up because I couldn't get the NIC on the laptop to work right.

So I decided to reuse the USB stick. First I tried using dd to write zeros onto it. Dd told me it had a read-only filesystem.

Next I tried using gpart destroy, and it also told me it had a read-only filesystem.

Finally, I put it on a Windows 11 system and was able to delete it. It appears that Windows has improved how it deals with Unix and Linux volumes. It used to get confused and not let you delete the *nix partitions.

So I got my problem solved, but I am still trying to figure out what I was doing wrong with the Unix tools. Am I overlooking something obvious?

Thanks...Lynn
 
That doesn't make sense.

A dd with zeros goes to the raw device such as /dev/da3. There is no filesystem involved.

Likewise gdisk is not concerned with filesystems.
 
I ran into something, which I can't find now, that implied that the problem was that the same partitions were mentioned in fstab (since both the host system and the USB stick have roughly identical layouts (which are ZFS, in case that is important). But the fstab entries have the device listed, so there shouldn't be any confusion.
 
So I got my problem solved, but I am still trying to figure out what I was doing wrong with the Unix tools. Am I overlooking something obvious?
Yeah, there is stuff that was overlooked.

According to the Handbook chapter on installing FreeBSD, this command creates a bootable USB installation stick:
Code:
# dd if=FreeBSD-13.1-RELEASE-amd64-memstick.img of=/dev/da0 bs=1M conv=sync


First, make sure the stick is inserted, but not mounted. A mounted stick will show up as /dev/da0s1 or /dev/da0p1. When the stick is not mounted, it will show up as /dev/da0, which is what you need to properly run the command.

No need to do gpart destroy, umount will do the job.

Next, in that /bin/dd command, you sub out the if=FreeBSD-13.1-RELEASE-amd64-memstick.img part, and replace it with if=/dev/zero. This will zero out your stick under FreeBSD. BTW, according to the dd(1) manpage, you can also add status=progress if you want to see the progress bar in command-line.

Oh, and you can use the same command to 'burn' a CD/DVD .iso file to a USB stick if it's big enough. I do that to MicroSD cards. :P
 
First, make sure the stick is inserted, but not mounted. A mounted stick will show up as /dev/da0s1 or /dev/da0p1. When the stick is not mounted, it will show up as /dev/da0, which is what you need to properly run the command.
This is not true. When a disk is attached and if the system can determine its format, it will create related devices such as da0p1 or da0s1 etc. In fact until these devices exist, you can not mount the disk resident filesystem.
 
It appears that Windows has improved how it deals with Unix and Linux volumes.
Nah, already Windows 95 was absolute top in dealing with such. When having a dual boot system, and you needed to reinstall Windows again 'cause its registry again was messed up too much, you had to lock your MBR, better have a backup, too, and unplug all drives containing non-Windows OS. Windows installation process never informed, nor asked, just wiped any drive found with no-Windows system or MBR clean, not matter if it used them, or not.
"If you wanna disks destroyed, install Windows!" 😁

A system doesn't need to have any knowledge about other filesystems or partition schemes to overwrite them. It needs at least to know there are others but the own to at least see a disk may not free, or unformatted, to prevent accidental write.

Seriously:
At the bottom of dd's man page:
Code:
BUGS
       Protection mechanisms in    the geom(4) subsystem might prevent the    super-
       user from writing blocks    to a disk.  Instructions for temporarily  dis-
       abling  these  protection  mechanisms  can  be found in the geom(4) man
       page.

Maybe that's what leads to the cause.
 
When a disk is attached and if the system can determine its format, it will create related devices such as da0p1 or da0s1 etc.
That's exactly what 'mounting' is to begin with.

A textbook by Tanenbaum may explain a bit better. Quoting the exact page and implementation of the mounting process is left as an exercise for the reader.

Maybe I did misread or misunderstand something in the Handbook, though. It did suggest making sure that the disk is not mounted. So, I tried playing with dd(1) to see if it will throw errors on a mounted stick, but it didn't.
Code:
# dd if=/dev/zero of=/dev/da1 bs=1M conv=sync status=progress

In any event, no need for gpart destroy.

Well, some of those USB sticks are actually SD or MicroSD adapters. The SD/MicroSD cards themselves do have a physical write protection slider on the edge that sometimes slides out of place. Sometimes, the USB stick itself comes with such a slider.
 
I still keep a Window 98 installation on a VM so I can play my Zork library.
I never cease to be amazed at how FAST Win98 performs over Win10 on the same type of VM.
I was forced to finally upgrade my primary big workstation from Win7 to Win10, and amazed at how much of a slug Win10 is on the same hardware.
 
Back
Top