TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Replace a running Debian installation by Arch remotely over ssh

161 pointsby m-ou-seover 9 years ago

28 comments

bobmagooover 9 years ago
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.
评论 #10990956 未加载
评论 #10992541 未加载
qrmnover 9 years ago
I&#x27;ve experimented with doing this kind of thing myself, especially with servers where I don&#x27;t have ready access to the console and where the provider doesn&#x27;t offer custom ISO support and I wanted a clean (and&#x2F;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&#x27;s first sector also a bootable MBR), and then simply dd if=install.iso of=&#x2F;dev&#x2F;sda - right over the top of the partition table and everything.<p>It&#x27;s inelegant, to say the very least, but it works just fine! I&#x27;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.
评论 #10990862 未加载
评论 #10992982 未加载
评论 #10994406 未加载
评论 #10994515 未加载
评论 #10994527 未加载
bentpinsover 9 years ago
It reminds me of changing the wheels of a car while driving it<p><a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=MQm5BnhTBEQ" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=MQm5BnhTBEQ</a>
yuvadamover 9 years ago
There&#x27;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:&#x2F;&#x2F;github.com&#x2F;gh2o&#x2F;digitalocean-debian-to-arch" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;gh2o&#x2F;digitalocean-debian-to-arch</a>
评论 #10993239 未加载
评论 #10989113 未加载
mverwijsover 9 years ago
Heheh. People used to do this with Debian when Debian wasn&#x27;t widely available on remote hosts. Even made it to the official Debian manual it seems:<p><a href="https:&#x2F;&#x2F;www.debian.org&#x2F;releases&#x2F;etch&#x2F;i386&#x2F;apds03.html.en" rel="nofollow">https:&#x2F;&#x2F;www.debian.org&#x2F;releases&#x2F;etch&#x2F;i386&#x2F;apds03.html.en</a>
评论 #10991030 未加载
评论 #10990616 未加载
评论 #11008422 未加载
hspakover 9 years ago
This reminds me of when the Twitch Installs Arch Linux took off, someone got a script to run that installed gentoo over the arch install.
moreorlessover 9 years ago
Reminds me of depenguinator back from the days :)<p><a href="http:&#x2F;&#x2F;www.daemonology.net&#x2F;blog&#x2F;2008-01-29-depenguinator-2.0.html" rel="nofollow">http:&#x2F;&#x2F;www.daemonology.net&#x2F;blog&#x2F;2008-01-29-depenguinator-2.0...</a><p><a href="https:&#x2F;&#x2F;github.com&#x2F;allanjude&#x2F;depenguinator" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;allanjude&#x2F;depenguinator</a>
dantillbergover 9 years ago
This is fantastic for e.g. EC2 where Arch Linux AMIs are hard to come by. (where &quot;hard to come by&quot; just means that they&#x27;re available at <a href="https:&#x2F;&#x2F;www.uplinklabs.net&#x2F;projects&#x2F;arch-linux-on-ec2&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.uplinklabs.net&#x2F;projects&#x2F;arch-linux-on-ec2&#x2F;</a> but I don&#x27;t know who uplinklabs.net is nor whether I should trust their AMIs)
评论 #10992997 未加载
mfinchamover 9 years ago
Here&#x27;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:&#x2F;&#x2F;github.com&#x2F;fincham&#x2F;kexec-remote-debian-install" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;fincham&#x2F;kexec-remote-debian-install</a><p>Works on DigitalOcean etc.
namecastover 9 years ago
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&#x27;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&#x27;ve got a stew going!
clordover 9 years ago
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...
nailerover 9 years ago
They&#x27;re nervous about this part:<p><pre><code> # Restart sshd in the new root. cp &#x2F;mnt&#x2F;etc&#x2F;ssh&#x2F;* &#x2F;etc&#x2F;ssh killall -HUP sshd # You&#x27;ll have to reconnect at this point. Let&#x27;s hope it works. </code></pre> Use a dead man&#x27;s switch: set an &#x27;at&#x27; job to undo everything in 10 minutes. If you screw up and get disconnected, the at job runs.
giggi89over 9 years ago
I&#x27;ve been using <a href="https:&#x2F;&#x2F;github.com&#x2F;drizzt&#x2F;vps2arch" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;drizzt&#x2F;vps2arch</a> since a &quot;long&quot; time for the same task
emeralddover 9 years ago
Kind of like installing gentoo <a href="https:&#x2F;&#x2F;www.gentoo.org&#x2F;get-started&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.gentoo.org&#x2F;get-started&#x2F;</a>
mrpippyover 9 years ago
I remember doing this to install Gentoo on a RedHat 7 (not RHEL 7, but RHL 7) machine ~12 years ago.
kozukumiover 9 years ago
These kind of things is what makes Linux so amazing [to me].<p>I wonder if this is possible with Windows at all?
评论 #10992391 未加载
agumonkeyover 9 years ago
shouldn&#x27;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.
BorisMelnikover 9 years ago
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 &quot;uptime&quot; yes?
评论 #10989152 未加载
Sleakerover 9 years ago
This only works on a KVM host or one with actual mount points though, correct? Like it wont work on a virtual host with a shared kernel correct?
digi_owlover 9 years ago
<a href="http:&#x2F;&#x2F;bedrocklinux.org&#x2F;" rel="nofollow">http:&#x2F;&#x2F;bedrocklinux.org&#x2F;</a> came to mind...
mixmastamykover 9 years ago
Too bad it doesn&#x27;t replace Windows instead.
评论 #10990306 未加载
评论 #10990771 未加载
geofftover 9 years ago
If I&#x27;m reading this right, this creates a <i>new</i> Arch rootfs onto &#x2F;dev&#x2F;xvda2 and abandons the old Debian one?
评论 #10989505 未加载
评论 #10989484 未加载
outworlderover 9 years ago
That&#x27;s actually one of the ways you can install Gentoo. That is, over a running system. Which can be remote.
lsv1over 9 years ago
reboot # And pray it&#x27;ll boot.<p>Let&#x27;s do this in production.
评论 #10994436 未加载
unixheroover 9 years ago
This is awesome. Totally a ballsy thing to do :)
wakwanzaover 9 years ago
so basically the tuxissa virus.
lutuspover 9 years ago
My favorite line from the procedure:<p>&gt; reboot # And pray it&#x27;ll boot.<p>This kind of thing should be performed by a well-tested script, not an interactive session. Otherwise you might have an &quot;Oh, what did I just type?&quot; moment.
评论 #10991119 未加载
评论 #10990979 未加载
dh997over 9 years ago
Linux installs (apart from grub boot blocks and partitioning) are JBOF (just a bunch of files).<p>Mostly, the non-user parts are &#x2F;etc &#x2F;boot &#x2F;usr and &#x2F;var (for package management), and things aren&#x27;t always in the same places and conf files may vary in options because of version&#x2F;patch differences.<p>Using symlinks and seperate directories, it&#x27;s theoretically possible to switch OSes at boot time assuming everything is symlink-agonistic (stow for operating systems)<p>It&#x27;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&#x27;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.