All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
Reinstall OS with SSH in absence of VNC/Console and Control Panel
Hi
How should I go about reinstalling a custom OS on a VPS which only has root SSH access?
Things would have been much easier if the OS reinstall option were available in control panel. Netboot is also not feasible due to lack of VNC/Console access.
Returning the server is out of the question because of the deal I got. So, please do not suggest such.
What are my options? Is there a template that automates installation of basic OS without any user input during the setup? I have also been looking into takeover.sh but can't get chroot to work. I obviously have missed some step in following the instructions. What I have done so far:
1- Downloaded the systemrescue iso. Mounted it at /mnt/iso.
2- Created a new directory /takeover. Mounted tmpfs with 'mount tmpfs /takeover'.
3- Copied the contents of /mnt/iso and takeover-github repo into /takeover.
4- Extracted busybox such that /takeover/busybox sh worked.
5- Compiled fakeinit with 'gcc /takeover/fakeinit.c -o /takeover/fakeinit'
But when I try to finally execute 'sh /takeover/takeover.sh', I get
"chroot: failed to run command `/bin/bash’"
May be I need to setup paths for the /takeover directory so that chroot works when its in that directory. If anyone has experience with takeover.sh, please do share your opinion.
Thanks!
Edit1: I tried above on CentOS. The virtualization is KVM.
Comments
You should specify the type of virtualization and current OS and probably fs is useful too
Tbh, instead of trying to do a hackjob, easiest would be to install KVM/Proxmox and just deploy a big VM
I tried above on CentOS 7. The filesystem was ext4. While mounting the tmpfs to /takeover, I didn't specify any filesystem. The provider has since reinstalled a Debian OS on my request since I am much comfortable and familiar with it. They are apparently Ok with reinstallation request but I would feel much comfortable if that were in my hands. I will take another go at it on Debian.
I did not think of that. Will try it as a last resort as this may result in a performance hit. May be the VPS also has to support virtualization which it does not in my case.
With CentOS 7 it is easy to shrink ext4 partition, create new partition in free space, install OS onto that. If swap partition is large enough can use that instead. This is repeatable and reliable. Usually only tricky situation is UEFI boot (e.g. Oracle cloud).
The normal OS installation involves a reboot. And when that happens, the user may not be able to proceed without console/vnc for user input. The ssh connection will only appear after the installation is finished. What I am looking for is some kind of installation that completes within current ssh session and when that is finished, the server reboots to new OS and let me connect with it.
Installing onto an empty partition is the best way to do that if you don't boot from ISO.
If you want to run from RAM and install on the active partition like it sounds you are trying to do, it works but it sucks in my experience because (a) RAM is sometimes too low, (b) closing open files is a pain, etc.
But I've only done it a couple of hundred times from CentOS 7 so maybe I don't know much.
Alright. Can you please outline the steps involved if I were to go with your method? From what I gather, it involves:
1- Resize existing partition for new one.
2- Copy the OS files to the new partition
3- Change grub
4- Reboot to new OS
Yes. Depending on OS then 2-3 may be grouped into the step of installing new OS. Like say you are going from CentOS 7 to Debian onto an empty partition mounted at
/nextstage
:Did you contact the provider so they can reinstall the VM for you?
Yes. I requested them to do so
And they responded with?
They installed it. But I dont want to bother them for reinstallation everytime I tinker with configuration etc.
Well, what you have bought was probably production-ready VPS. I.e not much reinstalls, and not a tinker VPS.
Maybe ask them to bring in reinstall option into the control panel.
You can boot netboot.xyz from grub, just set it to default and pray to the gods that it boots right the first time because you won't get to repair it otherwise since you don't have VNC.
Edit: Brainfart, just realized this isn't feasible entirely due to absence of VNC,
How about building an initramfs containing an ssh server and all the tools you need to do the installation?