This page discusses about Usermode linux and Host Identity for Linux. We start by configuring the host and guest kernels. Next we go through the necessary steps to get the networking to work (this part is very similar to the virtualbox configuration. As last item in the list we discuss about ways to use hosts fs.
As a first step you should get kernel sources for desired kernel version (kernel.org. Unpack the kernel. Then you need the HIPL patche(s) (depends on the kernel version you use for never kernels there is only one patch) for the kernel. Apply the patche(s) to the kernel (patches and the instructions can be found from infrahip site. Make a copy of it and mark the kernels as <kernel>-host and <kernel>-guest (replace the <kernel> with the name of the chosen kernel).
Host Kernel Configuration First of all you have to change your directory to the one that holds the hosts kernel.
host$ cd /[path-to-host-kernel-source]After that the kernel has to be cleaned.
host$ make mrproperIf you have old configuration file you have to copy it to the host kernels directory and get it up to date with the kernel version you chose.
host$ cp [path-to-old-config] [path-to-host-kernel-source]/.config
host$ make oldconfig
Otherwise you have to use command.
host$ make defconfigThen the actual kernel configuration can commence.
host$ make menuconfigEnable following features (check infrahip site for complete list of HIPL required features):
- Make sure that you have UML specific --> 'host filesystem' hard
coded to kernel, because it makes your life easier
- Security options --> Default linux capabilities
- Networking options --> IP tunneling
- Networking options --> 802.1d Ethernet Bridging
- Network packet filtering-->
- Core netfilter configuration
- IP NEtfilter configuration and Bridged IP/ARP packets filtering
- Network device support --> universal TUN/TAP device driver support
- HIP required stuff (check www.infrahip.net)
- And others needed by host...
fakeroot make-kpkg --initrd --revision=custom.1.0 --append-to-version=.hipl kernel_image fakeroot make-kpkg --initrd --revision=custom.1.0 --append-to-version=.hipl kernel_headers
Install the kernel and its headers.
host$ sudo dpkg -i [kernel-image].deb host$ sudo dpkg -i [kernel-headers].deb
Boot and change kernel to now compiled
Guest Kernel Configuration
First go to the directory containing the HIPL patched guest kernel. Then you have to clean the kernel sources and define that the configuration uses the Usermode linux architecture (ARCH=um). When cleaning it may be necessary to use "make distclean ARCH=um" (if kernel sources were used to compile kernel for different arch).
host$ cd /[path-to-guest-kernel-source] host$ make mrproper ARCH=um host$ make defconfig ARCH=um host$ make menuconfig ARCH=um
When creating a kernel for UML it is easiest if you disable the loadable kernel module support. By doing this the kernel will have everything compiled into the kernel. This might result in big kernel image, but at least the UML architecture will remove almost all device support from the guest kernel so the kernel will remain quite small. Following features have to be enabled.
- HIP required stuff (check www.infrahip.net)
- Security options --> Default linux capabilities
- Networking options --> IP tunneling
- Networking options --> 802.1d Ethernet Bridging
- Network device support --> Universal TUN/TAP device driver support
Compiling the kernel for guest is done with the following command that tells the make to a image called linux. This image can be run as a program in UML as explained later.
host$ make linux ARCH=um
Now you have to copy and name the image to something more descriptive like <kernel-version>-guest.
host$ cp /[path-to-kernel-source]/linux /[path-to-final-location-of-guest-kernel]/[name-it]Download a filesystem image from uml.nagafix.co.uk. Or make it yourself. This tutorial does not describe hot to make one. For the networking to work you have to install package dhcp to the host After the installation is complete modify the /etc/dhcpd.conf to include the following. The IP ranges can be changed but remember to modify the start command introduced later on this page accordingly.
option subnet-mask 255.255.255.0;
default-lease-time 6000;
max-lease-time 72000;
option domain-name-servers 172.16.121.1;
option routers 172.16.121.1;
server-name "172.16.121.1";
subnet 172.16.121.0 netmask 255.255.255.0 {
range 172.16.121.20 172.16.121.25;
}
Script to build up the interfaces and iptables rules to get the host networking to work. First the script loads necessary kernel modules. Stops previous instances of dhcpd. Creates the interfaces for the virtual machine. As a last thing the script starts the UML.
# modprobe needed modules for TUN/TAP devices modprobe tun # shutdown earlier instance of dhcpd /etc/init.d/dhcp stop # create device for the uml and dhcp service running for it tunctl -t tap1 ifconfig tap1 172.16.121.1 dhcpd tap1 # modprobe needed modules for iptables modprobe ip_tables modprobe iptable_filter modprobe iptable_nat # enable NIC forwarding echo 1 > /proc/sys/net/ipv4/ip_forward # set forwarding rules to the host iptables for the uml guest iptables -t nat -I POSTROUTING -o eth0 -j MASQUERADE iptables -I FORWARD -i tap1 -j ACCEPT iptables -I FORWARD -o tap1 -j ACCEPT echo "Starting host kernel" # should be on one line /home/sklvarjo/hipl/uml/linux-2.6.22.1-hipumlguest ubda=/home/sklvarjo/hipl/uml/stuff/Ubuntu-FeistyFawn-i386-root_fs eth0=tuntap,tap1,fe:f0:00:00:00:01,172.16.121.20
Notice: Last line should be on one line! Complete script I use with UML can be found here. Some of the lines have to be modified before it works for you (marked with <small-explanation> also check out the comments).
How to use same hip sources and binaries between host and
guest
There is at least two ways of doing this. First one uses nfs and the
second uses the UML specific hostfs mechanism.
Install nfs-user-server package on host Modify /etc/exports to contain line /home 172.16.121.20 Restart nfs services on host Install autofs package to guest Modify /etc/auto.master to contain lines /home /etc/auto.home /misc /etc/auto.misc Modify /etc/auto.home to contain line (including asterisk) * 172.16.121.1:/home/&
If you enabled the hostfs you can mount the hosts fs with the following command.
host$ mount -t hostfs none /media/host -o [path-to-hipl-sources]
As a last point you have to install to both host and guest the packages needed by HIPL.
All of these manuals/tutorials are provided as is. They worked for me and that is all the help I give with them, so if I forgot something or there is a typo you can inform me but do not expect me to solve your problems :) Oh and almost forgot, use them at your own risk.