Live data from Hacker News

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

astrid.tech

41–50 of 70 posts

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

#42
Reminds me of the first company I worked for out of school.

We had a big drive with the source of truth image used to boot all our machines on it, and we added rsync to the init image. When each machine booted init would rsync everything from the storage box to the local machine. We'd keep the storage machine up to date and when we wanted to update other machines in the fleet we'd just do a reboot and it would sync up the latest files (provisioning for whatever each machine was supposed to do happened later, can't remember how that was handled now). The storage machine was running ZFS so we also took a snapshot before doing any rolling reboots, so if anything did go wrong you could just revert to the previous snapshot and reboot again as long as you didn't break the init image.

Sounds jank saying it out loud, but I don't remember it ever causing us any problems.

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

#43
post #8

Reminded me of how to install Alpine linux (which isn't available) on Oracle cloud over an ubuntu install. It uses dd and has the advantage of having a console. I had found it in a github gist when I used it but here's a similar blog post. https://alextsang.net/articles/20191006-063049/index.html

From what it sounds like, because you have a console and therefore aren't dependent on SSHD not getting overwritten, you can just dd the live running system here?

Like I said in the other comment I am not really familiar with the various clouds. I self host. The console is a weird web based thing that isn't the same environment as your VMs (or their hypervisor). It's a barebones shell where you can mount your volumes and such, not actually boot or enter the vm. (Edit: This was incorrect) And if I remember correctly I probably did have to do some mounting there to create device files and such. I didn't really have much use for the console after that either. I will try to find the actual gist I followed.

Here's the gist I had used. It's really simple. https://gist.github.com/unixfox/05d661094e646947c4b303f19f9b...

Why would not have not done the dd bit on the console? I have no idea. Again possibly can't download the iso there?

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

#45
post #21
post #7

> 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.

That sounds like the best way if keeping the filesystem is an option. In my case I wanted to also change filesystems and apply FDE, which is possible to do if the original filesystem supports online shrinking but many do not.

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

#47
Instead of applying some sense to the problem, and using a solution that actually allows you to kill all running processes of the original distro at runtime, incl. getting rid of the original init process, to be able to pivot_root somewhere else amd umount the original system's filesystems and free the block device for re-installation, this ridiculous approach gets promoted to a front page, lol.

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

#49
If you have a swap partition, swapoff it and install there. Or at least a minimal kernel and initramfs. Set as default in grub and there you go.

Also, I once burned an iso straight from ftp using a fifo. I was low on disk space and really needed that CD. Worked fine because the Internet was already faster than the CDR.

Post reply on HN