[转帖]Install Xen 4.3.1 on Ubuntu 12.04 LTS from source

2014-1-24 Nie.Meining Life

原帖地址:http://dcvan24.wordpress.com/2014/01/24/install-xen-4-3-1-on-ubuntu-12-04-lts-from-source/

转帖原因:原网址被墙了,查阅不方便。

正文开始:

-----------------------------------------------------------------------------------------------------------------------------


0. Install Xen Dependencies

1
# apt-get install bridge-utils build-essential libncurses-dev python-dev uuid uuid-dev libglib2.0-dev libyajl-dev bcc gcc-multilib iasl libpci-dev mercurial flex bison libaio-dev build-essential gettext libpixman-1-dev bin86 gawk bridge-utils iproute libcurl3 libcurl4-openssl-dev bzip2 module-init-tools transfig tgif texinfo texlive-latex-base texlive-latex-recommended texlive-fonts-extra texlive-fonts-recommended pciutils-dev mercurial make gcc libc6-dev zlib1g-dev python python-dev python-twisted libncurses5-dev patch libvncserver-dev libsdl-dev libbz2-dev e2fslibs-dev git-core uuid-dev ocaml ocaml-findlib libx11-dev bison flex xz-utils libyajl-dev

1. Download Xen Source Code

1
2
3
# git clone git://xenbits.xen.org/xen.git ~/xen
# cd ~/xen
# git checkout -b RELEASE-4.3.1 RELEASE-4.3.1

2. Compile and Install Xen from Source

1
2
3
# ./configure
# ./make -j4 dist
# ./make install

Note that the option “-j4″ tells the compiler to use 4 cores(it uses 2 cores by default).

3. Update GRUB 
Delete duplicate entries in /boot

1
2
# cd /boot
# rm -rf xen.gz xen.4.3.gz xen.4.3.1.gz xen-syms-4.3.1

Set priority for loading Xen-compatible kernel at boot

1
2
# mv /etc/grub.d/20_linux_xen /etc/grub.d/09_linux_xen
# update-grub

4. Load Xen Services at Boot

1
2
3
# update-rc.d xencommons 20 19
# update-rc.d xendomains 21 22
# update-rc.d xen-watchdog 23 22

5. Update /etc/ld.so.conf

1
# ldconfig

This step is important since the system will complain about missing library files if not do so.

6. Configure Virtual Network
Assuming we use DHCP for VMs. Modify the network configuration as follow.

1
# vi /etc/network/interfaces
1
2
3
4
5
6
7
8
9
10
11
auto eth0
iface eth0 inet manual
 
auto xenbr0
iface xenbr0 inet static
        bridge_ports eth0
        address 10.10.100.2
        netmask 255.255.255.0
        network 10.10.100.0
        broadcast 10.10.100.255
        gateway 10.10.100.1

7. Manage Storage for VMs
Assuming we use LVM to manage storage for VMs. It is suggested to spare a dedicated partition for VM storage.

1
2
# pvcreate /dev/sda3
# vgcreate vg0 /dev/sda3

Now you can find the volume group at /dev/vg0

8. Reboot

9. Create a VM for Test
Check if Dom0 is running

1
2
3
# xl list
Name                                        ID   Mem VCPUs  State   Time(s)
Domain-0                                     0 11962     8     r-----    8582.6

Check Xen’s configuration

1
# xl info

Create a logical volume(LV) for a new VM

1
lvcreate -nwin7 -L20G vg0

Create the .cfg file for the VM. Here we’ll install Window 7 32-bit on a VM.

1
# vi win7.cfg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
kernel = 'hvmloader'
builder = 'hvm'
 
## number of cores ##
vcpus = '2'
 
## memory size ##
memory = '4096'
device_model_version="qemu-xen-traditional"
 
## storage: use the LV we just created ##
disk = [
        'phy:/dev/vg0/win7,hda,w'
]
## name of the VM ##
name = 'windows'
 
## network configuration ##
vif = [ 'mac=00:16:3E:51:20:4C,bridge=xenbr0,model=e1000' ]
 
## events policy ##
on_poweroff = 'destroy'
on_reboot = 'restart'
on_crash = 'restart'
 
## boot priority ##
boot = 'dc'
acpi = '1'
apic = '1'
viridian = '1'
xen_platform_pci='1'
sdl = '0'
 
## VNC configuration ##
vnc = '1' ## 1 or larger numbers to turn on; 0 to turn off ##
vnclisten = '0.0.0.0' ## network it listens to ##
vncdisplay = '6' ## VNC port ##
vncpasswd = ''
 
stdvga = '0'
usb = '1'
usbdevice = 'tablet'

10. VIew the VM via VNC Viewer
Use a computer with GUI to do so. Assuming we use a computer with Ubuntu running on it.

We need to install a VNC viewer first. Any type of VNC viewer should work. Here we usegvncviewer.

1
# apt-get install -y gvncviewer

Then connect to the VM with it

1
# gvncviewer 10.10.100.2:6

You will get a view of the VM if everything goes smoothly. Have fun!

11. Troubleshooting

  • libxlutil.so.4.3: cannot open shared object file: No such file or directory
  • Solution:

    1
    ldconfig



发表评论:

Powered by emlog