Debian Guest Installation Using Debian Installer

From Xen
Revision as of 11:24, 23 April 2012 by Ijc (talk | contribs) (Details of configuring, installing and finalizing when installing from ISO image.)
Jump to navigationJump to search

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.

Netboot installation

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.

Install Debian

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

CD-ROM installation

Selecting a CD/DVD/BD ISO image

Full support for installing a Xen PV guest (32 or 64 bit) from an ISO image was added to Debian in the Squeeze (6.0.0) release.

Downloads of Debian CD images are available from the Debian CD Image site. Several options are available for downloading, it is preferred to use jigdo (a tool which can reconstitute an ISO image from a Debian mirror) or BitTorrent rather than direct download of ISO (which may be throttled or otherwise slower). More info on downloading using jigdo is available on the Debian CD Jigdo page.

Debian provides several different flavours of the first ISO image, only some of which support installation as a Xen PV guest. The main two flavours which support Xen PV are:

In both cases the image supports installation of both 32 bit (i386) and 64 bit (amd64) Debian guests.

Information on verifying the authenticity of these images is available here.

If the machine on which you want to install guests has a network connection then the netinst option is preferable since it reduces the initial download and will then only download precisely what you need for your configuration. Note that if you have a network connection then booting a netboot image (as described above) is an even better option.

Having selected the appropriate first ISO you can then combine this with the images from the standard set in order to make up a complete set of Debian packages installable from ISO.

In addition to the above stable release images there are daily builds of multi-arch netinst CD images (jigdo,torrent) and weekly builds of the multi-arch DVD images (jigdo, torrent) for the testing release. Note that the testing release of Debian is by definition a work in progress and may contain transient issues etc.

Create Initial Guest Configuration

For the most part this is the same as the guest configuration for the netboot installation case discussed above (e.g. the requirement to use the whole disk partitioning scheme remains). Installation from an ISO image differs from this in the need to provide the ISO image as a device to the guest and to select the appropriate kernel from the ISO to use.

Providing the ISO image to the guest as a PV CDROM device is simply a case of including the ISO image in the disk directive of your configuration file. For example to configure a domain with /dev/xvda as a disk and /dev/xvdd as the ISO image use:

disk = ['file:/scratch/debian-6.0.4-amd64-i386-netinst.iso,xvdd:cdrom,r', 'phy:/dev/VG/debian-installer,xvda,w']

(Note: if you are using the pygrub method to boot from the ISO as described below then the CDROM device must come first as shown)

Each Debian ISO image which supports installation as a Xen PV guest contains a kernel (vmlinuz) and installer ramdisk (initrd.gz) specially for this use case. These live in /install.386/xen and /install.amd/xen for 32 and 64 bit installation respectively.

One option for booting these is to extract them from the ISO image, store them in your domain 0 filesystem and refer to them with kernel and ramdisk directives in your guest configuration file, much like the netboot case.

However it may be more convenient to use the pygrub tool to extract the correct kernel from the image. To do this first ensure that the PV CDROM device is the first device in the guest configuration disk directive and then specify pygrub as the bootloader giving the path to the kernel and ramdisk as bootloader arguments. e.g. for a 32 bit guest:

bootloader = "pygrub"
bootloader_args = "--kernel=/install.386/xen/vmlinuz --ramdisk=/install.386/xen/initrd.gz"

or for a 64 bit guest:

bootloader = "pygrub"
bootloader_args = "--kernel=/install.386/amd/vmlinuz --ramdisk=/install.amd/xen/initrd.gz"

As with the netboot install you should specify suitable command line options. e.g.:

extra = "debian-installer/exit/always_halt=true -- console=hvc0"

Therefore a complete (if minimal) example of an install time configuration booting using pyrub might be:

name = "debian-installer"

memory = 256

disk = ['file:/scratch/debian-6.0.4-amd64-i386-netinst.iso,xvdd:cdrom,r', 'phy:/dev/VG/debian-installer,xvda,w']
vif = [' ']

bootloader = "pygrub"
bootloader_args = "--kernel=/install.386/xen/vmlinuz --ramdisk=/install.386/xen/initrd.gz"
extra = "debian-installer/exit/always_halt=true -- console=hvc0"

Install Debian

Installation proceeds in the same way as with netboot, described above.

Finalize Guest Configuration

Once installation has completed the guest will shutdown and exit. At this point you should remove any bootloader_args, kernel, initrd and extra lines from the guest configuration and use 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

Advanced Options

Preseeding

You can preseed a Xen installation in the same way as a normal native install by adding the necessary command line 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.