How to remotely install Linux via SSH?

Solution 1:

The best practice for remotely installing any OS is to buy server hardware with out of band management (HP ilo, Dell drac) that lets you remotely power cycle and see the console of a server. Don't even try otherwise.

Solution 2:

I agree with the sentiment of the other answers here: Although it may be possible to install Ubuntu remotely on RHEL 3.4, you are likely going to be treading on some very thin ice.

I think the biggest problem you may have is the age of the kernel and libc on the existing system. Is that a 2.4.x-series kernel? If so, I'm not sure you'll be able to pull this off, because at some point during your install, you'll need to run tools that were compiled to run in Ubuntu's kernel and libc, and they may not function properly (or at all) on an older runtime environment. If you are not running a 2.6.x-series kernel on the remote server, I don't think you have much chance of success.

If you still think you might want to try this, there are a couple of guides I am aware of:

  • Installing new Debian systems with debootstrap, on debian-administration.org. Although it is Debian-specific, it is mostly applicable to Ubuntu as well.

  • Installing Debian GNU/Linux from a Unix/Linux System, from the Debian GNU/Linux Installation Guide. Again, Debian-specific, but mostly applicable.

Both of those guides are kind of old, so neither can be treated as anything even close to a cut-and-paste guide. I would strongly suggest following the advice of others here and do some dry runs on a local server or a VM, because there are definitely kinks and gotchas you'll need to work out before going ahead for real.


Solution 3:

Installing a new distro in place can be done, but is very challenging. It's something that you almost certainly will NOT get right the first time. In fact, you'll be luck if you get it right the third or fourth time.

Additionally, nobody here is going to be able to give you a laundry list that you can just follow and this will happen. You're going to have to experiment with different alternatives, depending on your exact disc partition and file-system layout, hardware configuration, etc.

That said, here's how I'd go about doing something like that if I had to:

  • Get a machine configured as similarly as possible to the existing machine: hard drives, network cards, disc adapters, RAM, you name it.
  • Set up this machine to mimic the current setup on that host.
  • Experiment with doing what you need to do on this test system.
  • Take copious notes on it so that you can reproduce it on the "live" system.
  • Run through these notes again on the test system before you do the final migration.

Some techniques that may be able to help you:

  • Decide if you want to install to a new partition, or try to install over the existing file-system. If you do a new partition, you can always back out by booting the old partition. However, that probably means you need to shrink the current file-system, which has to be done offline. I wrote up some notes back in 2007 when I did this.
  • You may be able to do an install to a small partition on your test machine, and then make appropriate changes such as the IP addresses and "dd" this file-system image off to use to populate the base install on the new partition. This would only be if you were using a separate partition for the new install.
  • You could instead put the root file-system in place in a sub-directory and then do something in the initrd so that it would: "cd /target; mv * oldroot; mv oldroot/newos/* ." to move all the old directories out of place and put the new ones in place. This would have to be done before the initrd does it's "pivotroot", probably right after it mounts the file-system.
  • Adding some code into the initrd scripts can allow you to do all sorts of wonderful things during the system boot. See the blog post I references above for more details.
  • Expect that you're going to fail at this. It's an extremely risky endeavor. When I did my file-system resize (mentioned above), I was shocked when it rebooted properly.
  • You'll have to decide what you want to do about the boot sectors, is it running LILO or GRUB? Do you want to try to stay with the current boot loader, or switch to 10.04's? Probably the ideal thing would be to use the existing loader to get booted into the new OS, then run "grub-install" from that OS to put the new one in place.

Good luck! You'll need it. :-)


Solution 4:

If you have a different partition you can use that partition to install in a VM that see the entire disk. As long as you do not mount the same partition in both the VM and host or play with partition table you are safe. Another way would be to boot from network and do a installation using preseed or kickstart. Experiment with a local environment before playing remotely.