How to Create Fedora 20 Domain-U on Fedora 20 Domain-0

Posted on In Linux, Tutorial, Virtualization

In this post, creating a file-backed virtual block device (VBD) and installing Fedora 20 in the Xen DomU via internet will be introduced. This domain is created on a Fedora 20 Dom0 as introduced in https://www.systutorials.com/installing-xen-on-fedora-20-as-domain-0/. For better performance, you may consider using LVM backed VM.

Create file-backed VBD

The actual space of VBD will be the amount of disk the virtual machine used. And it will be convenient if the virtual machine will be duplicated since the work is just copying the VBD file and changing some configurations.

Assume that we are working in /home/xen/f20install/

Create a 20GB sparse file-backed VBD:

# dd if=/dev/zero of=./vmdisk0 bs=1k seek=20480k count=1

Install Fedora 20 Linux via Internet

First download the pxeboot kernel of Fedora 20 for installation via Internet:

(Note: if the URL expired, try to find it on https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/ )

wget http://download.fedoraproject.org/pub/fedora/linux/releases/20/Fedora/x86_64/os/images/pxeboot/vmlinuz
wget http://download.fedoraproject.org/pub/fedora/linux/releases/20/Fedora/x86_64/os/images/pxeboot/initrd.img

Create an installation profile vm.run:

name="f20install"
vcpus=2
memory=2048
disk = ['file:/home/xen/f20install/vmdisk0,xvda,w']
vif = [ 'bridge=xenbr0' ]
kernel="/home/xen/f20install/vmlinuz"
ramdisk="/home/xen/f20install/initrd.img"
extra="root=live:http://download.fedoraproject.org/pub/fedora/linux/releases/20/Fedora/x86_64/os/LiveOS/squashfs.img"
on_reboot = 'restart'
on_crash = 'restart'

The virtual machine’s name is “f20install”, memory is 2G, VCPU count is 2, and the disk is the VBD created above.

Here, DHCP is used for the VM to get IP, DNS and gateway information. If gateway and DNS server should be set according to the network configuration in format like:

extra="root=live:http://.../to/squashfs.img ip=10.8.1.210::10.8.1.1:255.255.0.0:vm210:eth0:none nameserver=8.8.8.8"

The full grammar explanation and supported protocols can be found in Anaconda documents.

Start this virtual machine and connect to this virtual machine’s console and complete the installation:

# xl create -c vm.run

The console can be released by “Ctrl+]”. And it can be reconnected by:

# xl console f20install

The installation of Fedora 20 will start. You can choose the “Text mode” and configure the installer interactively.

After successful installation of Fedora 20, it will reboot automatically. However, as the VM configuration is using the old one, it will boot from the external kernel and go the the installation interface again. As the installation is already done, you can shut down it by:

# xl shutdown f20install

This virtual machine can be duplicated to get more VMs: https://www.systutorials.com/how-to-duplicate-xen-domu-virtual-machines/.

Start DomU

Assume the VM vmdisk0 is duplicated to /home/xen/vm-10.8.1.210 and we are working in this directory.

Create a profile vm.run for loading the virtual machine:

name="10.8.1.210"
vcpus=2
memory=2048
disk = ['file:/home/xen/vm-10.8.1.210/vmdisk0,xvda,w' ]
vif = [ 'bridge=xenbr0' ]
bootloader = "pygrub"
on_reboot = 'restart'
on_crash = 'restart'

Here we use the PyGrub as the bootloader. PyGrub starts Linux DomUs with the kernels that lie in the file system of the DomU instead of the kernels that lie in the file system of the Dom0. That makes the kernel update and management easier.

Then the DomU can be started using the profile:

# xm create vm.run

The console of this DomU can be connected to:

# xm console 10.8.1.210

Eric Ma

Eric is a systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

3 comments

Leave a Reply

Your email address will not be published. Required fields are marked *