Skip to content
Tech News
← Back to articles

curl > /dev/sda: How I made a Linux distro that runs wget | dd

read original get Linux Command Cheat Sheet → more articles
Why This Matters

This article highlights a powerful and unconventional method for installing or replacing a Linux OS directly onto a disk using curl piped to device files, emphasizing the flexibility and control available to advanced users. It underscores the importance of understanding low-level disk operations and scripting for efficient system management, which can be particularly valuable for automation, custom setups, or cost-saving measures in the tech industry and among enthusiasts.

Key Takeaways

curl > dev/sda How I made a Linux distro that runs `wget | dd` Linux http

To replace your Linux installation with a new OS, you can download a pre-prepared disk image directly to your disk by running a command like this:

curl https://something.example/foo.img > /dev/sda # (or whatever your disk is called)

No need to save it anywhere first, just pipe it directly to the disk. Then you can reboot into that OS, and congratulations, you’ve installed a new OS. This works even for most EFI machines without any further efibootmgr commands because EFI firmware automatically discovers the new EFI system partition!

This command is possible because /dev/sdX , /dev/nvmeX , and other such disks can be directly accessed from the filesystem, following the ancient Unix concept of “everything is a file.” You can write to the /dev/sdX file, and that directly writes to the disk!

No, like, why would you want to do this instead of installing Linux any other normal way?

Okay, so the reason I initially did this was because I didn’t want to pay Contabo an extra $1.50/mo to have object storage just to be able to spawn VPSes from premade disk images.

I thought it was a neat trick, a funny shitpost that riffs on the eternal curl | sh debate. I could write a blog post about it, I tell you about how you can do it yourself, one thousand words, I learn something, you learn something, I get internet points, win win.

The problem is that it didn’t stop there. I kept asking one more question. I kept peeling one more layer off the onion. I kept turning one more page in the grimoire… and before I knew it, I ended up with a four part blog series that doesn’t end where you expect it to end.

Why don’t we start from the beginning?

... continue reading