http://www.crashcourse.ca/wiki/index.php/User_Mode_Linux_on_FedoraUser Mode Linux on FedoraFrom Crashcourse Wiki
OverviewThis tutorial explains how to get User Mode Linux up and running on a Fedora system, starting with a pre-built UML kernel and root filesystem and carrying on to configuring networking, creating your own kernels and root fileystems and so on. It's an ongoing work in progress, so feel free to check back occasionally for new content. All of this has been tested on a fully-updated F8 system running on a Gateway laptop, which means that if the directions here don't work, I'd like to know. Seriously, this is not meant to be a set of directions that might work. They should work and, if they don't, I'll fix them. The content formatSince a lot of this recipe consists of listing commands to run and there are two operating systems to work with, it behooves us to be very clear on which system each command is to be run, so I'll use the following standards: $ ls [non-root command on host system] # ls [root command on host system] UML# ls [command run from within the UML session] In addition, when we get into networking, I'll stick with the standard that the network I'm on currently has the following IP addresses:
Getting startedUsing a pre-built kernel and root filesystemJust to get things going, let's begin with a ready-made UML kernel and root filesystem. As examples, you can go [here] and download the appropriate 2.6.24.3 kernel and Fedora 8 root filesystem, then simply follow the instructions [here] under the section heading "Getting started" to verify simply that you can start a UML session. Don't try to do anything fancy yet -- just make sure you can start the UML session, run a few simple commands, then get out with halt. Also, take a look at the sample "Boot log" that's supplied on that page, and note carefully that you should expect to get some boot-time errors using these downloaded, pre-built components, so don't let that concern you. Your UML's UMIDEvery active UML session (and, yes, you can have more than one going at a time) can be identified by a Unique Machine ID (UMID), which will be used later when setting up networking, among other things. There are a couple of different ways to associate a UMID with a new UML session:
Regardless of which of the above you use, once the UML session is running (and let's just stick with one for now), you can see the corresponding UMID either from the host side: $ ls ~/.uml p7KeCa <-- that's it $ or from within the UML session itself: # dmesg | grep mconsole
mconsole (version 2) initialized on /home/rpjday/.uml/p7KeCa/mconsole
^^^^^^ there it is again
#
Getting and building the UML utilitiesIn order to use a number of UML features, you need to install the "UML utilities" on your host. And given that there is no pre-built Fedora package, you're going to have to download the source tarball and build from that. Grab the utilities tarball from [here], and un-tar it into a working directory. Before going any further, on a Fedora system, you'll need to: # yum install fuse-devel and, finally, build and install the UML utilities but, for cleanliness, arrange for them to be installed in /usr/local/bin rather than /usr/bin -- it's always better that way. $ make all # make BIN_DIR=/usr/local/bin install UML networkingOverviewThe next few sections cover how to configure networking for your UML session, starting with simple manual networking between the guest and host, and getting into DHCP, NAT and so on. For the examples that follow, assume we're still using the pre-built kernel and root filesystem mentioned above. Also, assume that our host system is on the 192.168.1.0 network, and that we're assigning the new UML IP addresses thusly:
The networking checklistComing soon: What to verify for both your host and UML kernel to make sure you have everything you need for networking before you go any further. Simple manual networking between guest and hostThis section is based heavily on the writeup [here], so let's just walk through a sample UML session that configures basic networking. First, let's configure simple networking after the UML session has already started. On the host side: $ ./kernel32-2.6.24.3 ubda=Fedora8-x86-root_fs [Start UML session] $ uml_mconsole p7KeCa config eth0=tuntap,,,192.168.1.254 [Configure interface] OK $ Following that, on the UML side: UML# ifconfig eth0 192.168.1.253 up
UML# ifconfig eth0
eth0 Link encap:Ethernet HWaddr C6:6A:56:AA:BF:CE
inet addr:192.168.1.253 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::c46a:56ff:feaa:bfce/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:18 errors:0 dropped:0 overruns:0 frame:0
TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2620 (2.5 KiB) TX bytes:328 (328.0 b)
Interrupt:5
UML#
That seemed easy, so let's test connectivity from the host side. First, you should have a new tap0 interface on the host side with IP address 192.168.1.254: $ ifconfig tap0
tap0 Link encap:Ethernet HWaddr 00:FF:A5:C0:2B:D2
inet addr:192.168.1.254 Bcast:192.168.1.254 Mask:255.255.255.255
inet6 addr: fe80::2ff:a5ff:fec0:2bd2/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:6 errors:0 dropped:0 overruns:0 frame:0
TX packets:28 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:500
RX bytes:468 (468.0 b) TX bytes:4478 (4.3 KiB)
$ ping 192.168.1.253
PING 192.168.1.253 (192.168.1.253) 56(84) bytes of data.
64 bytes from 192.168.1.253: icmp_seq=1 ttl=64 time=2.25 ms
...
$
And from the UML side: UML# ping 192.168.1.254 ping: error while loading shared libraries: libidn.so.11: cannot open shared object file: No such file or directory Hmmmm ... not good, but it's only ping that's the problem; we can still ssh back to the host system, so that proves that networking really is working: UML# ssh 192.168.1.254 [EMAIL PROTECTED]'s password: Last login: Wed Mar 5 04:29:53 2008 from 192.168.1.253 [EMAIL PROTECTED] ~]# In short, we seem to have networking. In addition, rather than having to establish the host-side networking after the UML session has already started, you can set it up during the UML invocation itself: ./kernel32-2.6.24.3 ubda=Fedora8-x86-root_fs eth0=tuntap,,,192.168.1.254 You'll still have to set up the UML-side networking as before, though, but we'll show you how to automate that shortly. Connecting to the outside worldSo far, your UML session is networked only to its own host system. If you want your UML session to have access to the Internet, just set the appropriate default gateway on the UML side to refer back to the host's IP address: UML# route add default gw 192.168.1.254 UML# route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.1.0 * 255.255.255.0 U 0 0 0 eth0 default 192.168.1.254 0.0.0.0 UG 0 0 0 eth0 UML# And on the host side:
# cat /proc/sys/net/ipv4/ip_forward 1 # If all the above is true, your UML session should have access to the Intertoobs. Static UML-side network configurationIf you have a Fedora-flavoured root filesystem (like the one we've been using until now) and are happy hard-coding your eth0 network interface so you don't have to do it manually each time you start your UML session, that's not hard. Just set up your UML-side network configuration file along the lines of: UML# cat /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 BOOTPROTO=static TYPE=Ethernet IPADDR=192.168.1.253 <-- hard-coded UML IP address NETMASK=255.255.255.0 Once that's done, you can manually start and stop your UML-side networking with one of: UML# service network {start,stop,restart,status}
However (and pay attention here), that might not be enough to bring up networking automatically at boot time. You also need to ensure that networking itself is activated at boot time, and that might involve: UML# chkconfig --add network A quick way to check if that step is necessary is to run: UML# chkconfig --list crond 0:off 1:off 2:on 3:on 4:on 5:on 6:off messagebus 0:off 1:off 2:on 3:on 4:on 5:on 6:off restorecond 0:off 1:off 2:on 3:on 4:on 5:on 6:off sshd 0:off 1:off 2:on 3:on 4:on 5:on 6:off udev-post 0:off 1:off 2:off 3:on 4:on 5:on 6:off If you don't see an entry for "network", then you'll have to run that earlier chkconfig command to activate it. (That step was, in fact, necessary for the root filesystem we've been using all this time.) Finally, if you're using a different flavour of root filesystem, well, you're on your own. It shouldn't be hard to figure out how to get the same effect. Feedback to [EMAIL PROTECTED]. Return to Fedora Cookbook. |
