- How to remotely install Linux via SSH?
- Solution 2:
- Solution 3:
- Solution 4:
- Installation / OverSSH
- Caveat
- Scenario
- Preparing the Hard Disk
- Partitioning
- Creating File Systems
- The Base System
- Mounting Root
- Getting Debootstrap
- Installing the Base System
- Basic Configuration
- Set the Hostname
- fstab
- Networking
- Enter the new environment
- Change the root password
- Create a user and switch shadow password on
- Installing Packages
- Installing OpenSSH Server
- Install a Kernel
- RAID
- Reboot
- Finishing
- Generate locales
- Install some more packages
- References
How to remotely install Linux via SSH?
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.
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.
Installation / OverSSH
This is a work in progress, it is not mature yet and it may break your system!
Caveat
As you may already have guessed following this instruction may break your system and you are on your own to fix it again. apt-get install linux-image-686
Scenario
This instruction describes how to install Ubuntu on a dedicated server over ssh. I assume that your provider provides you with a rescue system from which you can boot and prepare your system. An Online replacement is possible, but it is some more work and a lot more risky if things go bad (the basic idea is to temporarily disable your swap and install a transitional system on it).
Preparing the Hard Disk
Partitioning
Use fdisk to partition your hard disk.
Remember to set the root partition bootable!
For the rest of this instruction we assume the following partition layout.
/dev/hda1 (83 Linux) - for /, /dev/hda2 (82 Linux swap) - as swap
Creating File Systems
Below is how we get our / populated with ext3.
And the same for our swap partition.
# mkswap /dev/hda2 # sync; sync; sync # swapon /dev/hda2
The Base System
Mounting Root
# mkdir /mnt/ubuntu # mount -t ext3 /dev/hda1 /mnt/ubuntu
Getting Debootstrap
Debootstrap is a collection of scripts that we will use in the next step to set up a base system. We need an appropriate version of debootstrap from http://archive.ubuntu.com/ubuntu/pool/main/d/debootstrap/ to make this work.
Make sure that binutils is installed on your system.
On an apt based system we can use dpkg to install it.
# wget http://archive.ubuntu.com/ubuntu/pool/main/d/debootstrap/debootstrap_1.0.32_all.deb # dpkg -i debootstrap_0.3.3.0ubuntu2_all.deb
If your current system is rpm based, use alien to install it or find a rpm on the web (http://azhrarn.underhanded.org/debootstrap-0.2.23-1.i386.rpm).
If your system is neither, this might work.
# mkdir /work; cd /work # wget http://archive.ubuntu.com/ubuntu/pool/main/d/debootstrap/debootstrap_0.3.3.0ubuntu2_all.deb # ar -xf debootstrap-udeb_0.3.3.0ubuntu7_i386.udeb # cd / # tar zxvf work/data.tar.gz
Installing the Base System
# /usr/sbin/debootstrap --arch i386 dapper /mnt/ubuntu http://archive.ubuntu.com/ubuntu
(arch may be different for you, e.g. amd64, hppa, ia64, powerpc, or sparc)
Basic Configuration
Set the Hostname
Change HOSTNAME to whatever suits your environment.
# echo HOSTNAME > /mnt/ubuntu/etc/hostname
fstab
Put the following in fstab:
# /etc/fstab: static file system information. # # proc /proc proc defaults 0 0 /dev/hda1 / ext3 defaults,errors=remount-ro 0 1 /dev/hda2 none swap sw 0 0
Networking
Make sure to use your network details instead.
## /mnt/ubuntu/etc/network/interfaces #Network Config: # The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eth0 iface eth0 inet static address 10.0.0.10 network 10.0.0.0 broadcast 10.0.0.255 gateway 10.0.0.1 netmask 255.255.255.0
Make sure to use your hostname and domain.
## /mnt/ubuntu/etc/hosts 127.0.0.1 localhost 127.0.0.1 hostname.domain.tld hostname
You need a valid resolv.conf with at least one valid nameserver, e.g.:
## /mnt/ubuntu/etc/resolv.conf nameserver 10.0.0.1
Enter the new environment
Before we chroot into the new environment we need to mount /proc and /dev
mount -t proc none /mnt/ubuntu/proc mount -o bind /dev /mnt/ubuntu/dev LANG= chroot /mnt/ubuntu /bin/bash
Change the root password
It is just bad if you forget this, so just .
Create a user and switch shadow password on
# dpkg-reconfigure --default-priority passwd
Installing Packages
Installing OpenSSH Server
# apt-get install openssh-server
Install a Kernel
Choose the right kernel for your architecture. I go with:
# apt-get install linux-image-686
RAID
Reboot
# umount /mnt/ubuntu/proc # umount /mnt/ubuntu/dev # umount /mnt/ubuntu # reboot
Finishing
After the reboot ssh in again.
Generate locales
# locale-gen en_US.UTF-8 # echo 'LANG="en_US.UTF-8"' >> /etc/environment # echo 'LANGUAGE="en_US:en"' >> /etc/environment
Install some more packages
apt-get install ubuntu-standard
References
- Installation/FromKnoppix
- The Gentoo Handbook contains a very good (Gentoo specific) instruction on chrooted installation procedures.
- An other instruction from the Ubuntu Installation Guide is somewhat outdated and has shortcomings related to the bootloader installation.
- HOWTO — Install Debian Onto a Remote Linux System — A Debian specific HOWTO.
Installation/OverSSH (последним исправлял пользователь cpc1-seac10-0-0-cust324 2011-05-31 16:43:31)
The material on this wiki is available under a free license, see Copyright / License for details
You can contribute to this wiki, see Wiki Guide for details