Mandrake Linux/xen Howto
1) Introduction
Xen is a virtual machine monitor for x86 hardware (runs only on i686-class CPUs), which supports running multiple guests operating systems on a single machine. Guest OSes (also called “domains”) require a modified kernel which supports Xen hypercalls in replacement to access to the physical hardware. At boot, the xen kernel is loaded (via grub) along with the guest kernel for the first domain
(called domain0). domain0 has privileges to access the physical hardware (PCI and ISA devices), administrate other domains and provide virtual devices (disks and network) to other domains. For more details, see http://www.cl.cam.ac.uk/Research/SRG/netos/xen/.
For this example, I'm using an old Pentium III 450Mhz with 128MB Ram, and a 12 Gig Hard drive. During the installation, I've created a partition 5 Gigabytes mounted on '/' for the domain0 installation. And additionally a swap partition mounted on /dev/hda5. I've left about 7 Gigabytes free to use for guest os installations. For my production servers, I use raid1 mirroring, and LVM to manage logical volumes (partitions) as it allows me to easily grow guest
filesystems as necessary. A whole book could be written on disk setup, so for this document to simplify the process I'm using a single disk.
2) Installing Mandrake 10.1 as domain0
- Install Mandrake 10.1 as you normally would with minimum packages. Make sure to install urpmi so you may add additional packages as needed.
to use my examples below you should partition your disk as follows: /dev/hda1 mounted on /, /dev/hda5 as a swap partition.
- Test your installation, make sure everything boots up normally and you have network connectivity. At this point you should have a working mandrake 10.1 system with Internet access before you continue.
- Upgrade your system! use urpmi to update your installed packages.
- Install the necessary packages for xen/xentools:
urpmi grub-0.95-7mdk python-2.3.4-6.1.101mdk libcurl3-devel-7.12.1-1.1.101mdk \
libcurl3-7.12.1-1.1.101mdk zlib1-devel-1.2.1.1-3.1.101mdk zlib1-1.2.1.1-3.1.101mdk \
bridge-utils-0.9.7-2mdk iproute2-2.6.8-3mdk python-twisted-1.3.0-2mdk
- Download one of the binaries from http://www.cl.cam.ac.uk/Research/SRG/netos/xen/downloads.html probably http://www.cl.cam.ac.uk/Research/SRG/netos/xen/downloads/xen-2.0.7-install-x86_32.tgz onto your newly installed machine:
- Extract the xen-2.0.7-install-x86_32.tgz somewhere on your filesystem (/usr/local/src is a useful place):
- Run the install.sh script that is included in the xen-2.0-install directory. This will install the domain0 kernel in /boot, as well as the start/stop scripts, libraries, xen specific tools, etc:
cd xen-2.0-install
./install.sh
- run drakboot to install grub as your bootloader. (If you selected grub as your bootloader during install you can skip this step)
- edit /boot/grub/menu.lst to add your newly installed xen kernel your menu entry should probably look pretty close to this:
title Xen 2.0 / 2.6.11.10-xen0
kernel (hd0,0)/boot/xen-2.0.7.gz dom0_mem=131072
module (hd0,0)/boot/vmlinuz-2.6.11.12-xen0 root=/dev/hda1 ro console=tty0
- set xen to start automatically:
chkconfig xend on
chkconfig xendomains on
- disable performance inhibiting libraries
mv /lib/tls /lib/tls.disabled
ldconfig
- Reboot your system and select the Xen option in the bootloader menu. When the system comes back up you should be able to use xm list and verify domain0 is started.
xm list
Name Id Mem(MB) CPU State Time(s) Console
Domain-0 0 59 0 r---- 92.0
3) Installing Mandrake 10.1 as your first guest (Unprivileged) operating system
- First we need to create a partition for the guest operating system(s). You can use drakdisk, cfdisk, parted, or anything you are comfortable with to create the partition. For the purposes of this document I've created a partition /dev/hda6 that is 2.5G, and no mount point, Type 'ext3', Formatted as 'ext3'.
- We also (optional but recommended) need to create a swap partition, for the purposes of this document I've create a partition /dev/hda7 that is 256M, no mount point, Type 'Linux swap', Formatted as 'swap'
- Now we need to copy the currently running system to the newly created partition:
mount /dev/hda6 /mnt
rsync -avDx / /mnt
cp -ar /dev/* /mnt/dev/
umount /mnt
- Create a guest configuration file
cd /etc/xen
sample /etc/xen/mdk
kernel = "/boot/vmlinuz-2.6-xenU"
memory = 32
name = "mdk"
nics = 1
dhcp="dhcp"
disk = ['phy:hda6,hda1,w',
'phy:hda7,hda5,w']
root = "/dev/hda1 ro"
hostname="thorium"
- start the guest domain
xm create mdk -c
- You should be able to login with the same accounts/passwords as you use in domain0. Your guest domain is a clone of your master domain including current updates.
- Cleanup Guest operating system (Optional):
chkconfig xend off
chkconfig xendomains off
4) Alternative installation instructions for installing Mandrake as a guest (Unprivileged) operating system
Often times it is desirable to install a different version of Mandrake as a guest operating system. This method should work with any version of Mandrake Linux and has been fully tested with 10.0, 10.1, and 10.2.
Pre installation requirements:
- create partition/lvm/vbd
- create filesystem on partition/lvm/vbd
- mount partition/lvm/vbd
(see section 3 above)
- make rpm repository directory
mkdir -p /mnt/var/lib/rpm
- Setup urpmi media for the version of Mandrake you are going to install. I won't go into details of urpmi except for the following example you to use to install your system.
# 10.2
urpmi.addmedia --update 102updates ftp://mandrakemirror/pub/linux/distributions/mandriva/official/updates/10.2/main_updates/ with media_info/hdlist.cz
urpmi.addmedia 102main ftp://mandrakemirror/pub/linux/distributions/mandriva/official/10.2/i586/media/main with media_info/hdlist.cz
urpmi.addmedia 102contrib ftp://mandrakemirror/pub/linux/distributions/mandriva/official/10.2/i586/media/contrib with media_info/hdlist.cz
- Install Guest Operating System
urpmi --media 102main,102updates,102contrib --root /mnt locales-en basesystem urpmi
You will probably be prompted for package selection options like below. Although you must select an option, since this is a guest installation and the kernel is loaded from domain0, the kernel and bootloader do not matter. curl or wget are options for the urpmi package and you can choose whichever one you are comfortable with.
One of the following packages is needed:
1- kernel-2.6.11.6mdk-1-1mdk.i586 : The Linux kernel (the core of the Linux operating system). (to install)
..........
16- kernel-xbox-2.6.11.12mdk-1-1mdk.i586 : The version of the Linux kernel used on XBox machines. (to install)
What is your choice? (1-16) 1
One of the following packages is needed:
1- curl-7.13.1-2mdk.i586 : Gets a file from a FTP, GOPHER or HTTP server (to install)
2- wget-1.9.1-5.1.102mdk.i586 : A utility for retrieving files using the HTTP or FTP protocols (to install)
What is your choice? (1-2) 2
One of the following packages is needed:
1- grub-0.95-8mdk.i586 : GRand Unified Bootloader (to install)
2- lilo-22.6.1-5mdk.i586 : The boot loader for Linux and other operating systems (to install)
What is your choice? (1-2) 1
One of the following packages is needed:
1- vim-enhanced-6.3-12mdk.i586 : A version of the VIM editor which includes recent enhancements (to install)
2- vim-X11-6.3-12mdk.i586 : The VIM version of the vi editor for the X Window System (to install)
3- vim-minimal-6.3-12mdk.i586 : A minimal version of the VIM editor (to install)
What is your choice? (1-3) 1
Post installation steps:
- copy some configuration files from domain0
cp /etc/resolv.conf /mnt/etc
- setup fstab
cp /etc/fstab /mnt/etc
- to continue our configuration let's put ourselves in a chroot envoironment
chroot /mnt
- setup inittab for console
vi /etc/inittab
Comment out all but mingetty entry for tty1
1:2345:respawn:/sbin/mingetty tty1
#2:2345:respawn:/sbin/mingetty tty2
#3:2345:respawn:/sbin/mingetty tty3
#4:2345:respawn:/sbin/mingetty tty4
#5:2345:respawn:/sbin/mingetty tty5
#6:2345:respawn:/sbin/mingetty tty6
- create shadow from passwd and an optionally existing shadow.
pwconv
- move your /lib/tls and /usr/lib/tls to /lib/tls.disabled and /usr/lib/tls.disabled, Xen will be awkwardly slow otherwise (but still work).
mv /lib/tls /lib/tls.disabled
ldconfig
- turn on networking (required for some initscripts)
edit /etc/sysconfig/network and enable networking
NETWORKING=yes
- set a root password
passwd root
- Exit the chroot shell
exit
- Unmount temporary mount point
cd /
umount /mnt
- setup xen domain startup script. This example shows using lvm partitions for guest drives.
kernel = "/boot/vmlinuz-2.6.11.12-xenU"
memory = 128
name = "neptuniam"
nics = 1
ip = "192.242.17.38"
netmask=get_current_ipmask()
gateway=get_current_ipgw()
disk = ['phy:vg0/neptuniam,hda1,w',
'phy:vg0/neptuniam-swap,hda6,w',]
root = "/dev/hda1 ro"
hostname="neptuniam"
Appendix A: Possible Errors and solutions
If you missed any of the steps you might get one or more of the following errors.
passwd: User not known to the underlying authentication module
run pwconv to creade shadow file
error: cannot open lock file /mnt//var/lib/rpm/RPMLOCK in shared mode
error: cannot open Packages database in /mnt/var/lib/rpm
unable to open rpmdb 4/4
mkdir -p /mnt/var/lib/rpm
during installation (section 4, item 6) you see the following message(s)
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
You can safely ignore these messages as they are normal (they occur during a CD installation also, but are hidden by the installer GUI)
|