Upgrading from Woody to Sarge: Part 1

Posted by Steve on Mon 14 Feb 2005 at 10:05

The next stable release of Debian is drawing closer than ever, so now is a good time to think about handling the migration. For servers only performing a single job such as being a gateway, or a proxy server, the upgrade should be straightforward. Other servers running multiple services are liable to have more complicated upgrades. With that in mind a good approach is to simulate the upgrade, allowing you to practise it.

qemu has been mentioned on this site before when we discussed running Microsoft Windows inside Debian. Put simply it is a virtual machine which allows you to install different operating systems isolated from your real machine (the host).

My first attempts at emulating upgrades from Woody to Sarge were conducted using user-mode-linux, but ironically this package is no longer scheduled to be included in Sarge. So I switched to running Qemu instead.

The first part of the job is to install the software if you don't have it already:

apt-get update
apt-get install qemu

Once this is done I created a 3Gb file on disk to represent the single disk drive which has Woody installed upon it:

dd of=hd.img bs=1024 seek=3000000 count=0

Once this has been carried out you will be ready to install Woody, and configure it to your liking.

By default the Debian Qemu package includes a setup script which gives your host machine a new IP address of 172.20.0.1 - this script is /etc/qemu-ifup, this executes when the virtual machine boots.

In order for your virtual machine to access the network I setup the following extra script:

#!/bin/sh

/sbin/modprobe tun
/bin/chmod 666 /dev/net/tun
/sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
/bin/echo "1" >/proc/sys/net/ipv4/ip_forward

If you run this as root before you start you will be able to give your woody installation the following network details and have it access the network:

IP address: 172.20.0.2
Gateway   : 172.20.0.1

Installing woody is fairly straightforward if you have an image to boot from, either the raw ISO image or a CD-ROM. I used the following command to execute the installer:

qemu -boot d -cdrom /dev/cdrom -hda hd.img  -monitor stdio

This reads the CDROM image from the host's CD drive, and boots from it using the 3Gb file we created as the hard drive.

The installation should be fairly straightfoward. The only issue I had was that rebooting the system following the installation resulted in the CD-ROM booting again. What I did was switch to a different virtual terminal instead of choosing the "Reboot system" from the installer - executing "shutdown" from here allowed the machine to shut down.

Once the installation has finished the command to start it up was:

qemu -boot c -hda hd.img  -monitor stdio

The difference here is that we boot from the drive, and don't include any access to the host machines CD-ROM device.

Once the sytem is up and running the X11 Windowing system can be installed and the machine setup to mirror the setup of the main machine you wish to upgrade.

To save you time I've compressed and uploaded the image to the following url, so you should be able to merely uncompress it and install additional software, please note the image is 170Mb so it will take a while to download, and when uncompressed it will be 3Gb in size:

http://people.debian.org/~skx/qemu/woody.image.bz2

To download it and run it you can use:

wget http://people.debian.org/~skx/qemu/woody.image.bz2
bunzip2 woody.image.bz2
qemu -boot c -hda woody.image -monitor stdio

This, gives you a basic installation of Woody with a root password of "root" which boots up to GDM by default and has Mozilla installed.

The next job is to install and configure any additional software you have upon your main Woody machine, the intent is to literally mirror your live system so that you can attempt to upgrade it to the Sarge release and see what problems are involved.

The simplest way to mirror a Debian machine is to make a dump of the packages which are installed, and then replace that package list upon the second machine.

To save a list of all the packages upon a machine run the following command:

dpkg --get-selections > package.list

Copy that to your new machine and run:

dpkg --set-selections < package.list
apt-get dselect-upgrade

This will cause the second machine to have the same packages as the main machine - of course the configuration settings will be different, so you will need to make those match your primary machine.

The next article in this series will cover upgrading a moderately complex machine to Sarge, and walk through the problems which were found.


This article can be found online at the Debian Administration website at the following bookmarkable URL:

This article is copyright 2005 Steve - please ask for permission to republish or translate.