Remote conversion of 32-bit CentOS 6.3 to 64-bit Ubuntu 13.10
Pretty much any Linux should be fine as long as you have suitable scratch partition for temp Ubuntu install, in this example we're re-using 6GB swap partition. Process is two step, first we do minimal 32-bit Ubuntu install over swap partition, boot system, hack it to 64-bit and finally do final 64-bit Ubuntu install over old CentOS rootfs.
# Get debootstrap mkdir -p /tmp/debootstrap cd /tmp/debootstrap wget http://archive.ubuntu.com/ubuntu/pool/main/d/debootstrap/debootstrap_1.0.53ubuntu0.1_all.deb ar -xf debootstrap_1.0.53ubuntu0.1_all.deb tar xzf data.tar.gz tar xzf control.tar.gz # Perl, GPG and keys are needed too yum install gpg perl wget "http://archive.ubuntu.com/ubuntu/pool/main/u/ubuntu-keyring/ubuntu-keyring_2011.11.21.1.tar.gz" tar xzf ubuntu-keyring_2011.11.21.1.tar.gz # Turn off swap (see /proc/swaps) swapoff /dev/sda2 # Create new rootfs mkfs.ext4 /dev/sda2 # Mount new roots mkdir -p /mnt/ubuntu32 mount /dev/sda2 /mnt/ubuntu32 # Start install of 32-bit Ubuntu DEBOOTSTRAP_DIR=/tmp/debootstrap/usr/share/debootstrap \ /tmp/debootstrap/usr/sbin/debootstrap --arch i386 \ --keyring=/tmp/debootstrap/ubuntu-keyring-2011.11.21.1/keyrings/ubuntu-archive-keyring.gpg \ saucy /mnt/ubuntu32 http://fi.archive.ubuntu.com/ubuntu/ # Configure OS cd /mnt/ubuntu32 # hostname echo "tempinstall" >etc/hostname # fstab echo "proc /proc proc defaults 0 0" >etc/fstab echo "$(blkid /dev/sda2 -o export|grep UUID) / ext4 defaults,errors=remount-ro 0 1" >>etc/fstab # network echo "auto lo" >etc/network/interfaces echo "iface lo inet loopback" >>etc/network/interfaces echo "auto eth0" >>etc/network/interfaces echo "iface eth0 inet static" >>etc/network/interfaces echo " address 192.168.8.16" >>etc/network/interfaces echo " network 192.168.8.0" >>etc/network/interfaces echo " broadcast 192.168.9.255" >>etc/network/interfaces echo " gateway 192.168.8.1" >>etc/network/interfaces echo " netmask 255.255.254.0" >>etc/network/interfaces # dns echo "nameserver 8.8.8.8" >etc/resolv.conf # Mount proc, sysfs and dev mount -t proc none /mnt/ubuntu32/proc mount -t sysfs none /mnt/ubuntu32/sys mount -o bind /dev /mnt/ubuntu32/dev # Next we chroot to temporary 32-bit Ubuntu install LANG= chroot /mnt/ubuntu32 /bin/bash # set root password passwd # Install openssh for remote access after boot apt-get update apt-get -y install openssh-server # Allow root over ssh sed -i.bak -e's/.*PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config # Install kernel apt-get -y install linux-image # When asked where grub-pc should put boot sector select all disks offered on multidisk system, with just one disk simply pick /dev/sda # exit chroot and then reboot exit rebootFor whatever reason at this point names of disks changed and disk containing root was detected as sdb. Hence change in disk names from now on
# Next we switch kernel from i386 to x64 dpkg --add-architecture amd64 apt-get update apt-get -y install linux-image:amd64 apt-get remove linux-image:i386 # Boot reboot
# Get debootstrap apt-get update apt-get -y install debootstrap # Create new bootfs and rootfs mkfs.ext4 /dev/sdb1 # boot mkfs.ext4 /dev/sdb3 # root # Mount new boot and root mkdir -p /mnt/ubuntu64 mount /dev/sdb3 /mnt/ubuntu64 mkdir -p /mnt/ubuntu64/boot mount /dev/sdb1 /mnt/ubuntu64/boot # Start install of 64-bit Ubuntu debootstrap --arch amd64 saucy /mnt/ubuntu64 http://fi.archive.ubuntu.com/ubuntu/ # Configure OS cd /mnt/ubuntu64 # hostname echo "vmbu" >etc/hostname # fstab echo "proc /proc proc defaults 0 0" >etc/fstab echo "$(blkid /dev/sdb3 -o export|grep UUID) / ext4 defaults,errors=remount-ro 0 1" >>etc/fstab echo "$(blkid /dev/sdb1 -o export|grep UUID) /boot ext4 defaults 0 2" >>etc/fstab # network echo "auto lo" >etc/network/interfaces echo "iface lo inet loopback" >>etc/network/interfaces echo "auto eth0" >>etc/network/interfaces echo "iface eth0 inet static" >>etc/network/interfaces echo " address 192.168.8.16" >>etc/network/interfaces echo " network 192.168.8.0" >>etc/network/interfaces echo " broadcast 192.168.9.255" >>etc/network/interfaces echo " gateway 192.168.8.1" >>etc/network/interfaces echo " netmask 255.255.254.0" >>etc/network/interfaces # dns echo "nameserver 8.8.8.8" >etc/resolv.conf echo "nameserver 8.8.4.4">>etc/resolv.conf # Mount proc, sysfs and dev mount -t proc none /mnt/ubuntu64/proc mount -t sysfs none /mnt/ubuntu64/sys mount -o bind /dev /mnt/ubuntu64/dev # Next we chroot to final 64-bit Ubuntu install LANG= chroot /mnt/ubuntu64 /bin/bash # set root password passwd # Install openssh for remote access after boot apt-get update apt-get -y install openssh-server # Allow root over ssh sed -i.bak -e's/.*PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config # Install kernel apt-get -y install linux-image # When asked where grub-pc should put boot sector select all disks offered on multidisk system, with just one disk simply pick /dev/sda # exit chroot and then reboot exit reboot
# Now we have our final 64-bit Ubuntu 13.10 install up and running but it still needs a bit fixing to be usable # Fix locales locale-gen en_US.UTF-8 echo 'LANG="en_US.UTF-8"' >> /etc/environment echo 'LANGUAGE="en_US:en"' >> /etc/environment # Enable swap mkswap /dev/sdb2 swapon /dev/sdb2 echo "$(blkid /dev/sdb2 -o export|grep UUID) none swap sw 0 0" >>/etc/fstab # Enable full repos cat <<_eof_>/etc/apt/sources.list deb http://fi.archive.ubuntu.com/ubuntu/ saucy main restricted deb-src http://fi.archive.ubuntu.com/ubuntu/ saucy main restricted deb http://fi.archive.ubuntu.com/ubuntu/ saucy-updates main restricted deb-src http://fi.archive.ubuntu.com/ubuntu/ saucy-updates main restricted deb http://fi.archive.ubuntu.com/ubuntu/ saucy universe deb-src http://fi.archive.ubuntu.com/ubuntu/ saucy universe deb http://fi.archive.ubuntu.com/ubuntu/ saucy-updates universe deb-src http://fi.archive.ubuntu.com/ubuntu/ saucy-updates universe deb http://fi.archive.ubuntu.com/ubuntu/ saucy multiverse deb-src http://fi.archive.ubuntu.com/ubuntu/ saucy multiverse deb http://fi.archive.ubuntu.com/ubuntu/ saucy-updates multiverse deb-src http://fi.archive.ubuntu.com/ubuntu/ saucy-updates multiverse deb http://fi.archive.ubuntu.com/ubuntu/ saucy-backports main restricted universe multiverse deb-src http://fi.archive.ubuntu.com/ubuntu/ saucy-backports main restricted universe multiverse deb http://security.ubuntu.com/ubuntu saucy-security main restricted deb-src http://security.ubuntu.com/ubuntu saucy-security main restricted deb http://security.ubuntu.com/ubuntu saucy-security universe deb-src http://security.ubuntu.com/ubuntu saucy-security universe deb http://security.ubuntu.com/ubuntu saucy-security multiverse deb-src http://security.ubuntu.com/ubuntu saucy-security multiverse _EOF_ # Install base ubuntu packages and some other useful stuff apt-get update apt-get -y install ubuntu-standard joe wget curl screen python perl mtr traceroute build-essential python-software-properties software-properties-common linux-source linux-image-generic linux-headers-generic smartmontools ntp apt-get -y dist-upgrade # Reconfigure timezone dpkg-reconfigure tzdata # Reboot one last time reboot # Whoo! We're done.
Comments
Post a Comment
Got something to say?!