We continue to put Xen on Ubuntu.
Part onePreparing the system for installing DomU
Let's start point by point.
')
1. Next, you should determine the storage location of the config. files
Configs we add in a directory
/etc/xen/config
If the config folder is not there - create.
And we do not forget to keep configs of all systems and a couple of pure templates there.
2. On what media do we have DomU - LVM or physical disk images created by dd or qemu.
Initially, I am only for LVM - and because it is faster than just images stuck in
/ dev / loop and because their backup is much simpler and more pleasant than anything that can be;)
I will dwell on this example. To whom I can, then I can supplement later with an example of working with physical
in a way.
In order to create an LVM partition, we need a separate partition on the screw drive. Desirable it
availability to think of initially and with a reserve of space, because there will be stored images of lvm and he
will not be available for storage there anything else.
Suppose we have such a partition / dev / sdb6 and its size is 270 GB.
Go to the root console (
sudo su -
) and set lvm itself
aptitude install lvm2
Next, you need to load the LVM modules:
modprobe dm_mod modprobe dm_mirror modprobe dm_snapshot
Initialize LVM support with this section.
pvcreate /dev/sdb
Create a volume group which we will call vg (virtual group)
vgcreate vg /dev/sdb
Everything, we create an image that will be visible in the system as a physical one and you can put Win XP there for example.
lvcreate -L10240M -n hdd vg
lvs
LV VG Attr LSize Origin Snap% Move Log Copy%
hdd vg -wi-a- 10.00G
Device appeared in the device list / dev / vg / hdd
Everything, you can start to put. Winchester we already have;)
3. Backup. How to do and where to fold.
The beauty of LVM is that it is quickly and painlessly backed up at any time without stopping the LVM operating system.
Suppose the backup remains with us on the screw, the options for where to put Pts are individual.
We will add in / mnt / backup
The first thing we do is a snapshot - a snapshot of the image in a “frozen” state.
lvcreate -L10G -s -n back-image /dev/vg/hdd
And then familiar to all the team dd
dd if=/dev/vg/hdd bs=1024000 | gzip -cf > /mnt/backup/hdd.gz
If after this you need to restore from backup then:
gunzip -c hdd.gz | dd of=/dev/vg/hdd bs=1024000
Then, at will, we make scripts for backup of all DomUs and enter them into cron, here everyone already chooses.
Install DomU.
So.
We have a harddrive for future WinXP virtual - / dev / vg / hdd - 10Gb
Now we need an image of Win to install or CD. Better image - more practical.
Suppose you have a WinXP license and have a disk with it.
We write the config of the future machine:
import os, re
arch = os.uname () [4]
if re.search ('64 ', arch):
arch_libdir = 'lib64'
else:
arch_libdir = 'lib'
kernel = "/ usr / lib / xen / boot / hvmloader"
builder = 'hvm'
# how much memory to allocate future machine
memory = 386
# name in xm list
name = "xp-test-1"
# number of processors with a cat, it will work
vcpus = 2
# acpi = 1
# apic = 1
# Mac address and through what he will see the network
vif = ['type = ioemu, mac = aa: 3c: 40: b0: 01: 11, bridge = xenbr0']
# physical disk (we made our cat image in lvm) and sdrom (here is the physical device cdrom of the main server)
disk = ['phy: / dev / vg / hdd, ioemu: hda, w', 'phy: / dev / cdrom, ioemu: hdc: cdrom, r']
device_model = '/ usr /' + arch_libdir + '/ xen / bin / qemu-dm'
# boot method - dc - boot by default from sdroma, if there is no boot - from the screw
boot = "dc"
# always post vnc port for access from the primary server
sdl = 0
vnc = 1
vncviewer = 1
vncpasswd = ''
ne2000 = 0
You can learn more about the config by typing
xm create --help_config
If you want to specify not a physical cdrom, but for example an image of a boot disk with the system distribution kit, then the line:
disk = [ 'phy:/dev/vg/hdd,ioemu:hda,w', 'phy:/dev/cdrom,ioemu:hdc:cdrom,r' ]
we change to
disk = [ 'phy:/dev/vg/hdd,ioemu:hda,w', 'phy:/dev/loop1,ioemu:hdc:cdrom,r' ]
having previously mounted our iso image on the virtual device / dev / loop1 (from 1 to N - depending on how many free ones there are)
Name the image winxp.hvm
Try not to use extra characters in the names of configs and machine names in the config name = "xp-test-1"
Napimer there are glitches with "_" in these places.
Enjoying free loop devices:
losetup -a
/ dev / loop4: [0801]: 5955594 (/home/backup/daily/xp_second.dd)
/ dev / loop6: [0801]: 5955586 (/home/backup/daily/arch_back.dd)
/ dev / loop7: [0801]: 5955588 (/home/backup/daily/arch_17_00.dd)
Mount image:
losetup /dev/loop1 /home/felvis/distr.iso
The manual Xen says that in the config it would be possible to specify directly the image 'file: / full / path / to / vm1disk, hdc, r'
But on bugzilla ubuntu you can find a bunch of reports on a bug that makes it impossible.
And by the way at the moment (10.28.2008) he was not fixed. So we mount in / dev / loop both cdrom disks and images of screws.
Now you can run the WinXP installation:
cd /etc/xen/config
xm create winxp.hvm
Using config file "./winxp.hvm".
VNC = 1
Started domain "xp-test-1"
xm list
Name ID Mem VCPUs State Time (s)
Domain-0 0 577 8 r ----- 186810.6
xp-test-1 1 386 2 -b ---- 15.1
If your distribution kit consists of several disks - it doesn't matter, you can re-mount the cdrom source to another disk on the fly:
xm block-configure 1 phy:/dev/null hd:cdrom r
losetup -d /dev/loop1
losetup /dev/loop1 /home/felvis/distr2.iso
xm block-configure 1 phy:/dev/loop1 hd:cdrom r
In order to get to the guest system, you need to put the VNC client:
aptitude install xtightvncviewer
After that, the virtual machine will be available on port vnc 0 (corresponding to the next raised machine by 1,2,3, etc.)
We carry out:
vncviewer :0
and if you are under X, then u will have a first-person view of Windows.
If you are not under X, but, for example, you sit through ssh - there is also a way out - Xming.
We put this program where you are sitting under win. It helps you to display GUI windows running in ssh.
We put Xming, run it.
On Ubuntu, set the environment variable:
export DISPLAY= ip:0.0
and now when you run the vncviewer command through some putty, you get a graphical window from Linux.
We finish the installation and enjoy the virtual machine.
The article was written by LiveJournal user felvis and me during the actual installation and configuration of this whole farm for production use.
Used materials from the book "Professional Xen® Virtualization" by William von Hagen and the manual from the site Xen.ru -
Read the manual .