Debian Guest Installation Using Debian Installer
Debian Installer is the standard installer used to install Debian on native systems. Debian Installer has supported netboot installation of Xen as a PV guests (both i386 and amd64) since Lenny (Debian 5.0) was released and has supported CD-ROM (and DVD, Blu-Ray etc) installations since Squeeze (Debian 6.0).
The main benefit of using Debian Installer to install a Xen guest is that you are able to use all the technologies (like pre-seeding) which you are used to using on a native system. You also end up with an installed system which is as similar as possible to a native Debian system installed via the same mechanisms. Installing a Xen guest Debian Installer produces a fully configured Debian system without the need to setup things such as /etc/fstab by hand.
A netboot installation is a quick and easy way to install Debian. You start by downloading a small (approximately 20MB) installer kernel and initrd which you boot as a PV guest. After this Debian Installer will take over and you can install the guest direct from the network. If you are only installing a single guest this has the advantage of only downloading exactly what is needed for the installation. If you are installing lots of guests then you may find it beneficial to create a local mirror (which will require a large initial bandwidth investment) or install a caching proxy such as apt-cacher to reduce the number of external downloads.
Select A Mirror
If you are not using your own mirror or a tool such as apt-cacher then you will need to choose a nearby mirror from Debian's list of worldwide mirrors. In general you should select the mirror which is nearest to you. Alternatively you can simply use the (unofficial) http://cdn.debian.net service to automatically select a nearby mirror.
The following instructions assume that you are using http://cdn.debian.net, substitute the mirror which you have selected or the name of your apt-cacher/mirror machine as appropriate.
Download Debian Installer Images
Once you have selected a mirror then you can download the Debian Installer kernel and initrd. You only need to do this once since you can reuse the same images multiple times.
Download both vmlinuz and initrd.img from here (amd64) or here (i386) and save them to your Xen system. This guide assumes you have put them in /scratch/debian/squeeze/amd64 and /scratch/debian/squeeze/i386 respectively.
These instructions assume you are installing Debian Squeeze. However you can modify the URLs to point to any release from Lenny onwards.
Create Initial Guest Configuration
For the initial boot you should configure the guest to use the vmlinux and initrd.gz which you downloaded above and with a command line suitable for using the installer. e.g.
kernel = "/scratch/debian/squeeze/amd64/vmlinuz" ramdisk = "/scratch/debian/squeeze/amd64/initrd.gz" extra = "debian-installer/exit/always_halt=true -- console=hvc0"
The rest of the guest configuration is down to you and your requirements for the guest you are installing. You would normally want to configure a disk and network device as normal. A network device with external connectivity (or connectivity to your local mirror/cache) is required for the duration of the installation process.
In order to use Debian Installer it is necessary to use the whole disk disk configuration rather than the partitions. In other words you must configure an xvda device and not xvda1, xvda2 etc. For example a complete (if rather minimal) installation time configuration might be:
name = "debian-installer"
memory = 256 disk = ['phy:/dev/VG/debian-installer,xvda,w'] vif = [' '] kernel = "/scratch/debian/squeeze/amd64/vmlinuz" ramdisk = "/scratch/debian/squeeze/amd64/initrd.gz" extra = "debian-installer/exit/always_halt=true -- console=hvc0"
At this point you should create the backing storage for the disk configuration you are using. e.g. in this case:
# lvcreate -L 4G -n debian-installer /dev/VG
See [Xen Man Pages] for more details of the guest configuration syntax.
Now that you have created the guest configuration you can start the guest and connect to its console. e.g. assuming your guest configuration file is /etc/xen/debian-installer.cfg:
# xl create -c /etc/xen/debian-installer.cfg
At this point the guest will boot and Debian Installer will start. Now you can install Debian like you normally would, perhaps following the Debian Installation Guide.
See [Xen Man Pages] for more details on the use of xl
Finalize Guest Configuration
Once installation has completed the guest will shutdown and exit. At this point you should remove the kernel, initrd and extra lines from the guest configuration and replace them with simply:
bootloader = "pygrub"
Keep the rest of the configuration file the same.
Now you can start the guest again to boot your newly installed Debian guest!
# xl create -c /etc/xen/debian-installer.cfg
You can preseed a Xen installation in the same way as a normal native install by adding the necessary directives to the extra configuration line. e.g.
extra = "debian-installer/exit/always_halt=true -- console=hvc0 auto-install/enable=true url=http://example.com/debian/squeeze.cfg"
More information on preseeding can be found in Appendix B of Debian's Installation Guide
Other Installation Methods
Debian's Xen wiki page covers several other methods of installing Xen guests, including debootstrap and xen-tools.