Remotely upgrading a server from 32 to 64 bit linux

This post isn’t designed to be a “how to” merely an overview of how I achieved the subject. It is possible to do this without any physical intervention but in practice I have had to visit site at least once to fix a boot error on every one I have done.

Disclaimer:- When attempting this having some sort of remote access solution that will give access to the server even when it won’t boot is desirable i.e. BMC, DRAC or KVM over IP. Obviously resizing and deleting partitions and file systems is very dangerous so you need to be ultra careful and ultra sure you understand the process and exactly what you are doing at each step. It may also be helpful to draw the partition layout at each stage so you have a clear view of what is happening. Don’t come crying to me when it all blows up in your face. You have been warned!

The steps to achieve this are:-

  1. Create a minimal 64 bit ubuntu install to fit inside 512MB (I used KVM and the Ubuntu alternate installer CD as I don’t have hardware virtualisation extensions in my CPU and purged un-needed packages and the apt cache). Resize the filesystem and partition as small as possible i.e. circa 480 MB to make sure it will fit inside the target swap partition space.
  2. Replace the swap partition on the target server with the disk image you have just created using dd. Use rsync with compression to upload the disk image file to the target server and save time.
  3. Copy the kernel from the created partition into the boot partition of the target server and update Grub accordingly. Don’t forget to put the correct root option onto the kernel command line.
  4. Boot from the new kernel and what was swap partition. Normally something goes wrong after changing Grub that involves a site visit.
  5. Resize the system partition of the target server to make room for a new partition. Not forgetting to make the filesystem and partition size as small as possible to speed copying with dd.
  6. Create a new partition and use dd to copy the existing system partition to the new partition.
  7. Erase the original system partition, resize the created partition (the one that was swap) reboot and do an online resize of the file system to take advantage of the extra space.
  8. Copy data and config files from copied system partition to the new (the one that was swap).
  9. Copy users and groups from /etc/passwd /etc/group and /etc/shadow, is very useful in that regard. Manually check the files created to delete any unnecessary groups and accounts.
  10. Install needed services checking each one works correctly. Most config files should migrate directly even if from a different distro.
  11. At some stage, when you’ve established everything is working, and you don’t need any data from the old install, delete the partition the original system partition was copied to in step 6 and create a new swap partition (preferably a big one in case you need to do something like this again in future).

Any questions? No? Good!

Join the conversation


  1. Interesting post – I’ve bookmarked this one.

    I was reading about performing minimal installs to the swap space recently – it could have been something to do with setting up LVM encryption post-install. It’s something I haven’t tried yet, though, so might give it a go inside VirtualBox in case I bork anything :)

    1. If you need any specifics at any stage while you are doing it let me know. You will need a partition size of say 1024MB to start with and then when you have it installed you can start removing unnecessary packages to get the install under 512MB, then resize the filesystem and partition. Of course you don’t need to bother with that if your swap is bigger than 512MB.

Leave a comment