Just waiting for the hilarious/terrible moment when someone hooks this up to a script scanning the internet for weak SSH passwords and singlehandedly skyrockets the install base for Arch.
I've experimented with doing this kind of thing myself, especially with servers where I don't have ready access to the console and where the provider doesn't offer custom ISO support and I wanted a clean (and/or customised) install, perhaps of something not yet supported.<p>While I did have some success with in-place install shenanigans, I eventually settled on creating a customised install ISO for the distribution I wanted (with a script to have it automatically listening for remote shell connections, and so on), using isohybrid on the ISO (which makes the ISO's first sector also a bootable MBR), and then simply dd if=install.iso of=/dev/sda - right over the top of the partition table and everything.<p>It's inelegant, to say the very least, but it works just fine! I'm pretty sure I saw that technique used a few times during Twitch Installs Arch Linux, during the more exotic segments when some joker hijacked the effort temporarily by installing Windows 95, and TempleOS, and so on.
It reminds me of changing the wheels of a car while driving it<p><a href="https://www.youtube.com/watch?v=MQm5BnhTBEQ" rel="nofollow">https://www.youtube.com/watch?v=MQm5BnhTBEQ</a>
There's a battle tested script that already does this specifically for DigitalOcean and can probably easily be adopted to other environments<p><a href="https://github.com/gh2o/digitalocean-debian-to-arch" rel="nofollow">https://github.com/gh2o/digitalocean-debian-to-arch</a>
Heheh. People used to do this with Debian when Debian wasn't widely available on remote hosts. Even made it to the official Debian manual it seems:<p><a href="https://www.debian.org/releases/etch/i386/apds03.html.en" rel="nofollow">https://www.debian.org/releases/etch/i386/apds03.html.en</a>
Reminds me of depenguinator back from the days :)<p><a href="http://www.daemonology.net/blog/2008-01-29-depenguinator-2.0.html" rel="nofollow">http://www.daemonology.net/blog/2008-01-29-depenguinator-2.0...</a><p><a href="https://github.com/allanjude/depenguinator" rel="nofollow">https://github.com/allanjude/depenguinator</a>
This is fantastic for e.g. EC2 where Arch Linux AMIs are hard to come by. (where "hard to come by" just means that they're available at <a href="https://www.uplinklabs.net/projects/arch-linux-on-ec2/" rel="nofollow">https://www.uplinklabs.net/projects/arch-linux-on-ec2/</a> but I don't know who uplinklabs.net is nor whether I should trust their AMIs)
Here's my attempt at partially automating this process for replacing Debianish systems remotely with Debian by launching the installer initrd with kexec: <a href="https://github.com/fincham/kexec-remote-debian-install" rel="nofollow">https://github.com/fincham/kexec-remote-debian-install</a><p>Works on DigitalOcean etc.
Neato. Just one minor nitpick: I see two points where vim is invoked but no way to tell what edits were made to the files (though it's easy enough to guess from the filenames).<p>Switch those two out with appropriate sed or echo commands, add a bash shebang at line 1, and baby, you've got a stew going!
Instead of rebooting, it should (in theory) be possible to use the kexec syscall to replace the kernel. I would rather just reboot for various hardware-related reasons though...
They're nervous about this part:<p><pre><code> # Restart sshd in the new root.
cp /mnt/etc/ssh/* /etc/ssh
killall -HUP sshd
# You'll have to reconnect at this point. Let's hope it works.
</code></pre>
Use a dead man's switch: set an 'at' job to undo everything in 10 minutes. If you screw up and get disconnected, the at job runs.
I've been using <a href="https://github.com/drizzt/vps2arch" rel="nofollow">https://github.com/drizzt/vps2arch</a> since a "long" time for the same task
Kind of like installing gentoo <a href="https://www.gentoo.org/get-started/" rel="nofollow">https://www.gentoo.org/get-started/</a>
shouldn't there be a sed line to uncomment some locales before actually locale-gen them ?<p>ps: I was completely blind to that vim statement just above. Ha, humans.<p>pps: also learned about mount --move and pivot_root from util_linux.
This is nuts, I would have never guessed you could swap an entire OS out! I scanned the code, this can be done without rebooting and while preserving "uptime" yes?
My favorite line from the procedure:<p>> reboot # And pray it'll boot.<p>This kind of thing should be performed by a well-tested script, not an interactive session. Otherwise you might have an "Oh, what did I just type?" moment.
Linux installs (apart from grub boot blocks and partitioning) are JBOF (just a bunch of files).<p>Mostly, the non-user parts are /etc /boot /usr and /var (for package management), and things aren't always in the same places and conf files may vary in options because of version/patch differences.<p>Using symlinks and seperate directories, it's theoretically possible to switch OSes at boot time assuming everything is symlink-agonistic (stow for operating systems)<p>It's possible and rarely necessary except for personal playgrounds but a production box would follow 12factors standards and lifecycle the entire OS by switching the underlying base image with something like unionfs + hypervisor.<p>Lots of ways to shoot yourself in the feet, and in box rebuilds it's usually much faster to just start fresh and deploy using configuration management than try to hammer a bank into the shape of plane.<p>Definitely make verified backups before attempting a lobotomy on anything real.