When I needed to migrate a production RHEL 3.4 system to Ubuntu Server 10.04 without physical access, I developed this SSH-based method that maintains system availability throughout the process. The key innovation was using the swap partition as temporary staging area.
Before beginning:
# Verify disk layout
fdisk -l
# Check network connectivity
ping -c 4 archive.ubuntu.com
# Create backup of critical data
tar czf /backup/rhel_backup.tar.gz /etc /home /var/www
On an existing Ubuntu system matching your target architecture:
# Install debootstrap if missing
sudo apt-get update && sudo apt-get install debootstrap
# Create the base system
sudo debootstrap --arch=i386 lucid /mnt/ubuntu http://old-releases.ubuntu.com/ubuntu
Using rsync over SSH with compression:
# From your workstation to the target server
rsync -avz -e ssh /mnt/ubuntu/ user@remote.server:/mnt/swap_partition/
The critical step that prevents system lockout:
# Edit /boot/grub/menu.lst
title Temporary Ubuntu Install
root (hd0,1)
kernel /boot/vmlinuz-2.6.32-21-generic root=/dev/sda2 ro single
initrd /boot/initrd.img-2.6.32-21-generic
savedefault --once
After booting into the temporary system:
# Mount original root partition
mount /dev/sda1 /mnt/original
# Rsync the complete system
rsync -a --exclude=/proc --exclude=/sys --exclude=/dev / /mnt/original/
# Chroot to finalize
chroot /mnt/original
mount -t proc proc /proc
mount -t sysfs sys /sys
Don't forget these configuration essentials:
# Reconfigure GRUB permanently
grub-install /dev/sda
update-grub
# Install missing packages
apt-get install tasksel ubuntu-standard
# Verify bootloader
dd if=/dev/sda bs=512 count=1 | xxd
If something goes wrong during the process:
# Network boot rescue option:
ipconfig eth0 192.168.1.100 netmask 255.255.255.0
tftp -g -r pxelinux.0 192.168.1.1
The entire process took approximately 2 hours for a minimal system, with additional time required for package installation and configuration. The method proved reliable across multiple test cases in virtualized environments before production deployment.
Performing a remote Linux distribution migration requires careful planning when physical access isn't available. In this case, we're upgrading from RHEL 3.4 (32-bit) to Ubuntu Server 10.04 (32-bit) entirely through SSH, where any misstep could result in an unrecoverable system.
- Another Ubuntu system for debootstrap environment
- At least 2GB free space in swap partition
- SSH access with root privileges
- Basic GRUB legacy knowledge
1. Prepare the Debootstrap Environment
On your Ubuntu helper machine:
sudo apt-get install debootstrap
mkdir /tmp/ubuntu-root
sudo debootstrap --arch=i386 lucid /tmp/ubuntu-root http://old-releases.ubuntu.com/ubuntu
2. Transfer Files to Target Server
First, identify your swap partition on RHEL:
cat /proc/swaps
# Assuming /dev/sda2 is swap
sudo swapoff /dev/sda2
mkfs.ext3 /dev/sda2
mount /dev/sda2 /mnt
Then transfer the debootstrap environment:
rsync -avz /tmp/ubuntu-root/ user@remote:/mnt/
3. Configure GRUB for Single Boot
Edit /boot/grub/menu.lst on RHEL:
title Ubuntu Temp Boot
root (hd0,1)
kernel /boot/vmlinuz-2.6.32-21-generic root=/dev/sda2 ro single
initrd /boot/initrd.img-2.6.32-21-generic
savedefault
4. Boot into Temporary Environment
After reboot, you'll be in the Ubuntu environment. Now migrate to main root:
mount /dev/sda1 /mnt/main
rsync -avz / /mnt/main/
chroot /mnt/main
mount -t proc proc /proc
mount -t sysfs sys /sys
5. Finalize Ubuntu Installation
apt-get update
tasksel install standard
apt-get install linux-image-generic grub
update-grub
- Always test in VM first with identical partition layout
- Keep SSH session alive using screen/tmux
- Have serial console access as backup if possible
- Verify kernel compatibility before final reboot
If system becomes unresponsive:
# In GRUB command line:
grub> root (hd0,0)
grub> kernel /boot/vmlinuz-2.4.21-40.EL ro root=/dev/sda1
grub> initrd /boot/initrd-2.4.21-40.EL.img
grub> boot
For modern systems, consider:
# Using AWS Systems Manager
aws ssm start-session --target i-1234567890abcdef0
# Or with PXE boot
dhclient -r && dhclient eth0