Live data from Hacker News

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

github.com

41–50 of 80 posts

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

#41

Earlier quoted context omitted.

You can ditch the initrd if you compile in the kernel the drivers you need to boot the system, as a minimal example SATA/SCSI, EXT4/JFS, that usually are compiled as kernel modules.

How most sane distros do it. Build a kernel with the most common hardware built into it, and use that to bootstrap. No need for messy things like balled up temporary rootfs in a ram drive. Initrd/initramfs have become an excuse for piling on complexities that frankly should be added by the sysadmin after initial install.

The purpose of the initrd to have the initrd bootstrap to rootfs. This involves userspace tools like mdadm, lvm2, cryptsetup, zfsprogs, etc.

It's not very common to need kernel modules (drivers) on initrd on typical hardware.

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

#42
post #29

Earlier quoted context omitted.

Something like this has been my default way of installing Linux for years - and I've installed Debian, Ubuntu (with debootstrap), Gentoo and Arch this way. Typically I just create another partition to my LVM volume group, chroot and install over there and then reboot without removing the old OS install and I run the install procedure from the old OS (instead of booting from a Live CD / usb stick). I do this because I…

You really only need two (kernel and initrd/initramfs), at least to get into a basic running state. This requires building your own initrd, of course, but it's pretty common in non-graphical Linux installers (Slackware's install media still does this, IIRC). I think it's even possible to embed the initrd in the kernel binary itself, but I've never really investigated that.

Yes, it's a fun exercise to build a tiny Linux install that's fully on the initrd. Not that you'd want to have that kind of system in daily use outside of special applications.

> I think it's even possible to embed the initrd in the kernel binary itself, but I've never really investigated that.

Yes, the kernel config has an option to embed the initrd in the kernel image. I'm not sure if there are any advantages to this.

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

#43

Earlier quoted context omitted.

You really only need two (kernel and initrd/initramfs), at least to get into a basic running state. This requires building your own initrd, of course, but it's pretty common in non-graphical Linux installers (Slackware's install media still does this, IIRC). I think it's even possible to embed the initrd in the kernel binary itself, but I've never really investigated that.

You can ditch the initrd if you compile in the kernel the drivers you need to boot the system, as a minimal example SATA/SCSI, EXT4/JFS, that usually are compiled as kernel modules.

This only works if you stick to a simple filesystem, not crypto, RAID, etc. Otherwise you'll need to have file system utilities (lvm2, mdadm, cryptsetup, zfsprogrs, etc) on the initrd to get your rootfs mounted.

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

#45

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

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

#47

Somebody correct if I am wrong, but this script somehow allows the session to live in the RAM. Once the OS is running directly from the RAM, the hard drive can be wiped and a new OS can be installed. The system is then booted to run off of the hard drive.

I feel like this is, on one hand, an amazing thing to be able to do because it removes the necessity to have IPMI to remotely re-install a system. On the other hand, this seems like it would be an incredibly easy thing to screw up and potentially leave yourself with a corrupted or unbootable system.

Hence the advice to only do this on machines where you have physical access, or at least can trigger a PXE boot via IPMI.

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

#50
post #49

I wonder if this would help me switch from Ubuntu Desktop to Ubuntu Server on my laptop that has a broken screen.

you can always connect an external screen and go from there

I can connect HDMI and can get into UBUNTU, but I cannot get into BIOS to tell it to boot from USB. If I could get that figured out- I think HDMI will activate on the boot of the ISO, but Im not sure. I even tried VGA to a monitor, but that dont show me bios either. Dont wake up till Ubuntu starts to boot.
Post reply on HN