wget http://mirror.centos.org/centos/5/os/i386/images/xen/vmlinuz -O /boot/vmlinuz-xen-install
wget http://mirror.centos.org/centos/5/os/i386/images/xen/initrd.img -O /boot/initrd-xen-install
wget http://www.grantmcwilliams.com/files/centos5-install -O /etc/xen/centos5
In this example, the kernel and initrd image will be named /boot/vmlinuz-xen-install and /boot/initrd-xen-install respectively. The third line downloads the centos5 DomU configuration file.
Example kickstart file
A kickstart file holds the instructions for installation, this one is very minimal which is handy if you would like to make copies of an image to deploy new instances rapidly. To modify the kickstart files just download them from grantmcwilliams.com and store them on a web server that you manage. Make sure that you change the "extra =" line in the Centos5 DomU config file (downloaded above) to match though.
Starting the installation
With the installation configuration set up, you can launch the domU instance:
xm create -c centos5
After the installation, the domU will be rebooted and destroyed (since that is the default action for reboots, we will change that later).
Post install configuration
Now that the installation is finished, this can be a good time to make a copy of the instance image to use as a template.
The installation configuration should now be modified for non-install use. This is the modified configuration:
wget http://www.grantmcwilliams.com/files/centos5 -O /etc/xen/centos5
This new configuration is no longer be using the dowloaded kernel and initrd images but instead boot from the DomU /boot directory. This is very handy, because this will allow you to use/manage kernels in the domU. All system updates will be handled by yum-updates.d in the DomU.
With this configuration in place, you can test this domain:
xm create -c centos5
Now that your Xen server is running you can login. The password was set using the kickstart file.
- Username: root
- Password: bogus
Add additional repositories and packages
rpm -ivh http://dag.wieers.com/rpm/packages/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
Now install additional packages and update the complete OS. In the future I'll be adding more packages to the kickstart file as I see fit.
yum install vim-enhanced
Backup Virtual Image
Before you start modifying the base CentOS image you should back it up.
cp /srv/xen/centos5.img /srv/xen/centos5-base.img
Automatically starting our new Xen virtual machine
If you would like a domain to start automatically when the (dom0) system is started, move the domain configuration to the /etc/xen/auto directory. For instance:
ln -s /etc/xen/centos5 /etc/xen/auto/centos5
This will also shut down the domain properly when the system is shut down.