curl > /dev/sda: How I made a Linux distro that runs wget | dd
51–60 of 70 posts
Re: curl > /dev/sda: How I made a Linux distro that runs wget | dd
#52Well not quite direct; the bits go through your RAM in between.
Re: curl > /dev/sda: How I made a Linux distro that runs wget | dd
#53Unfortunately it's not safe as the kernel can still write to (what it thinks is) the old filesystem on the device, which will introduce corruption to the new disk image. However a fun fact is that you can (do not actually do this!) boot a qemu VM from /dev/sda. You have to use an overlay (eg. qemu -drive snapshot=on flag) so that qemu won't write through to /dev/sda. I use this trick in supernested, a script I wrote…
I used to dual-boot windows, but I was too lazy to actually reboot, so naturally I had Virtualbox just boot the physical Windows partition while Linux was running. Which is totally fine! It's not a real dual boot if you don't boot both partitions at the same time. As long as you don't install guest VBox drivers, those would make it hang when it boots as the host on physical hardware, since there's no longer someone a…
I had no idea that this was possible, and I learned something new today. Thank you!
Re: curl > /dev/sda: How I made a Linux distro that runs wget | dd
#54Unfortunately it's not safe as the kernel can still write to (what it thinks is) the old filesystem on the device, which will introduce corruption to the new disk image. However a fun fact is that you can (do not actually do this!) boot a qemu VM from /dev/sda. You have to use an overlay (eg. qemu -drive snapshot=on flag) so that qemu won't write through to /dev/sda. I use this trick in supernested, a script I wrote…
unmount the efi and boot partitions, write your image to the head of the disk, power cycle, then grow the last filesystem from the image to cover the rest of the disk.
you might get lucky and have all three of uefi/boot/swap to work with.
of course with the advent of uefi, you could instead just drop an installer image directly into the efi parition and boot that.
Re: curl > /dev/sda: How I made a Linux distro that runs wget | dd
#55From the article: > The OS may stop you from unmounting /dev/sda1, but it won’t stop you from writing to /dev/sda1 or /dev/sda even if there’s something mounted! Not always true. There's a kernel config option that allows it. CONFIG_BLK_DEV_WRITE_MOUNTED
Re: curl > /dev/sda: How I made a Linux distro that runs wget | dd
#56> How do you unmount your OS’s disk while keeping the OS running to be able to overwrite itself? I went down a similar rabbit-hole myself, with the goal of safely replacing the Linux installation on a disk that a machine is already running from (e.g. replace a VPS's setup image with one of your own) without needing a KVM-style remote access tool to the console. The problem there is if you directly modify the disk whe…
I usually just move all the files to a new directory (/oldroot) and pivot_root -- any open files reference the new paths. Then install into the newly empty root directory of the filesystem, reboot and delete the /oldroot.
Re: curl > /dev/sda: How I made a Linux distro that runs wget | dd
#57Unfortunately it's not safe as the kernel can still write to (what it thinks is) the old filesystem on the device, which will introduce corruption to the new disk image. However a fun fact is that you can (do not actually do this!) boot a qemu VM from /dev/sda. You have to use an overlay (eg. qemu -drive snapshot=on flag) so that qemu won't write through to /dev/sda. I use this trick in supernested, a script I wrote…
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...
Re: curl > /dev/sda: How I made a Linux distro that runs wget | dd
#58Unfortunately it's not safe as the kernel can still write to (what it thinks is) the old filesystem on the device, which will introduce corruption to the new disk image. However a fun fact is that you can (do not actually do this!) boot a qemu VM from /dev/sda. You have to use an overlay (eg. qemu -drive snapshot=on flag) so that qemu won't write through to /dev/sda. I use this trick in supernested, a script I wrote…
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...
Re: curl > /dev/sda: How I made a Linux distro that runs wget | dd
#59So ending up at:
> From a 292MB initramfs, we now have a 6.1MB initramfs, smaller than almost every other distro's initramfs and made entirely to run busybox wget dd.
Is pretty great achievement today - but way bigger than something that can fit on a floppy.
Re: curl > /dev/sda: How I made a Linux distro that runs wget | dd
#60Earlier quoted context omitted.
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...
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.
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.