Woefull USB in NixOS

Woefull USB in NixOS
GNU/Linux via NixOS empowering Windows

So, I needed to create a Windows 11 bootable USB stick for my desktop PC (gaming system I'm reinstalling), and all I had was my Zombie X1 running NixOS 24.11 because of other poor life choices. Nothing says "I love a challenge" like using a Linux distro that prides itself on making you question your other life choices. I got it working and in this little aside I'll talk about my journey to resolves my woes.

First attempt? The Disk Destroyer (dd)

This notorious command, affectionately known as "data destroyer," that I love. dd is infamous for its efficiency in turning your disks drives into coasters; surprise, it didn’t work.

dd if=/home/cloudnull/Downloads/Windows.iso of=/dev/sdX bs=1M

My attempt to use dd.

Instead of a sleek Windows 11 install media, I ended up with a USB stick that looked like it had been through a digital blender. Thanks, dd, you're the best.

🤡
I'm only partially kidding. While the drive was bootable, the Windows 11 installer would not work, resulting in an error stating, "A media driver your computer needs is missing." This error makes it impossible to do anything. To me, the root cause is unknown but the internet believes that it's caused by the drive format gone wrong; Microsoft thinks I should be using their USB installation media tool instead of dd.

After dd left me hanging, I had to look for another option. Enter woeusb, the tool that promises to eliminate your Windows woes. Normally, this would be a straightforward installation on any regular operating system. But hey, I'm not on a regular OS; I'm on NixOS, where doing simple things can sometimes feel like you need a PhD in underwater basket weaving.

Solving my Woes

Now, I'm not about to mess with my precious configuration.nix just for a one-time utility. If I wanted to spend hours debugging why my entire system won't boot after a single configuration change, while running on the beta version of an operating system, I'd still be using Arch. So, I decided to use nix-shell to install woeusb temporarily.

For those who don't know, nix-shell is like a temporary sandbox where you can install whatever you want without committing to a long-term relationship. It's the Tinder of package managers; you're welcome.
Attempting to use woeusb without nix-shell

Enter the Matrix (nix-shell)

I invoked the mighty nix-shell to pull in woeusb. This was my way of saying, "Hey, NixOS, I'm not cheating on you; I'm just... exploring my options."

nix-shell -p woeusb

Temporarily installing woeusb with nix-shell

Installing woeusb in my tinder shell

Formatting Fun

With woeusb at my disposal, it was time to format the drive correctly. If you don't do this, you'll encounter the aforementioned "A media driver your computer needs is missing" error during the Windows installation.

woeusb --device /home/cloudnull/Downloads/Windows.iso /dev/sdX

Creating my bootable USB Stick

Replace /dev/sdX with your actual USB device. If you get this wrong, well, I hope you enjoyed your previously functioning drive.
Running woeusb

Upon completion, you'll get a smiley face and the "should be bootable" vote of confidence this mission deserves.

Completing the drive

Here’s how the saga continued

Cross Your Fingers: After woeusb worked its magic, I stabbed my new USB stick back into my gaming PC and powered it on, hoping for the best. The USB stick, now blessed by a disciple of Bill Gates, was ready for action; the error was gone.

Fin

And there you have it - a journey filled with peril, dark humor, and a sprinkle of hope. Creating a Windows 11 bootable USB stick on NixOS wasn't as straight forward as I'd have hoped it to be, however, it was simple. nix-shell is a fantastically powerful tool that can make life easy just as soon as you get through the mental gymnastics needed to leverage it.

So next time you find yourself in a similar situation, remember: when dd leaves you high and dry, and you don't want to commit to full-on system manipulation, nix-shell + woeusb has got your back. Just ensure you keep your sanity levels in check; the world of NixOS can challenge them.

Mastodon