Remix.run Logo
Joker_vD 11 hours ago

What if we remount the filesystem(s) at /dev/sda as read-only first? Then make a small ramfs with statically-linked curl in it and exec it. Hmm. Ideally, you'd also want to call reboot(2) after it's done...

duskwuff 3 hours ago | parent | next [-]

One bit of magic you may be interested in is pivot_root, which allows another filesystem to take the place of the root filesystem (e.g. / and /mnt become /old and /). It's usually used during startup, to allow the "real" root filesystem to take the place of the initrd, but could have other uses.

Dylan16807 3 hours ago | parent [-]

Last time I tried to use it though I just could not get it to let go of the main filesystem even after repeatedly killing the processes I could and restarting the rest.

Taking control at the initrd stage, as in the second page of the article, is significantly more reliable.

But have busybox in your initrd so you don't have to suffer. It takes up 0.5% of the size of my initrd file.

tremon 4 hours ago | parent | prev | next [-]

You also don't want to do this under any kind of memory pressure, because the kernel will happily drop read-only pages from memory if it thinks they can be re-read from disk when needed.

astralbijection 10 hours ago | parent | prev | next [-]

All of those things get covered in parts 2, 3, and 4 :)

Joker_vD 10 hours ago | parent [-]

There's... no part 2 in the post? And it's the latest blog post on the site, as far as I can see.

astralbijection 10 hours ago | parent [-]

It does get linked at the very bottom, though admittedly it could be made clearer. https://astrid.tech/2026/03/24/1/swap-out-the-root-before-bo...

Joker_vD 10 hours ago | parent [-]

Oh, I see, the posts got published in the reversed order.

On the topic itself: wow, what a journey. And I personally fully support "come on, you should totally be able to just dump the system image onto your disk and reboot/exec it!"

akdev1l 10 hours ago | parent | prev [-]

in most cases you could just drop back into the initramfs that is included in most distros

Or if you have access to the boot command line you can also usually stop the boot process before pivot_root happens (hence you’ll be left running in the initramfs environment)

On Fedora/EL it would be done by putting `rd.break` in the kernel command line