curl > dev/sda

84 points by abhin4v a day ago on lobsters | 24 comments

sammko | a day ago

A fun linux exercise is to take a running system, create a minimal root in a tmpfs, get the system to a state where you can pivot root to the tmpfs and then unmount the disk. It takes some finnagling but is quite doable by hand. Systemd supports a concept of a shutdown initrd which is essentially that.

Then you install Arch curl > /dev/sda.

koala | a day ago

https://github.com/marcan/takeover.sh or, I believe nix-infect.

ThinkChaos | 15 hours ago

It's https://github.com/nix-community/nixos-anywhere now!

I was definitely thinking about it while reading the article cause I set it up recently. It doesn't download directly to disk, but indeed does kexec into a downloaded NixOS with tools to format disks and install the new system config.
What's a lot nicer compared to curl > /dev/sda is the download is done on an already setup machine, so kernel & tool signatures are checked by nix.

gigawhitlocks | 21 hours ago

Comment removed by author

icefox | a day ago

ooh that sounds fun. kinda the dual of setting up a chroot.

squarism | a day ago

This is what stage 1 gentoo was, I think? A very, very revealing and great teaching exercise. Live CD, get a system running in a temp dir, chroot into it. It is worth doing just once.

gigawhitlocks | 20 hours ago

oh I did this about ten years ago to migrate an Arch install from one machine to another, and it worked!

I followed exactly the steps you describe, except used rsync for the last step :D

mayli | 22 hours ago

A fun linux exercise is to take a running system, create a minimal root in a tmpfs, get the system to a state where you can pivot root to the tmpfs and then unmount the disk. It takes some finnagling but is quite doable by hand. Systemd supports a concept of a shutdown initrd which is essentially that.

Isn't we can just flush and remount everything with ro, then dd?

matheusmoreira | 13 hours ago

Why not both? :)

curl $MIRROR/archlinux-x86_64.iso > /dev/sda

evert | a day ago

I love this series. It's connecting a lot of Linux booting dots that I was missing. Note: the link to part 2 is in the bottom. I missed it initially

bjeanes | 7 hours ago

I read the whole series just now thanks to your comment. Truly a delightful adventure.

ClashTheBunny | a day ago

Things like this need more disclaimers. There are a bunch of people who don't understand the sarcasm and then suggest people do this on Reddit. Most of the search results for "how do I move my steam Deck to a new nvme drive" have this as the top voted answer and it's so frustrating.

There have been gists of better ways floating around for a while because Oracle free tier only allows Ubuntu: https://gist.github.com/4abhinavjain/893ec13c651bee08088c8f4661998952

aarroyoc | a day ago

I installed Debian on Oracle Cloud Free Tier in a different way. There's a debugging shell which allows you to jump into UEFI directly. From there you can just load netboot.xyz and install the distro you like

ClashTheBunny | a day ago

A much better way.

The way I settled on was to mount a new disk, dd the cloud image to it, reboot with it being the primary disk.

It was the only way I could get to reliabily work with hands totally off and terraform managing the state.

hugoarnal | a day ago

In case some people might’ve missed it, this is the first post in a 4 part series:

Part 0: this one

Part 1: https://astrid.tech/2026/03/24/1/swap-out-the-root-before-boot/

Part 2: https://astrid.tech/2026/03/24/2/how-to-pass-secrets-between-reboots/

Part 3: https://astrid.tech/2026/03/24/3/chicken-shed/

linkdd | a day ago

How does it compare to curl | sudo bash?

/s

Garbi | a day ago

It's more

pta2002 | a day ago

Well this is a wild ride.

I actually tried to find out how to something like this relatively recently, when I wanted to repartition an Oracle Cloud boot disk to have a larger /boot partition. So the partition layout was /boot 100MB (way too small for NixOS), and then imediately after that, 99.9GB of ext4. I ended up growing the disk slightly, moving the ext4 partition forward, and then growing /boot, but it would have been incredibly nice if I could have done this without having to pay oracle for another boot drive while I did this!

kjensenxz | a day ago

curl | sudo tee /dev/sda

mayli | 22 hours ago

tee binary to console is a very very bad idea

Garbi | 4 hours ago

Comment removed by author

Yep. To use the pattern anyway, you can pipe it away with:

curl | sudo tee /dev/sda > /dev/null

jevinskie | 6 hours ago

I thought that I had initramfs figured out until I had to roll my own. The author’s journey is pretty similar to the one I took!

I’ve had good luck using u-root in the past to boot Debian images via a TFTPed initrd that downloaded the large image via HTTP (since TFTP is slow). I had to tweak the u-root implementation of switch_root to add support for extra arguments (systemd init needed it IIRC).

https://github.com/u-root/u-root

ner0n | a day ago

Awesome! This is some ballsy education!

valpackett | 22 hours ago

ha, the way I had to install the postmarketOS rootfs onto my new phone was with nc -l 6969 > /dev/sdX12 over USB networking. The geniuses who worked on the bootloader decided that userdata should only be allowed to be erased from fastboot but not flashed with an image… and chainloaded U-Boot is (for now) useless as there's an issue breaking the UFS driver specifically with the combo of this SoC (kodiak/yupik) and UFS 3.x. So booting into debug-shell, starting the receiving netcat on the phone via telnet and the sending netcat on the PC was the easiest option left :)

izissise | a day ago

I love it