First, some empty disk space is needed. Let’s create a logical volume for our new virtual machine:
| 
					 1 2  | 
						root@xenserver1:~# <strong>lvcreate -n testlv -L 10G vg0</strong>   Logical volume "testlv" created  | 
					
Create a filesystem on the new logical volume:
| 
					 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22  | 
						root@xenserver1:~# <strong>mke2fs -j /dev/vg0/testlv</strong> mke2fs 1.40-WIP (14-Nov-2006) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) 1310720 inodes, 2621440 blocks 131072 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=2684354560 80 block groups 32768 blocks per group, 32768 fragments per group 16384 inodes per group Superblock backups stored on blocks:         32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632 Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 25 mounts or 180 days, whichever comes first.  Use tune2fs -c or -i to override.  | 
					
Create a mount point:
| 
					 1  | 
						root@xenserver1:~# <strong>mkdir /mnt/test</strong>  | 
					
Mount the new filesystem
| 
					 1  | 
						root@xenserver1:~# <strong>mount /dev/vg0/testlv /mnt/test</strong>  | 
					
Bootstrap the new system. For this, we will use a utility called “debootstrap”, which can bootstrap a fresh Ubuntu installation easily:
| 
					 1 2  | 
						root@xenserver1:~# <strong>apt-get install debootstrap</strong> root@xenserver1:~# <strong>debootstrap feisty /mnt/test</strong>  | 
					
After the system is bootstrapped, kernel modules must be copied inside the guest system for it to be able to load them during startup:modules:
| 
					 1  | 
						root@xenserver1:~# <strong>cp -a /lib/modules/2.6.19-4-server /mnt/test/lib/modules/</strong>  | 
					
Guest system’s /etc/fstab must be created:
| 
					 1  | 
						root@xenserver1:~# <strong>nano -w /mnt/test/etc/fstab</strong>  | 
					
| 
					 1 2  | 
						proc            /proc           proc    defaults        0       0 /dev/sda1       /               ext3    defaults,errors=remount-ro 0       1  | 
					
Give the guest a hostname:
| 
					 1  | 
						root@xenserver1:~# <strong>echo "test" > /mnt/test/etc/hostname</strong>  | 
					
Umount the filesystem so that we can boot from it:
| 
					 1  | 
						root@xenserver1:~# <strong>umount /mnt/test/</strong>  | 
					
Create a Xen configuration file:
| 
					 1  | 
						root@xenserver1:/etc/xen/auto# <strong>nano -w /etc/xen/auto/test</strong>  | 
					
| 
					 1 2 3 4 5 6 7 8  | 
						kernel = "/boot/vmlinuz-2.6.19-4-server" # Your kernel image ramdisk = "/boot/initrd.img-2.6.19-4-server" # The initial ramdisk memory = 128 # Number of megabytes allocated name = "test" # Virtual machine name vcpus = 4 # Number of virtual CPUs the guest sees vif = [ 'mac=aa:00:00:00:13:13, bridge=xenbr0' ] # A network interface disk = [ 'phy:mapper/vg0-testlv,sda1,w' ] # The root disk root = "/dev/sda1 ro" # Root partition the kernel mounts first  | 
					
Boot the machine:
| 
					 1 2 3 4 5 6 7  | 
						root@xenserver1:~# <strong>xm create -c /etc/xen/auto/test</strong> Log in: Ubuntu 7.04 test tty1 test login: root  | 
					
The root password is initially empty, which is not very secure. Change root password:
| 
					 1 2 3 4  | 
						root@test:~# <strong>passwd</strong> Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully  | 
					
Configure network:
| 
					 1  | 
						root@test:~# <strong>vi /etc/network/interfaces</strong>  | 
					
| 
					 1 2 3  | 
						auto lo eth0 iface lo inet loopback iface eth0 inet dhcp  | 
					
| 
					 1  | 
						root@test:~# <strong>/etc/init.d/networking restart</strong>  | 
					
Install some useful packages:
| 
					 1 2 3 4  | 
						root@test:~# <strong>apt-get update</strong> root@test:~# <strong>apt-get install language-pack-fi</strong> root@test:~# <strong>apt-get install nano cron bash man</strong> root@test:~# <strong>apt-get install openssh-server</strong>  | 
					
That’s it! You now have a working virtual machine ready for use.