Live data from Hacker News

Takeover.sh – Wipe and reinstall a running Linux system via SSH without reboot

github.com

61–70 of 80 posts

Re: Takeover.sh – Wipe and reinstall a running Linux system via SSH without reboot

#62

For anyone interested in adding this to their toolkit, I would suggest reading this StackOverflow answer: http://unix.stackexchange.com/a/227318/189858 In short, the answer details how to switch your running system to use an in-memory only root filesystem, without restarting. This allows installing a new OS, resizing the OS disks, etc. It's a risky operation, but the linked answer covers many pitfalls that you might…

I've been using this procedure to remotely replace operating systems for years. The most common scenario is a VPS provider that doesn't give you the choice of OS you want. Infact, I will be using it later today, to replace a Debian system with Gentoo, no less. The README in OPs link is spot-on here (the last few paragraphs).

This is exactly what I thought when I saw this post. I really want to use Void Linux on a provider, but no one supports it (except for those who allow custom images like Linode). It'd be great to be able to provision a standard Ubuntu or CentOS box and then replace it with the OS I actually want to run.

Re: Takeover.sh – Wipe and reinstall a running Linux system via SSH without reboot

#64

For anyone interested in adding this to their toolkit, I would suggest reading this StackOverflow answer: http://unix.stackexchange.com/a/227318/189858 In short, the answer details how to switch your running system to use an in-memory only root filesystem, without restarting. This allows installing a new OS, resizing the OS disks, etc. It's a risky operation, but the linked answer covers many pitfalls that you might…

Thanks for this! Ive been doing wacky stuff like kexec which was completely unecessary when I could've just done a pivot_root...

Re: Takeover.sh – Wipe and reinstall a running Linux system via SSH without reboot

#65
post #21
post #17

Seeing if I understand what this is doing: this keeps running the same Linux kernel and kernel modules, but swaps out absolutely everything else up to and including the init system - is that right?

More precisely, what it does is start a new init system on a pseudofilesystem, starts an sshd chrooted to that new system, and lets you then login there, where you can then, if you want, umount the original root fs, wipe it, install a new os, then reboot the system.

Thanks!

Re: Takeover.sh – Wipe and reinstall a running Linux system via SSH without reboot

#66
post #4

Pretty cool, although I'm pretty sure I would never use something like this. What has saved my skin on a number of occasions is the ability to boot remote servers into rescue mode and chroot into the broken system. That way you can use package managers, all your diagnostic tools, and everything else the boot image doesn't provide. Basically you just mount the different partitions and then chroot just swaps /proc /sys…

I work at an IT Helpdesk and we build a custom GRML image which we write to our pen drives. We use it, for example, to quickly live boot Debian/Ubuntu PC's and run a script that mounts all necessary file systems (including pseudo file systems). This makes it really easy to quickly chroot into a broken system right at a users desk.

On our Linux installations we have separated most of the directories into different LVM partitions. Such as '/home', '/usr', '/var' and of course '/' (the root). Just last week I helped a user live boot his system and ran a fsck on his '/home' partition. We had "frozen" the system and hard reset his computer which led to a couple of corrupt blocks and inodes.

Re: Takeover.sh – Wipe and reinstall a running Linux system via SSH without reboot

#67
Another nice trick of this family (with reboots, or without with using systemd-nspawn) lies with clever btrfs usage. Long story short:

* use btrfs, and create your main root filesystem as a btrfs partition subvolume and another btrfs subvolume for snapshots (also a sub of master btrfs partition)

* to start any experiment (e.g. installing whole gnome and 500 different packages you MIGHT WANT TO REVERT in the future) create before the risky operation snapshot (btrfs subvolume snapshot / /.snapshots/yournameofsnap) of current filesystem

* experiment in any way :)

* switch between old root (snapshot you created) or the new one with (btrfs subvoulme set-default)

* delete any of them (btrfs subvolume delete)

btrfs copy-on-write allows all of these commands to happen instantly without (almost) any actual copying. Also booting from both volumes is possible without any additional steps as long as master btrfs partition is the one to be booted from UEFI.

https://wiki.archlinux.org/index.php/Btrfs

Re: Takeover.sh – Wipe and reinstall a running Linux system via SSH without reboot

#68
post #53
post #7

Earlier quoted context omitted.

Haha yes, this is the default install procedure for Gentoo! :D

It's funny, I knew how to do that when I borked my systems back in 2004 only because the Gentoo installation instructions were like that.

Sort of the same for me but I learnt it from the Arch Linux installation process.

Re: Takeover.sh – Wipe and reinstall a running Linux system via SSH without reboot

#69

Earlier quoted context omitted.

Pretty sure the conflation has been around ever since rocket science and brain surgery have been used as a comparison. :)

I don't tend to link youtube videos on HN, particularly of the comedic type, but I'm just going to leave this here for anyone who wants a good laugh for their morning. https://www.youtube.com/watch?v=THNPmhBl-8I

That was great!

Re: Takeover.sh – Wipe and reinstall a running Linux system via SSH without reboot

#70
post #67

Another nice trick of this family (with reboots, or without with using systemd-nspawn) lies with clever btrfs usage. Long story short: * use btrfs, and create your main root filesystem as a btrfs partition subvolume and another btrfs subvolume for snapshots (also a sub of master btrfs partition) * to start any experiment (e.g. installing whole gnome and 500 different packages you MIGHT WANT TO REVERT in the future) c…

Congratulations, you've reinvented ZFS Boot Environments :)
Post reply on HN