Sign in Join
Wiki copytemporary

linux/kernel/user mode VM: what changed

Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.

Title: linux/kernel/user mode VM

OldNewLine
1+## Overview
2+
3+This section is intended to help users interested in developing Linux kernel modules to setup an UML VM to debug it during development phase.
4+
5+Please note that this page will focus on configuring a VM running on a Debian distribution based host.
6+
7+## Installation
8+
9+You need to install the packages *user-mode-linux* and *uml-utilities*.
10+
11+``` bash
12+apt-get install user-mode-linux uml-utilities
13+```
14+
15+### File system image
16+
17+The easiest way to set up your system is to download an already built image:
18+
19+> **Note:** This URL is obviously fake. Please insert correct URL.
20+
21+``` bash
22+wget ftp://ftp.freepascal.org/some path/umlrootfs.img.bz2
23+```
24+
25+Then you need to decompress it:
26+
27+``` bash
28+bunzip2 umlrootfs.img.bz2
29+```
30+
31+Please note that this is really a minimal installation, including the fp-compiler and aptitude packages. The latter will allow you to install any package you want providing you set up your network correctly.
32+
33+The provided root file system image has networking configured already for the VM, so you just need to configure the host part as described in the next section.
34+
35+### Networking
36+
37+#### Creating TAP interface
38+
39+In order to setup networking you need to configure a tap interface:
40+
41+``` bash
42+cat - > /etc/network/interfaces
43+ # /etc/network/interfaces -- configuration file for ifup(8), ifdown(8)
44+ # In this configuration example we will setup two physical networking
45+ # cards eth0 and eth1. The first card, eth0, will be automatically
46+ # configured at host starting up, while the second one will be configured
47+ # on manual demand using "ifup eth1".
48+ # We will also configure a virtual networking card tap0 which will be
49+ # configured at system startup too.
50+
51+ auto lo eth0 tap0
52+
53+ # The loopback interface
54+ iface lo inet loopback
55+
56+ iface eth0 inet static
57+ address 192.168.1.2
58+ netmask 255.255.255.0
59+ network 192.168.1.0
60+ gateway 192.168.1.1
61+
62+ iface eth1 inet static
63+ address 192.168.2.1
64+ netmask 255.255.255.0
65+ network 192.168.2.0
66+
67+ iface tap0 inet static
68+ address 192.168.3.1
69+ netmask 255.255.255.0
70+ network 192.168.3.0
71+ tunctl_user uml-net
72+ uml_proxy_arp 192.168.3.2
73+ uml_proxy_ether eth0
74+```
75+
76+#### Enabling IP forwarding
77+
78+In addition to this networking configuration, you need to instruct your kernel to forward IP packets, so the VM can communicate with the rest of your network and the internet.
79+
80+``` bash
81+cat - > /etc/sysctl.conf
82+ #
83+ # /etc/sysctl.conf - Configuration file for setting system variables
84+ # See sysctl.conf (5) for information.
85+ #
86+
87+ ##############################################################3
88+ # Functions previously found in netbase
89+ #
90+
91+ # Uncomment the next line to enable packet forwarding for IPv4
92+ net.ipv4.ip_forward=1
93+```
94+
95+#### Configuring UML switch
96+
97+``` bash
98+cat - > /etc/default/uml-utilities
99+ # Options to pass to uml_switch.
100+
101+ # set to "false" if you want to prevent uml_switch from
102+ # starting with SysV scripts in /etc/init.d
103+ UML_SWITCH_START="true"
104+
105+ # For preconfigured tap setup, see
106+ # /usr/share/doc/uml-utilities/examples/interfaces.example
107+ UML_SWITCH_OPTIONS="-tap tap0"
108+
109+ # User as which to run uml_switch
110+ UML_SWITCH_USER="uml-net"
111+
112+ # Socket file to use
113+ # Debian's default is:
114+ UML_SWITCH_CTL="/var/run/uml-utilities/uml_switch.ctl"
115+ #
116+ # if you instead use your rolled up kernel from upstream
117+ # sources you may want to uncomment the following:
118+ #UML_SWITCH_CTL="/tmp/uml.ctl"
119+```
120+
121+## Starting the UML VM
122+
123+### Startup script
124+
125+Starting UML VM requires a lot of arguments, but a small script can ease this task:
126+
127+``` bash
128+cat - > ${HOME}/bin/startUML.sh
129+#! /bin/sh
130+UML_BIN=linux
131+UML_ROOT_FS=${HOME}/umlrootfs.img
132+UML_SWITCH_SOCKET=/var/run/uml-utilities/uml_switch.ctl
133+exec ${UML_BIN} \
134+ umid=uml1 \
135+ mem=512M \
136+ ubd0=${UML_ROOT_FS} \
137+ eth0=daemon,fe:fd:fe:ed:b0:0f,,${UML_SWITCH_SOCKET} \
138+ con0=xterm xterm=/usr/bin/xterm,-T,-e \
139+```
140+
141+---
142+*From the Free Pascal wiki, page "linux/kernel/user mode VM", as it stood on 2013-09-05 after a change by BigChimp, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
143+Category: FPC
144+Category: Linux

Back to history