How to fix a borked USB flash drive

Josh Sherman
7 min read

So this post was supposed to be how I [yet again] fixed an issue with a USB flash drive that I use for installing Linux.

The USB flash drive in question is “the blue one” that I picked up back in 2016 because I wanted to have a handful of smaller sized thumb drives laying around while I did some soul searching to find the best Linux distro for me.

The blue one has always housed a copy of Arch Linux. The red one had Debian Stretch on it from back when it was still in testing.

There was also a black one I gave the wife to hold some dance music for the kiddo, a purple one that had Ubuntu on it, that I think also went to the wife and a green one that I gave my buddy Justin last time he was in town to film an application video for Y Combinator with me.

I really like having these little drive laying around. 2 gigs is more than enough for my needs, as most Linux ISOs are less than that, and they are cheap enough on Amazon that I don’t feel bad giving them away when the need arises.

The real talk is, these drives are effectively disposable to me. I don’t use them for long term file storage and don’t use them for any backup purposes.

Of the 5 drives that I purchased in bulk, the blue one has been the one to give me the most trouble. Incidentally, it’s also the one I’ve used the most often as I tend to slap the latest version of Arch Linux on it before I get to installing.

I’m not here to argue that these flash drives are quality or not. They are sold in bulk and there’s like 20 companies all selling the same looking drives. I knew what I had gotten myself into.

As mentioned, this post was supposed to be about how I solved a problem with the drive. You see, a while back the drive had started to give me grief. It wasn’t mounting properly, even though the system could see it, and I was faced with some nonsense about how the super block and/or partition table was fucked.

Previously, I had somehow worked through all of my issues, and was able to get the latest version of Arch on the drive. That was about a year ago when I got my System76 Galago Pro.

More recently, I picked up a new computer (more on that later, as it was a dud and I’m waiting for a replacement now) and since Arch is still my Linux distro of choice, I went through my usual routine of downloading the current month’s release and went to dd it on the drive.

Upon running dd, the light on the drive didn’t flicker as it normally would. Being somewhat hasty because I really wanted to get my new system up and running, I opted to just try running things again.

No dice. Unplugged, replugged, unplugged again. Rebooted, all of the usual troubleshooting shit. At some point, I realized the drive wasn’t even mounting properly when inserted.

Never fear! In the past, I’ve been able to plug a finicky drive into a macOS system and have it bark about the drive being unrecognized and offer up a reformat to get things moving in the right direction again.

This time around, macOS was like “lolnope”. Windows was the same deal. Didn’t even acknowledge the drive, didn’t tell me shit was fucked and I needed to format it. Didn’t do anything.

Just to make sure it was the drive in question, I did go through the motions with the red drive with Debian on it. Everything there was as it should be, so I deemed the drive to be the problem.

Because I didn’t want to spend all night on this, I went ahead and slapped Arch on the red drive, and proceeded to muddle my way through getting Windows and the system bios to let me install Linux.

All was fairly right in the world at this point.

Then came last Saturday night.

I decided that I wasn’t going to give up on my favorite little thumb drive. I brought her back to life once, so I still had faith in her future.

A few things I tried:

After trying a bunch of stuff, including using the GNOME Disks application (which didn’t give me many options) I did what I should have did at the start, I ran fsck on the drive.

fsck is a handy command that can check and even repair a Linux file system.

Upon running fsck on /dev/sda and /dev/sda1, I was greeted with a message advising that the super block could not be read or does not describe a valid file system:

# fsck /dev/sda1
fsck from util-linux 2.34
e2fsck 1.45.3 (14-Jul-2019)
ext2fs_open2: Bad magic number in super-block
fsck.ext2: Superblock invalid, trying backup blocks...
fsck.ext2: Bad magic number in super-block while trying to open /dev/sda1

The superblock could not be read or does not describe a valid ext2/ext3/ext4
filesystem.  If the device is valid and it really contains an ext2/ext3/ext4
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
    e2fsck -b 8193 <device>
    e2fsck -b 32768 <device>

This error was the one that started to feel a bit more deja vu. This was exactly what happened the last time, and I know there was a command out there that could help me along, even if I couldn’t remember what the hell it was.

In my latest research, I did find a script called mkusb that seems to have made it super easy to blow away the first byte, which if corrupt can cause issues similar to what I was experiencing.

Amazingly enough, I wasn’t able to find the package out in the Arch Linux official packages or the Arch Linux User Repository (AUR).

Knowing I didn’t use this script last go around, I kept on chugging, pretty much brute forcing solutions from Stack Overflow and other sources.

After running a handful of commands that gave the impression that things were addressed and actually fixed (but they weren’t), I finally decided that the best path to fix things was just give it a fucking rest already.

As a software engineer, I love solving problems, but sometimes the time invested isn’t worth it. Sure a couple of hours of poking around on a Saturday night is harmless enough, but what else could I have been doing during that time?

I’d even argue that doing nothing and NOT being on the computer for a couple of hours would have been time well spent in comparison to muddling along trying to fix a USB drive that didn’t even contain any important files.

I mentioned previously, the drive was purchased in 2016. At ~$3 for the unit, I’ve gotten nearly 3 years of usage, coming out to a grand total of $1 per year.

So yeah, unless the drive has important files on it, often times the best way to fix a borked USB flash drive is to just trash it and buy a new one.

That said, I still ended up getting a blog post out of it, and even with the issues I had with that one particular drive, I’d absolutely buy those drives again.

Join the Conversation

Good stuff? Want more?

Weekly emails about technology, development, and sometimes sauerkraut.

100% Fresh, Grade A Content, Never Spam.

About Josh

Husband. Father. Pug dad. Musician. Founder of Holiday API, Head of Engineering and Emoji Specialist at Mailshake, and author of the best damn Lorem Ipsum Library for PHP.

Currently Reading

Parasie Eve

Previous Reads

Buy Me a Coffee Become a Sponsor

Related Articles