Stephen Reese

This guide describes how to create a filesystem and guest for the Xen hypervisor. This assumes you have a working Xen install with Dom U. I have described setting up a Xen hypervisor from source in another posted titled Installing Xen on CentOS 6 from source.

Create a partition to store virtual machines on. We want to use a partition based verse file based file-system for our guests as the performance is much better.

$ sudo parted /dev/sdb
mklabel gpt
(parted) unit GB
(parted) mkpart VolGroup00 0GB 400GB
(parted) set 1 lvm on
(parted) quit
(parted) p
Model: DELL PERC 6/i (scsi)
Disk /dev/sdb: 3999GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number  Start   End    Size   File system  Name        Flags
1      1049kB  400GB  400GB               VolGroup00  lvm

Create a partition for the first virtual machine.

$ sudo pvcreate /dev/sdb1
$ sudo vgcreate VolGroup00 /dev/sdb1
$ sudo vgdisplay
--- Volume group ---
VG Name               VolGroup00
System ID
Format                lvm2
Metadata Areas        1
Metadata Sequence No  1
VG Access             read/write
VG Status             resizable
MAX LV                0
Cur LV                0
Open LV               0
Max PV                0
Cur PV                1
Act PV                1
VG Size               372.53 GiB
PE Size               4.00 MiB
Total PE              95367
Alloc PE / Size       0 / 0
Free  PE / Size       95367 / 372.53 GiB
VG UUID               hdCkfh-twnj-Nu2V-FsTe-RsQg-PzlE-5w4QGR

Create a logical volume for the virtual machine.

$ sudo lvcreate -L 10GB -n Wheezy VolGroup00
$ sudo lvdisplay
--- Logical volume ---
LV Path                /dev/VolGroup00/Wheezy
LV Name                Wheezy
VG Name                VolGroup00
LV UUID                jQqEFZ-sd39-siY6-kqCZ-l8Lq-UWWk-3f4oh5
LV Write Access        read/write
LV Creation host, time host.localdomain, 2013-05-14 12:32:00 -0400
LV Status              available
# open                 0
LV Size                10.00 GiB
Current LE             2560
Segments               1
Allocation             inherit
Read ahead sectors     auto
- currently set to     256
Block device           253:0

Get the latest Debian hd-media. Specify these parameters in the virtual machine configuration that will be used for the first start-up, i.e. the install of your guest. A second configuration will be used for booting the guest post-install.

kernel = "/scratch/debian/wheezy/vmlinuz"
ramdisk = "/scratch/debian/wheezy/initrd.gz"
extra = "debian-installer/exit/always_halt=true -- console=hvc0"
memory = 512
name = "Wheezy"
vif = ['bridge=br0']
disk = ['phy:/dev/VolGroup00/Wheezy,xvda,w']

Connect to the new guest with a console and perform the installation.

$ sudo xl create -c /etc/xen/install-debian.cfg

Start a guest without a console.

$ sudo xl create /etc/xen/debian.cfg

Leave the console.

$ "Ctrl+]"

List the instances.

$ sudo xl list
Name                                        ID   Mem VCPUs      State   Time(s)
Domain-0                                     0  2048     1     r-----    237.4
Wheezy                                      11   512     1     -b----      6.8

Connect to the console.

$ sudo xl console Wheezy

Leave the console.

$ "Ctrl+]"

If you have any questions or feel something is missing, leave a comment below.


comments powered by Disqus