Live data from Hacker News

Wipe and reinstall a running Linux system via SSH (2017)

github.com

41–50 of 81 posts

Re: Wipe and reinstall a running Linux system via SSH (2017)

#41
post #23

Earlier quoted context omitted.

It's far more generic but also practically useless for an end-user. Really, its only use seems to be for someone who is a remote sysadmin of some sort. You have to stop pretty much everything on the computer, and still go through a reboot. The only difference thing it buys you is being able to stay SSH'd at the cost of wasting so much more time and going through so much more risk and inconvenience. On Windows you'd j…

>It's far more generic but also practically useless for an end-user. Do end-users really mess with partitioning usually (outside of formatting brand new disks I suppose)? I'm not asking rhetorically, I suppose there must be a use case if MS implemented this (tricky) feature but I can't really imagine any of my non-techies friends and relative decide to shrink a partition (actually most of them probably aren't aware o…

I recently installed ubuntu and there was no warning that the previous (many years ago) functionality of a default swap sized large enough to allow for hibernation was no longer the case. I installed using defaults without much thought because of course why wouldn't hibernation be possible using the default. Now I want to resize my partitions.

Re: Wipe and reinstall a running Linux system via SSH (2017)

#42
The closest I think I came to doing this was to migrate a running Debian system from being an i386 system to being an amd64-system, in-place:

https://wiki.debian.org/CrossGrading

The first step is to update the kernel from an i386 one, so that it could run both i386 and amd64 binaries, but then you essentially overwrite every package with the version from the new architecture, and hope like hell it doesn't mess up.

At the time I had a pair of servers, a mail-host, and a web-host, and I managed to successfully upgrade both, although it was a little scary. At least I had console access if things did get horribly screwed up.

Re: Wipe and reinstall a running Linux system via SSH (2017)

#43
post #3

Earlier quoted context omitted.

I love how the first comment praises it for being "straightforward". For reference, this is how you shrink a file system on Windows: diskpart select volume C: shrink desired=4096 I guess it's nice that the Linux version lets you move the partition as well (or "shrink from behind", so to speak), but damn, "straightforward" is not a word I would have used to describe it.

The "good" Linux answer would be to do the equivalent to your script on parted. I have no idea why an explanation of how to remotely install Linux on a machine while running Linux become the accepted answer. But about Windows, last year I had to resize the partitions on my work desktop, there are enough restrictions around changing things on the disk that Windows is installed that it became a week long research task…

> I have no idea why an explanation of how to remotely install Linux [mess with partitions] on a machine while running Linux

The question was explicitly about shrinking the root filesystem without booting a livecd or any other OS.

Gparted cannot do that directly because the root filesystem cannot be unmounted, and the appropriate answer for nearly everyone else (boot from a livecd and use gparted) doesn't apply because the question explicitly bars this option.

Re: Wipe and reinstall a running Linux system via SSH (2017)

#44

The closest I think I came to doing this was to migrate a running Debian system from being an i386 system to being an amd64-system, in-place: https://wiki.debian.org/CrossGrading The first step is to update the kernel from an i386 one, so that it could run both i386 and amd64 binaries, but then you essentially overwrite every package with the version from the new architecture, and hope like hell it doesn't mess up. A…

You could first chroot to a minimal stable system then update everything without having to rely on hope so much (but yeah big updates are always "exciting" and yum/apt/etc never get it completely right)

Re: Wipe and reinstall a running Linux system via SSH (2017)

#45
> This script does not have any provisions for exiting out of the new environment back into something sane. You will have to reboot when you're done. If you get anything wrong, your machine won't boot. Tough luck.

So then "without rebooting" in the title is inaccurate, no?

I haven't studied TFA carefully. But reinstalling running Linux systems via SSH is pretty routine, no? Using debian-installer with network-console, I mean.

I occasionally reinstall remote servers with LUKS via SSH. I just login, build the installer, and reboot into it. Then I SSH to the installer, and almost complete it. Just before rebooting, I go to single-user mode, and setup dropbear in initramfs. Then I reboot.

So OK, that's two reboots, not one. And if it fails, I just reboot using the control panel. If I've really fucked up, I reinstall and try again.

Re: Wipe and reinstall a running Linux system via SSH (2017)

#46
post #34

Earlier quoted context omitted.

Does that also shrink the partition? Otherwise you're not comparing equivalent things... P.S. I realize an existence proof makes us mathematically happy, but it's a little disingenuous to suggest file system experience on Linux and Windows is comparable merely because of the existence of some uncommon file system with similar capabilities. The reality is most Linux users are on ext4 rather than on btrfs or zfs, and m…

> Does that also shrink the partition? Otherwise you're not comparing equivalent things... yes, it does. btfs is already the default in SUSE derivatives. It remains to be seen how the other distributions will handle it within the next ~3 yrs. its only just become stable enough to be usable in production.

The btrfs resize command only changes the size of the filesystem. A fdisk or similar command is needed to adjust the partition size as well.

Re: Wipe and reinstall a running Linux system via SSH (2017)

#49

I actually implemented something on an embedded linux product once: a busybox initramfs that you could boot into "recovery mode," then along with dropbear, SSH into a completely in-memory system and re-flash the entire system image without having to pop out an SD card or connect a cable for DFU. The recovery mode could even be initiated remotely, so you could re-flash a device without ever touching it. Of course you…

I've implemented something very similar for upgrading headless Linux mobile robots. One nice property of this approach is that the in-memory installer environment and associated scripts can be common between USB-based install media and a remotely-triggerable kexec type installer.

At first, it surprised me there wasn't more standard tooling out there for this kind of thing, but as I got more into it, I realised how specific to our particular needs my solution had become, and I could see how it would be hard to offer something generic that would be a good fit for a wide range of use-cases without being super-bloated.

Re: Wipe and reinstall a running Linux system via SSH (2017)

#50
post #45

> This script does not have any provisions for exiting out of the new environment back into something sane. You will have to reboot when you're done. If you get anything wrong, your machine won't boot. Tough luck. So then "without rebooting" in the title is inaccurate, no? I haven't studied TFA carefully. But reinstalling running Linux systems via SSH is pretty routine, no? Using debian-installer with network-console…

Wipe and reinstall, not reinstall and load/run. I think the title is fair.
Post reply on HN