Convert a running Linux installation to Debian
|Convert a running Linux installation to Debian|
Organic Design procedure
For installs where we're starting from scratch, we can simply install a debian base-system on-site and then go through the Install a new server procedure as usual (although this is intended to become automated eventually). But for installations which are already in the field and possibly physically inaccessible, Debian can be installed from within the existing non-Debian Linux environment. If the installation is on a dedicated physical server, then the process can be carried out as explained in the section Installing Debian on an existing Linux machine from the Debian documentation.
The situation is more complex for a VPS depending on how restrictive they've made the client environments. Following is the process we've worked out for the most restrictive case where the root device is a single non-configurable partition and there is no boot loader or kernel accessible. The VPS's hosted with godaddy.com are one such environment, but we have successfully Debianised it using this process (note that you may be violating your hosts agreements and the machine will break if they push security updates and patches into the OS). The godaddy environment is a restricted Virtuozzo Red hat VPS and from the client's perspective it starts with the execution of /sbin/init from an already running "hard-wired" kernel.
Creating a Debian template
Before starting, we used a debian-chroot within the redhat VPS environment to determine the configuration necessary to get the networking, secure shell, storage and tty devices working properly. To test SSH, use a port other than 22 so that it can be tested without conflicting with the redhat's exisiting SSH session. Our template was a very minimal based on the 40MB business-card install and with no database or webserver etc, as we wanted to use the Install a new server procedure after Debianisation.
- We only included the root directories which are specific to Debian and which are not mount points such as /dev or /proc in the template structure.
- Our backups are created as an appropriate template, but the template will still need to be configured if unpacking to a new LAN or OS environment
Preparing the target environment
Before doing anything, back up any important information off the target environment because if you make any mistakes you'll probably need to reprovision the server from the hosting providers web admin interface - what's that? your provider doesn't give you that option? bail out now, its unlikely to work first time, I had to nuke this VPS three times before I got this to work, but when it did work it worked perfectly ;-)
After we had built our template it was 117MB gzipped, we downloaded it into the Redhat VPS environment, unpacked it into /debian and updated the following configuration files to the content we'd worked out in the Debian-chroot stage. Thanks to Daniel D for working out how to translate the virtuozzo network configuration to Debian's format.
auto lo iface lo inet loopback auto venet0 iface venet0 inet static address 127.0.0.1 netmask 255.255.255.255 broadcast 0.0.0.0 auto venet0:0 iface venet0:0 inet static address 18.104.22.168 netmask 255.255.255.255 broadcast 0.0.0.0 up route add -net 22.214.171.124 netmask 255.255.255.0 venet0 up route add default gw 126.96.36.199 venet0 down route del default down route del -net 188.8.131.52
nameserver 184.108.40.206 nameserver 220.127.116.11
# /etc/fstab: static file system information. # # <file system> <mount point> <type> <options> <dump> <pass> proc /proc proc defaults 0 0 none /dev/pts devpts rw 0 0
# this is for posfix, usually we're on exim4 relayhost = k2smtpout.secureserver.net
Swapping the root file structures
It's risky simply unpacking the template over the existing root stucture because some processes use directory scanning for there startup configuration like the way the processes are launched in /etc/init.d or how Apache handles enabled/installed sites and modules. So instead our process was to move the Redhat-specific root content out of the way into /redhat and move the /debian directories into root one at a time.
There are two slight hitches with this approach, firstly the mv command will be moved into /redhat/bin/mv so either make a root copy of the command, or specify the full path after /bin is moved. Secondly the locations of dynamic objects in /lib are depended upon by nearly all commands including mv, so we must handle /lib slightly differently. Here's the steps of the swapping process:
- Make a directory in root called /redhat
- Move the current root directories into /redhat except for the following:
lib boot dev initrd mnt opt proc sys tmp home
- Move all the items from /debian into root except for /lib which will be handled separately next,
- We used a PERL command to swap the /lib directories over in one go otherwise the first mv would break the interpreter making subsequent commands impossible:
perl -e "rename '/lib','/redhat/lib'; rename '/debian/lib','/lib';"
Reboot & Post-Install
- That's it! Now we just need to ensure it reboots properly,
- The first reboot should not be done from the Debian command, if you can reboot the server from your VPS web admin then do that, otherwise use the redhat one:
/redhat/sbin/shutdown -r now
- If the system comes back and you can SSH in, then you're now in your Debianised system!
- If it doesn't come back you'll probably need to reprovision the VPS environment from the hosts web admin interface and start over :-(
- Now you can follow your normal post-install procedure, such as Install a new server which will also be a good test of the new environment