Blog Code Forum

Xen

From Wiki.cyring.fr

(Difference between revisions)
Jump to: navigation, search
(Filesystems)
(SysOp user)
 
(57 intermediate revisions not shown)
Line 1: Line 1:
-
=== Installation ===
+
== Installation ==
-
==== Initialization ====
+
=== Initialization ===
-
ie. using our free partition number 3 formatted with a 6 GB Ext4 file system
+
Context:
-
===== Partitioning =====
+
# Create a SSD partition, number 3, formatted with a 6 GB Ext4 file system.
 +
# Attach an existing HDD partition named /vm to store the virtual machines.
 +
==== Partitioning ====
<syntaxhighlight lang="bash" line start="1">
<syntaxhighlight lang="bash" line start="1">
fdisk /dev/sda
fdisk /dev/sda
Line 10: Line 12:
</pre>
</pre>
-
===== Formatting =====
+
==== Formatting ====
<syntaxhighlight lang="bash" line start="2">
<syntaxhighlight lang="bash" line start="2">
mkfs.ext4 -E discard -L DEBIAN /dev/sda3
mkfs.ext4 -E discard -L DEBIAN /dev/sda3
Line 16: Line 18:
</syntaxhighlight>
</syntaxhighlight>
-
==== Requirements ====
+
=== ArchLinux as a source ===
<syntaxhighlight lang="bash" line start="1">
<syntaxhighlight lang="bash" line start="1">
pacman -S abs
pacman -S abs
Line 27: Line 29:
pacman -U debootstrap*
pacman -U debootstrap*
</syntaxhighlight>
</syntaxhighlight>
-
==== Debian ====
+
=== Debian as a host ===
<syntaxhighlight lang="bash" line start="1">
<syntaxhighlight lang="bash" line start="1">
debootstrap --arch=amd64 wheezy /mnt http://ftp.fr.debian.org/debian
debootstrap --arch=amd64 wheezy /mnt http://ftp.fr.debian.org/debian
Line 34: Line 36:
cd /dev
cd /dev
MAKEDEV generic
MAKEDEV generic
 +
cd /
 +
mkdir /vm
</syntaxhighlight>
</syntaxhighlight>
-
=== Configuration ===
+
== Configuration ==
-
==== Filesystems ====
+
=== Filesystems ===
<syntaxhighlight lang="bash" line start="1">
<syntaxhighlight lang="bash" line start="1">
nano /etc/fstab
nano /etc/fstab
Line 57: Line 61:
</pre>
</pre>
-
==== Network ====
+
=== Network ===
<syntaxhighlight lang="bash" line start="1">
<syntaxhighlight lang="bash" line start="1">
nano /etc/network/interfaces
nano /etc/network/interfaces
</syntaxhighlight>
</syntaxhighlight>
<pre>
<pre>
-
auto lo
+
auto lo eth0 xenbr0
iface lo inet loopback
iface lo inet loopback
-
auto eth0
 
iface eth0 inet static
iface eth0 inet static
     address 192.168.1.101
     address 192.168.1.101
Line 70: Line 73:
     netmask 255.255.255.0
     netmask 255.255.255.0
     gateway 192.168.1.1
     gateway 192.168.1.1
-
iface br0 inet static
+
iface xenbr0 inet static
     bridge_ports none
     bridge_ports none
     address 192.168.1.199
     address 192.168.1.199
Line 91: Line 94:
127.0.0.1 XEN
127.0.0.1 XEN
</pre>
</pre>
-
==== Kernel ====
+
 
 +
=== Kernel ===
<syntaxhighlight lang="bash" line start="1">
<syntaxhighlight lang="bash" line start="1">
nano /etc/modprobe.d/blacklist.conf
nano /etc/modprobe.d/blacklist.conf
Line 100: Line 104:
blacklist bluetooth
blacklist bluetooth
</pre>
</pre>
-
==== Packages ====
+
=== Packages ===
<syntaxhighlight lang="bash" line start="1">
<syntaxhighlight lang="bash" line start="1">
nano /etc/apt/sources.list
nano /etc/apt/sources.list
Line 110: Line 114:
aptitude update
aptitude update
</syntaxhighlight>
</syntaxhighlight>
-
==== Localization ====
+
=== Localization ===
<syntaxhighlight lang="bash" line start="1">
<syntaxhighlight lang="bash" line start="1">
aptitude install locales
aptitude install locales
Line 117: Line 121:
dpkg-reconfigure console-data
dpkg-reconfigure console-data
</syntaxhighlight>
</syntaxhighlight>
-
==== Defaults ====
+
=== Defaults ===
-
===== Locale =====
+
==== Locale ====
<syntaxhighlight lang="bash" line start="1">
<syntaxhighlight lang="bash" line start="1">
nano /etc/default/locale
nano /etc/default/locale
Line 125: Line 129:
LANG=en_US.UTF-8
LANG=en_US.UTF-8
</pre>
</pre>
-
===== Keyboard =====
+
==== Keyboard ====
<syntaxhighlight lang="bash" line start="1">
<syntaxhighlight lang="bash" line start="1">
nano /etc/default/keyboard
nano /etc/default/keyboard
Line 133: Line 137:
XKBLAYOUT="fr"
XKBLAYOUT="fr"
</pre>
</pre>
-
===== tmp filesystem =====
+
==== tmp filesystem ====
<syntaxhighlight lang="bash" line start="1">
<syntaxhighlight lang="bash" line start="1">
nano /etc/default/tmpfs
nano /etc/default/tmpfs
Line 140: Line 144:
RAMTMP=yes
RAMTMP=yes
</pre>
</pre>
-
===== HDD temperature =====
+
==== HDD temperature ====
<syntaxhighlight lang="bash" line start="1">
<syntaxhighlight lang="bash" line start="1">
nano /etc/default/tmpfs
nano /etc/default/tmpfs
Line 148: Line 152:
DISKS="/dev/sdb"
DISKS="/dev/sdb"
</pre>
</pre>
-
===== rcS =====
+
==== rcS ====
<syntaxhighlight lang="bash" line start="1">
<syntaxhighlight lang="bash" line start="1">
nano /etc/default/rcS
nano /etc/default/rcS
Line 155: Line 159:
TMPTIME=-1
TMPTIME=-1
</pre>
</pre>
 +
=== Boot Manager ===
 +
==== SysLinux ====
 +
<syntaxhighlight lang="bash" line start="1">
 +
exit
 +
mkdir /boot/Debian
 +
cp /mnt/boot/vmlinuz-3.2.0-3-amd64 /boot/Debian/
 +
cp /mnt/boot/initrd.img-3.2.0-3-amd64 /boot/Debian/
 +
ln -s /boot/Debian/vmlinuz-3.2.0-3-amd64 /boot/Debian/vmlinuz
 +
ln -s /boot/Debian/initrd.img-3.2.0-3-amd64 /boot/Debian/initrd.img
 +
nano /boot/syslinux/syslinux.cfg
 +
</syntaxhighlight>
 +
<small><pre>
 +
LABEL debian
 +
MENU LABEL De^bian Linux
 +
LINUX ../Debian/vmlinuz
 +
APPEND root=/dev/sda3 ro quiet elevator=noop nmi_watchdog=0 vga=0
 +
INITRD ../Debian/initrd.img
 +
</pre></small>
 +
==== Reboot to Debian ====
 +
<syntaxhighlight lang="bash" line start="1">
 +
shutdown -r now
 +
</syntaxhighlight>
 +
=== Xorg ===
 +
<syntaxhighlight lang="bash" line start="1">
 +
aptitude install xfce4
 +
wget http://us.download.nvidia.com/XFree86/Linux-x86_64/304.60/NVIDIA-Linux-x86_64-304.60.run
 +
chmod +x NVIDIA-Linux-x86_64-304.60.run
 +
./NVIDIA-Linux-x86_64-304.60.run
 +
nvidia-xconfig
 +
</syntaxhighlight>
 +
<pre>
 +
Section "Monitor"
 +
    Identifier    "Monitor0"
 +
    VendorName    "Dell"
 +
    ModelName      "U2711"
 +
    Option        "DPMS"
 +
EndSection
-
=== XEN ===
+
Section "Device"
-
==== Deployment ====
+
    Identifier    "Device0"
 +
    Driver        "nvidia"
 +
    VendorName    "NVIDIA Corporation"
 +
EndSection
 +
</pre>
 +
<syntaxhighlight lang="bash" line start="6">
 +
aptitude install chromium
 +
aptitude install lightdm lightdm-gtk-greeter
 +
echo "/usr/sbin/lightdm" > /etc/X11/default-display-manager
 +
</syntaxhighlight>
 +
=== SysOp user ===
 +
<syntaxhighlight lang="bash" line start="1">
 +
adduser --gid 100 sysop
 +
mkdir /home/sysop/tmp
 +
ln -fs /home/sysop/tmp /home/sysop/.cache
 +
nano /etc/X11/Xsession
 +
</syntaxhighlight>
 +
<pre>
 +
ERRFILE=$HOME/tmp/.xsession-errors
 +
</pre>
 +
<syntaxhighlight lang="bash" line start="5">
 +
nano /etc/fstab
 +
</syntaxhighlight>
 +
<pre>
 +
# /etc/fstab
 +
#
 +
# <file system>          <dir>          <type> <options>                    <dump> <pass>
 +
 
 +
tmpfs                    /home/sysop/tmp tmpfs  size=2048M                  0      0
 +
</pre>
 +
 
 +
== XEN ==
 +
=== Deployment ===
<syntaxhighlight lang="bash" line start="1">
<syntaxhighlight lang="bash" line start="1">
aptitude install xen-linux-system-amd64
aptitude install xen-linux-system-amd64
Line 163: Line 236:
aptitude install xen-tools
aptitude install xen-tools
</syntaxhighlight>
</syntaxhighlight>
-
 
+
=== Append Boot Manager ===
-
==== Boot Manager ====
+
==== Copy fresh files ====
-
===== Files =====
+
<syntaxhighlight lang="bash" line start="1">
<syntaxhighlight lang="bash" line start="1">
-
exit
 
ln -s /usr/lib/syslinux/mboot.c32 /boot/syslinux/mboot.c32
ln -s /usr/lib/syslinux/mboot.c32 /boot/syslinux/mboot.c32
-
mkdir /boot/Debian
 
cp /mnt/boot/xen-4.1-amd64.gz /boot/Debian/
cp /mnt/boot/xen-4.1-amd64.gz /boot/Debian/
cp /mnt/boot/vmlinuz-3.2.0-3-amd64 /boot/Debian/
cp /mnt/boot/vmlinuz-3.2.0-3-amd64 /boot/Debian/
Line 175: Line 245:
ln -s /boot/Debian/xen-4.1-amd64.gz /boot/Debian/xen.gz
ln -s /boot/Debian/xen-4.1-amd64.gz /boot/Debian/xen.gz
ln -s /boot/Debian/vmlinuz-3.2.0-3-amd64 /boot/Debian/vmlinuz
ln -s /boot/Debian/vmlinuz-3.2.0-3-amd64 /boot/Debian/vmlinuz
-
ln -s /boot/Debian/vmlinuz-3.2.0-3-amd64 /boot/Debian/initrd.img
+
ln -s /boot/Debian/initrd.img-3.2.0-3-amd64 /boot/Debian/initrd.img
</syntaxhighlight>
</syntaxhighlight>
-
===== SysLinux =====
+
==== SysLinux ====
<syntaxhighlight lang="bash" line start="1">
<syntaxhighlight lang="bash" line start="1">
nano /boot/syslinux/syslinux.cfg
nano /boot/syslinux/syslinux.cfg
</syntaxhighlight>
</syntaxhighlight>
-
<pre>
+
<small><pre>
-
LABEL debian
+
-
MENU LABEL De^bian Linux
+
-
LINUX ../Debian/vmlinuz
+
-
APPEND root=/dev/sda3 ro quiet elevator=noop nmi_watchdog=0 vga=0
+
-
INITRD ../Debian/initrd.img
+
-
 
+
LABEL xen
LABEL xen
MENU LABEL Debian ^Xen
MENU LABEL Debian ^Xen
KERNEL mboot.c32
KERNEL mboot.c32
-
APPEND ../Debian/xen.gz --- ../Debian/vmlinuz root=/dev/sda3 ro quiet elevator=noop --- ../Debian/initrd.img
+
APPEND ../Debian/xen.gz dom0_mem=512M,max:512M dom0_max_vcpus=1-2 dom0_vcpus_pin=1 --- ../Debian/vmlinuz root=/dev/sda3 ro quiet elevator=noop --- ../Debian/initrd.img
-
</pre>
+
</pre></small>
-
<syntaxhighlight lang="bash" line start="2">
+
=== Reboot to XEN ===
 +
<syntaxhighlight lang="bash" line start="1">
shutdown -r now
shutdown -r now
</syntaxhighlight>
</syntaxhighlight>
-
==== Testing ====
+
 
 +
=== Testing ===
<syntaxhighlight lang="bash" line start="1">
<syntaxhighlight lang="bash" line start="1">
-
/usr/sbin/xentop
+
xentop
</syntaxhighlight>
</syntaxhighlight>
<small><pre>
<small><pre>
Line 209: Line 275:
 +
  Delay  Networks  vBds  Tmem  VCPUs  Repeat header  Sort order  Quit 
 +
</pre>
 +
</small>
 +
=== Virtual Machine Manager ===
 +
==== First VM ====
 +
* Prepare the VM directory
 +
<syntaxhighlight lang="bash" line start="1">
 +
ifup xenbr0
 +
brctl show
 +
cd /vm
 +
mkdir XEN
 +
chgrp users XEN
 +
chmod g+w XEN
 +
cd
 +
nano /etc/xen-tools/xen-tools.conf
 +
</syntaxhighlight>
 +
<pre>
 +
dir = /vm/XEN
 +
</pre>
 +
===== Create a Debian VM =====
 +
<syntaxhighlight lang="bash" line start="1">
 +
xen-create-image --hostname VPC1 --ip 192.168.1.201 --vcpus 2 --dist wheezy
 +
</syntaxhighlight>
 +
<small><pre>
 +
...
 +
General Information
 +
--------------------
 +
Hostname      :  VPC1
 +
Distribution  :  wheezy
 +
Mirror        :  http://ftp.fr.debian.org/debian
 +
Partitions    :  swap            128Mb (swap)
 +
                  /              4Gb  (ext3)
 +
Image type    :  sparse
 +
Memory size    :  128Mb
 +
Kernel path    :  /boot/vmlinuz-3.2.0-3-amd64
 +
Initrd path    :  /boot/initrd.img-3.2.0-3-amd64
 +
...
 +
Logfile produced at:
 +
/var/log/xen-tools/VPC1.log
 +
Installation Summary
 +
---------------------
 +
Hostname        :  VPC1
 +
Distribution    :  wheezy
 +
IP-Address(es)  :  192.168.1.201
 +
RSA Fingerprint :  07:04:0e:08:0c:01:08:0b:0c:03:09:07:00:08:01:02
 +
Root Password  :  xXxXxXxX
 +
</pre></small>
 +
* Define Video & Audio features
 +
<syntaxhighlight lang="bash" line start="2">
 +
nano /etc/xen/VPC1.cfg
 +
</syntaxhighlight>
 +
<pre>
 +
#
 +
#  Graphics and Audio
 +
#
 +
stdvga      = '1'
 +
videoram    = '16'
 +
</pre>
 +
===== Start the new VM =====
 +
<syntaxhighlight lang="bash" line start="1">
 +
xm create /etc/xen/VPC1.cfg
 +
</syntaxhighlight>
 +
<small><pre>
 +
Using config file "/etc/xen/VPC1.cfg".
 +
Started domain VPC1 (id=3)
 +
</pre></small>
 +
===== List any running VM =====
 +
<syntaxhighlight lang="bash" line start="1">
 +
xm list
 +
</syntaxhighlight>
 +
<small><pre>
 +
Name                                        ID  Mem VCPUs      State  Time(s)
 +
Domain-0                                    0  4902    8    r-----    101.5
 +
VPC1                                        3  128    2    -b----      2.4
 +
</pre></small>
 +
===== Take control of the VM =====
 +
* Using the console (''press'' CTRL+] ''to exit'')
 +
<syntaxhighlight lang="bash" line start="1">
 +
xm console 3
 +
</syntaxhighlight>
 +
* Using ssh to remotely connect
 +
<syntaxhighlight lang="bash" line start="2">
 +
ssh root@VPC1
 +
</syntaxhighlight>
 +
===== Windowing =====
 +
* Inside the VM, configure an Internet box
 +
<syntaxhighlight lang="bash" line start="1">
 +
aptitude install xorg
 +
dpkg-reconfigure x11-common
 +
aptitude install dbus
 +
aptitude install twm
 +
echo RandomPlacement >>  /etc/X11/twm/system.twmrc
 +
echo 'NoTitle { chromium }' >>  /etc/X11/twm/system.twmrc
 +
aptitude install chromium
 +
adduser --gid 100 cyring
 +
exit
 +
</syntaxhighlight>
 +
* Reconnect as a regular user
 +
<syntaxhighlight lang="bash" line start="1">
 +
ssh cyring:VPC1
 +
echo "chromium &" > .xinitrc
 +
echo "exec twm" >> .xinitrc
 +
startx
 +
</syntaxhighlight>
 +
===== Stop the VM =====
 +
* Nicely shut down the VM
 +
<syntaxhighlight lang="bash" line start="1">
 +
xm shutdown 3
 +
</syntaxhighlight>
 +
* Remove the VM from the managed environment.
 +
<syntaxhighlight lang="bash" line start="2">
 +
xm delete VPC1
 +
</syntaxhighlight>
 +
===== Lost password ! =====
 +
* Mount the VM filesystem
 +
<syntaxhighlight lang="bash" line start="1">
 +
mount /vm/XEN/domains/VPC1/disk.img /mnt
 +
chroot /mnt
 +
</syntaxhighlight>
 +
* ''Inside the VM''
 +
<syntaxhighlight lang="bash" line start="3">
 +
passwd
 +
exit
 +
</syntaxhighlight>
 +
* ''Back to back''
 +
<syntaxhighlight lang="bash" line start="5">
 +
umount /vm/XEN/domains/VPC1/disk.img
 +
</syntaxhighlight>
-
 
+
==== Virt-Manager GUI ====
-
 
+
-
  Delay  Networks  vBds  Tmem  VCPUs  Repeat header  Sort order  Quit 
+
-
</pre>
+
-
</small>
+
-
 
+
-
==== Virtual Machine Manager ====
+
-
===== X11 =====
+
<syntaxhighlight lang="bash" line start="1">
<syntaxhighlight lang="bash" line start="1">
-
wget http://us.download.nvidia.com/XFree86/Linux-x86_64/304.60/NVIDIA-Linux-x86_64-304.60.run
+
aptitude install virt-manager
-
chmod +x NVIDIA-Linux-x86_64-304.60.run
+
# usermod -a -G libvirt sysop
-
./NVIDIA-Linux-x86_64-304.60.run
+
mkdir -p /vm/XEN/libvirt/images
-
nvidia-xconfig
+
virsh pool-edit default
</syntaxhighlight>
</syntaxhighlight>
<pre>
<pre>
-
Section "Monitor"
+
     <path>/vm/XEN/libvirt/images</path>
-
     Identifier    "Monitor0"
+
-
    VendorName    "Dell"
+
-
    ModelName      "U2711"
+
-
    Option        "DPMS"
+
-
EndSection
+
-
 
+
-
Section "Device"
+
-
    Identifier    "Device0"
+
-
    Driver        "nvidia"
+
-
    VendorName    "NVIDIA Corporation"
+
-
EndSection
+
</pre>
</pre>
 +
:''Pool default XML configuration edited.''
<syntaxhighlight lang="bash" line start="5">
<syntaxhighlight lang="bash" line start="5">
-
aptitude install xfce4
+
mkdir -p /vm/XEN/libvirt/qemu/dump
-
aptitude install lightdm lightdm-gtk-greeter
+
nano /etc/libvirt/qemu.conf
-
echo "/usr/sbin/lightdm" > /etc/X11/default-display-manager
+
-
nano /etc/X11/Xsession
+
</syntaxhighlight>
</syntaxhighlight>
<pre>
<pre>
-
ERRFILE=$HOME/tmp/.xsession-errors
+
auto_dump_path = "/vm/XEN/libvirt/qemu/dump"
</pre>
</pre>
-
 
+
<syntaxhighlight lang="bash" line start="7">
-
===== GUI =====
+
nano /etc/xen/xend-config.sxp
-
<syntaxhighlight lang="bash" line start="1">
+
</syntaxhighlight>
-
aptitude install virt-manager
+
<pre>
-
usermod -a -G libvirt LOGIN
+
(xend-unix-server yes)
 +
</pre>
 +
* virt-manager & Debian Wheezy packages are broken : some paths to libraries are invalid
 +
<syntaxhighlight lang="bash" line start="8">
 +
# mkdir -p /usr/lib64/xen/bin
 +
# ln -s /usr/lib/xen-4.1/bin/qemu-dm /usr/lib64/xen/bin/qemu-dm
 +
# ln -s /usr/lib/xen-4.1 /usr/lib/xen-default
 +
service xen restart
 +
virt-manager
</syntaxhighlight>
</syntaxhighlight>

Latest revision as of 19:38, 23 October 2012

Contents

Installation

Initialization

Context:

  1. Create a SSD partition, number 3, formatted with a 6 GB Ext4 file system.
  2. Attach an existing HDD partition named /vm to store the virtual machines.

Partitioning

  1. fdisk /dev/sda
n 3 [enter] +6G

Formatting

  1. mkfs.ext4 -E discard -L DEBIAN /dev/sda3
  2. mount /dev/disk/by-label/DEBIAN /mnt

ArchLinux as a source

  1. pacman -S abs
  2. pacman -S base-devel
  3. abs
  4. mkdir /tmp/debootstrap
  5. cd /tmp/debootstrap
  6. wget https://aur.archlinux.org/packages/de/debootstrap/PKGBUILD
  7. makepkg -s
  8. pacman -U debootstrap*

Debian as a host

  1. debootstrap --arch=amd64 wheezy /mnt http://ftp.fr.debian.org/debian
  2. LANG=C chroot /mnt /bin/bash
  3. export TERM=xterm-color
  4. cd /dev
  5. MAKEDEV generic
  6. cd /
  7. mkdir /vm

Configuration

Filesystems

  1. nano /etc/fstab
# /etc/fstab
#
# <file system>           <dir>    <type> <options>                           <dump> <pass>

/dev/disk/by-label/DEBIAN /        ext4   discard,noatime,nodiratime,defaults 0      1

proc                      /proc    proc   defaults                            0      0
devpts                    /dev/pts devpts defaults                            0      0
shm                       /dev/shm tmpfs  nodev,nosuid                        0      0
tmpfs                     /tmp     tmpfs  size=2048M                          0      0
tmpfs                     /var/log tmpfs  size=64M                            0      0

/dev/disk/by-label/VM     /vm      ext4   defaults                            0      0

Network

  1. nano /etc/network/interfaces
auto lo eth0 xenbr0
iface lo inet loopback
iface eth0 inet static
    address 192.168.1.101
    network 192.168.1.0
    netmask 255.255.255.0
    gateway 192.168.1.1
iface xenbr0 inet static
    bridge_ports none
    address 192.168.1.199
    broadcast 192.168.1.255
    netmask 255.255.255.0
    gateway 192.168.1.1
  1. nano /etc/resolv.conf
nameserver 192.168.1.1
  1. echo XEN > /etc/hostname
  2. nano /etc/hosts
127.0.0.1	localhost
127.0.0.1	XEN

Kernel

  1. nano /etc/modprobe.d/blacklist.conf
blacklist pcspkr
blacklist acpi_cpufreq
blacklist bluetooth

Packages

  1. nano /etc/apt/sources.list
deb http://ftp.fr.debian.org/debian wheezy main non-free
  1. aptitude update

Localization

  1. aptitude install locales
  2. dpkg-reconfigure locales
  3. aptitude install console-data
  4. dpkg-reconfigure console-data

Defaults

Locale

  1. nano /etc/default/locale
LANG=en_US.UTF-8

Keyboard

  1. nano /etc/default/keyboard
XKBMODEL="pc105"
XKBLAYOUT="fr"

tmp filesystem

  1. nano /etc/default/tmpfs
RAMTMP=yes

HDD temperature

  1. nano /etc/default/tmpfs
RUN_DAEMON="true"
DISKS="/dev/sdb"

rcS

  1. nano /etc/default/rcS
TMPTIME=-1

Boot Manager

SysLinux

  1. exit
  2. mkdir /boot/Debian
  3. cp /mnt/boot/vmlinuz-3.2.0-3-amd64 /boot/Debian/
  4. cp /mnt/boot/initrd.img-3.2.0-3-amd64 /boot/Debian/
  5. ln -s /boot/Debian/vmlinuz-3.2.0-3-amd64 /boot/Debian/vmlinuz
  6. ln -s /boot/Debian/initrd.img-3.2.0-3-amd64 /boot/Debian/initrd.img
  7. nano /boot/syslinux/syslinux.cfg
LABEL debian
	MENU LABEL De^bian Linux
	LINUX ../Debian/vmlinuz
	APPEND root=/dev/sda3 ro quiet elevator=noop nmi_watchdog=0 vga=0
	INITRD ../Debian/initrd.img

Reboot to Debian

  1. shutdown -r now

Xorg

  1. aptitude install xfce4
  2. wget http://us.download.nvidia.com/XFree86/Linux-x86_64/304.60/NVIDIA-Linux-x86_64-304.60.run
  3. chmod +x NVIDIA-Linux-x86_64-304.60.run
  4. ./NVIDIA-Linux-x86_64-304.60.run
  5. nvidia-xconfig
Section "Monitor"
    Identifier     "Monitor0"
    VendorName     "Dell"
    ModelName      "U2711"
    Option         "DPMS"
EndSection

Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
EndSection
  1. aptitude install chromium
  2. aptitude install lightdm lightdm-gtk-greeter
  3. echo "/usr/sbin/lightdm" > /etc/X11/default-display-manager

SysOp user

  1. adduser --gid 100 sysop
  2. mkdir /home/sysop/tmp
  3. ln -fs /home/sysop/tmp /home/sysop/.cache
  4. nano /etc/X11/Xsession
ERRFILE=$HOME/tmp/.xsession-errors
  1. nano /etc/fstab
# /etc/fstab
#
# <file system>           <dir>           <type> <options>                    <dump> <pass>

tmpfs                     /home/sysop/tmp tmpfs  size=2048M                   0      0

XEN

Deployment

  1. aptitude install xen-linux-system-amd64
  2. aptitude install xen-hypervisor-4.1-amd64
  3. aptitude install xen-tools

Append Boot Manager

Copy fresh files

  1. ln -s /usr/lib/syslinux/mboot.c32 /boot/syslinux/mboot.c32
  2. cp /mnt/boot/xen-4.1-amd64.gz /boot/Debian/
  3. cp /mnt/boot/vmlinuz-3.2.0-3-amd64 /boot/Debian/
  4. cp /mnt/boot/initrd.img-3.2.0-3-amd64 /boot/Debian/
  5. ln -s /boot/Debian/xen-4.1-amd64.gz /boot/Debian/xen.gz
  6. ln -s /boot/Debian/vmlinuz-3.2.0-3-amd64 /boot/Debian/vmlinuz
  7. ln -s /boot/Debian/initrd.img-3.2.0-3-amd64 /boot/Debian/initrd.img

SysLinux

  1. nano /boot/syslinux/syslinux.cfg
LABEL xen
	MENU LABEL Debian ^Xen
	KERNEL mboot.c32
	APPEND ../Debian/xen.gz dom0_mem=512M,max:512M dom0_max_vcpus=1-2 dom0_vcpus_pin=1 --- ../Debian/vmlinuz root=/dev/sda3 ro quiet elevator=noop --- ../Debian/initrd.img

Reboot to XEN

  1. shutdown -r now

Testing

  1. xentop
xentop - 14:55:16   Xen 4.1.3
1 domains: 1 running, 0 blocked, 0 paused, 0 crashed, 0 dying, 0 shutdown
Mem: 6282360k total, 5093488k used, 1188872k free    CPUs: 8 @ 3210MHz
      NAME  STATE   CPU(sec) CPU(%)     MEM(k) MEM(%)  MAXMEM(k) MAXMEM(%) VCPUS NETS NETTX(k) NETRX(k) VBDS   VBD_OO   VBD_RD   VBD_WR  VBD_RSECT  VBD_WSECT SSID
  Domain-0 -----r        491    1.7    5020324   79.9   no limit       n/a     8    0        0        0    0        0        0        0          0          0 0



  Delay  Networks  vBds  Tmem  VCPUs  Repeat header  Sort order  Quit  

Virtual Machine Manager

First VM

  • Prepare the VM directory
  1. ifup xenbr0
  2. brctl show
  3. cd /vm
  4. mkdir XEN
  5. chgrp users XEN
  6. chmod g+w XEN
  7. cd
  8. nano /etc/xen-tools/xen-tools.conf
dir = /vm/XEN
Create a Debian VM
  1. xen-create-image --hostname VPC1 --ip 192.168.1.201 --vcpus 2 --dist wheezy
...
General Information
--------------------
Hostname       :  VPC1
Distribution   :  wheezy
Mirror         :  http://ftp.fr.debian.org/debian
Partitions     :  swap            128Mb (swap)
                  /               4Gb   (ext3)
Image type     :  sparse
Memory size    :  128Mb
Kernel path    :  /boot/vmlinuz-3.2.0-3-amd64
Initrd path    :  /boot/initrd.img-3.2.0-3-amd64
...
Logfile produced at:
	 /var/log/xen-tools/VPC1.log

Installation Summary
---------------------
Hostname        :  VPC1
Distribution    :  wheezy
IP-Address(es)  :  192.168.1.201 
RSA Fingerprint :  07:04:0e:08:0c:01:08:0b:0c:03:09:07:00:08:01:02
Root Password   :  xXxXxXxX
  • Define Video & Audio features
  1. nano /etc/xen/VPC1.cfg
#
#  Graphics and Audio
#
stdvga      = '1'
videoram    = '16'
Start the new VM
  1. xm create /etc/xen/VPC1.cfg
Using config file "/etc/xen/VPC1.cfg".
Started domain VPC1 (id=3)
List any running VM
  1. xm list
Name                                        ID   Mem VCPUs      State   Time(s)
Domain-0                                     0  4902     8     r-----    101.5
VPC1                                         3   128     2     -b----      2.4
Take control of the VM
  • Using the console (press CTRL+] to exit)
  1. xm console 3
  • Using ssh to remotely connect
  1. ssh root@VPC1
Windowing
  • Inside the VM, configure an Internet box
  1. aptitude install xorg
  2. dpkg-reconfigure x11-common
  3. aptitude install dbus
  4. aptitude install twm
  5. echo RandomPlacement >>  /etc/X11/twm/system.twmrc
  6. echo 'NoTitle { chromium }' >>  /etc/X11/twm/system.twmrc
  7. aptitude install chromium
  8. adduser --gid 100 cyring
  9. exit
  • Reconnect as a regular user
  1. ssh cyring:VPC1
  2. echo "chromium &" > .xinitrc
  3. echo "exec twm" >> .xinitrc
  4. startx
Stop the VM
  • Nicely shut down the VM
  1. xm shutdown 3
  • Remove the VM from the managed environment.
  1. xm delete VPC1
Lost password !
  • Mount the VM filesystem
  1. mount /vm/XEN/domains/VPC1/disk.img /mnt
  2. chroot /mnt
  • Inside the VM
  1. passwd
  2. exit
  • Back to back
  1. umount /vm/XEN/domains/VPC1/disk.img

Virt-Manager GUI

  1. aptitude install virt-manager
  2. # usermod -a -G libvirt sysop
  3. mkdir -p /vm/XEN/libvirt/images
  4. virsh pool-edit default
    <path>/vm/XEN/libvirt/images</path>
Pool default XML configuration edited.
  1. mkdir -p /vm/XEN/libvirt/qemu/dump
  2. nano /etc/libvirt/qemu.conf
auto_dump_path = "/vm/XEN/libvirt/qemu/dump"
  1. nano /etc/xen/xend-config.sxp
(xend-unix-server yes)
  • virt-manager & Debian Wheezy packages are broken : some paths to libraries are invalid
  1. # mkdir -p /usr/lib64/xen/bin
  2. # ln -s /usr/lib/xen-4.1/bin/qemu-dm /usr/lib64/xen/bin/qemu-dm
  3. # ln -s /usr/lib/xen-4.1 /usr/lib/xen-default
  4. service xen restart
  5. virt-manager
Personal tools