Software-based virtualizationCreate an empty disk image and then install Fedora onto it:
qemu-img create -f qcow2 disk.qcow2 4G qemu-system-x86_64 -hda disk.qcow2 \ -cdrom Fedora-20-x86_64-netinst.iso \ -boot d \ -net nic \ -net user \ -m 1024To accelerate qemu when virtualizing the same platform as the host, first use modprobe to install the appropriate KVM modules, and then add the --enable-kvm option to the qemu-system-x86_64 command above.
Running OpenWrt as a Xen HVM DomU guestConfigure a Xen DomU guest using the following:
name = "OpenWrt" memory = 1024 vcpus = 1 builder = "hvm" vif = [ "model=e1000,script=vif-bridge" ] disk = [ "tap2:tapdisk:aio:/path/to/openwrt-x86-generic-combined-ext4.img,xvda,w" ] serial = "pty"To select a network bridge on a host which has configured more than one, add a statement of the form bridge=brname to the list of network parameters. To hard-code an Ethernet MAC, add mac=mac.
Running CentOS as a Xen HVM DomU guestConfigure a Xen DomU guest using the following:
name = "CentOS" memory = 4096 vcpus = 1 builder = "hvm" vif = [ "model=e1000,script=vif-bridge" ] disk = [ "tap2:tapdisk:aio:/path/to/disk.img,xvda,w" ] serial = "pty" sdl = 1If you click on the SDL window, then the Xen interface will capture your mouse. To release the mouse, press Ctrl-Alt. Ctl-Alt-f will enter or leave full screen mode. Alternatively, you can omit sdl = 1 and configure GRUB to boot the Linux kernel with console=ttyS0.
Running OpenBSD as a Xen HVM DomU guestConfigure a Xen DomU guest using the following:
name = "OpenBSD" memory = 4096 vcpus = 1 builder = "hvm" vif = [ "model=e1000,script=vif-bridge" ] disk = [ "tap2:tapdisk:aio:/path/to/disk.img,xvda,w" ] serial = "pty" sdl = 1See the description of CentOS above for how to use the SDL console. Alternatively, you can omit sdl = 1 and configure OpenBSD to use a serial console. To do this, add tty00 "/usr/libexec/getty std.9600" vt220 on secure to /etc/ttys and add:
stty com0 19200 set tty com0to /etc/boot.conf.
NetworkingThe Xen domain configurations above assume bridged networking. This requires some configuration on the host.
You can set up a network bridge by placing the following in Dom0's /etc/sysconfig/network-scripts/ifcfg-xenbr0:
DEVICE=xenbr0 TYPE=Bridge ONBOOT=yes BOOTPROTO=dhcp NM_CONTROLLED=no DELAY=0
along with this in /etc/sysconfig/network-scripts/ifcfg-DEVICE, replacing MACADDRESS and DEVICE:
DEVICE=DEVNAME TYPE=Ethernet HWADDR=MACADDRESS BOOTPROTO=none ONBOOT=yes NM_CONTROLLED=no BRIDGE=xenbr0
Alternatively, you can configure a Xen guest to connect to a network through Dom0 with Dom0 acting as a NAT router.
- Configure the guest with vif = [ "model=e1000,script=vif-nat,ip=10.0.0.1/32,gatewaydev=INTERFACE" ], where INTERFACE is the network interface which serves as your default route to the Internet.
- Add the following to /etc/sysctl.conf on Dom0: net.ipv4.ip_forward=1 and run sysctl -p
- Run iptables -t nat -A POSTROUTING -o INTERFACE -j MASQUERADE, where INTERFACE is the interface from step one. (If you use firewalld, then run firewall-cmd --add-masquerade instead.)
- Boot the guest and configure its IP address as 10.0.0.1, its default gateway to 10.0.0.129 (Dom0's virtual interface), and its DNS resolver to a valid server.
Boot from an installation CDAdd the following to your Xen DomU guest configuration:
disk = [ "tap2:tapdisk:aio:/path/to/cdrom.iso,hdc:cdrom,r" ]You might want to instead add this statement to an existing disk list.
Pass an entire logical volume into a Xen guestIf you have an entire logical volume on Dom0 set aside for the guest, then you can pass it to the guest using:
disk = [ "phy:/dev/mapper/lv-name,xvdb,w" ]
Pass a USB device into a Xen guestAdd the following to your Xen DomU guest configuration:
usb = 1 usbdevice = "host:xxxx:yyyy"or
usb = 1 usbdevice = "host:x.y"In the first example, xxxx:xxxx represents the USB device's tag. In the second example, x.y represents the USB device's bus address. You can learn these identifiers by using lsusb.
Ensuring DomU virtual machines start after booting Dom0
- Place the configurations which you want to start upon booting in /etc/xen/.
- Make a symlink for each configuration from /etc/xen/ to /etc/xen/auto/.
- Run chkconfig xendomains on to ensure the xendomains script executes when Dom0 boots.
Share a folder from host to Linux guest
- Select guest Settings→Shared Folders.
- Add the folder on your host which you would like to add to your guest; remember the folder name.
- Ensure VirtualBox guest addition exists on the guest.
- On the Linux guest, run mount -t vboxsf folder-name mount-point.
Pass a USB device from host to Linux guest
- If you need USB 2 and 3 support, then install the VirtualBox extension pack from Oracle on the host: sudo VBoxManage extpack install path-to-extpack.
- Add the user running VirtualBox to the vboxusers group: sudo gpasswd -a $USER vboxusers. You might need to log out and log back in for this change to take affect.
- After booting the guest, look for the USB icon in VirtualBox's guest control panel at the bottom of the guest's window. Right click on it to select a USB device to pass through.
You might want to always pass a certain USB device to the guest. To do this, first identify the device's properties using VBoxManager list usbhost, and then create a filter using the interface at guest Settings→USB.
- Convert a raw disk image such that it can be used with VirtualBox or VMware:
- qemu-img convert -f raw foo.img -O vmdk foo.vmdk (This will allow the use of an OpenWrt image such as openwrt-x86-generic-combined-ext4.img.gz if you uncompress it first.)
- Create a sparse QCOW image for use with Xen:
- qcow-create $((1024*1024)) vm-disk.qcow