Penguin
Blame: UserModeLinux
EditPageHistoryDiffInfoLikePages
Annotated edit history of UserModeLinux version 23, including all changes. View license author blame.
Rev Author # Line
22 AristotlePagaltzis 1 With all the recent activity happening with Linux being ported to things, people started running out of hardware to port linux to. So one smart cookie decided to port Linux to uh, Linux! And thus the UserModeLinux project was born.
14 DanielBalster 2
3 User mode linux is basically a program that lets you run linux as a normal process under linux.
4
5 To get it running under debian sid I did:
22 AristotlePagaltzis 6
18 PerryLorier 7 <pre>
22 AristotlePagaltzis 8 apt-get install user-mode-linux
18 PerryLorier 9 </pre>
22 AristotlePagaltzis 10
14 DanielBalster 11 you then want to add yourself to the uml-net group. I didn't find this documented anywhere, but if you don't do this, you'll get weird random messages when you try and use networking under user-mode-linux. People in this group can do nasty things to your network so only give it to people you trust yadda yadda yadda. Remember to logout/login again after making this change
12
13 Then, I created a 512 mb "hard disk"
22 AristotlePagaltzis 14
18 PerryLorier 15 <pre>
22 AristotlePagaltzis 16 dd if=/dev/zero of=root_fs bs=1M count=512
18 PerryLorier 17 </pre>
22 AristotlePagaltzis 18
14 DanielBalster 19 and formatted it with ext2
22 AristotlePagaltzis 20
18 PerryLorier 21 <pre>
22 AristotlePagaltzis 22 mke2fs ./root_fs
18 PerryLorier 23 </pre>
22 AristotlePagaltzis 24
14 DanielBalster 25 then mounted it as a loop back device
22 AristotlePagaltzis 26
18 PerryLorier 27 <pre>
22 AristotlePagaltzis 28 mkdir uml && mount -o loop ./root_fs uml
18 PerryLorier 29 </pre>
22 AristotlePagaltzis 30
14 DanielBalster 31 then built my disto on it
22 AristotlePagaltzis 32
18 PerryLorier 33 <pre>
22 AristotlePagaltzis 34 debootstrap woody uml /mirrors/debian
18 PerryLorier 35 </pre>
22 AristotlePagaltzis 36
14 DanielBalster 37 you can then boot uml
22 AristotlePagaltzis 38
18 PerryLorier 39 <pre>
22 AristotlePagaltzis 40 linux single rw devfs=mount eth0=tuntap,,,''the-ip-of-your-host-machine''
18 PerryLorier 41 </pre>
22 AristotlePagaltzis 42
14 DanielBalster 43 it'll boot up into single user mode so you can configure and finalise the installation
22 AristotlePagaltzis 44
18 PerryLorier 45 <pre>
22 AristotlePagaltzis 46 ifconfig eth0 ''the-ip-of-your-uml-machine'' netmask ''the-netmask''
47 route add -net 0 gw ''the-ip-of-your-gateway''
19 AlastairPorter 48 </pre>
49
20 AlastairPorter 50 If you get the error ''SIOCSIFFLAGS: Operation not permitted'' when trying to bring up eth0, ensure that the user you are running UML as on the host has read/write permissions to /dev/net/tun. See the note about the uml-net group above.
19 AlastairPorter 51
52 <pre>
22 AristotlePagaltzis 53 apt-get update
54 apt-get upgrade
18 PerryLorier 55 </pre>
14 DanielBalster 56
57 This failed on my system, but it passed after creating a /etc/apt/apt.conf file with the following content
22 AristotlePagaltzis 58
18 PerryLorier 59 <pre>
22 AristotlePagaltzis 60 APT::Default-Release "woody";
61 APT::Cache-Limit 10000000;
62 Apt::Get::Purge;
18 PerryLorier 63 </pre>
14 DanielBalster 64
65 You don't need lilo, and it gets in the way, so lets get rid of it.
22 AristotlePagaltzis 66
18 PerryLorier 67 <pre>
22 AristotlePagaltzis 68 apt-get remove lilo
18 PerryLorier 69 </pre>
22 AristotlePagaltzis 70
14 DanielBalster 71 Now lets configure all the packages
22 AristotlePagaltzis 72
18 PerryLorier 73 <pre>
22 AristotlePagaltzis 74 dpkg-reconfigure -a
75 tzconfig
18 PerryLorier 76 </pre>
22 AristotlePagaltzis 77
14 DanielBalster 78 now before we reboot we need to create some files that the installer usually creates
22 AristotlePagaltzis 79
18 PerryLorier 80 <pre>
22 AristotlePagaltzis 81 echo /dev/ubd/0 / ext2 defaults,errors=remount-ro 0 1 >/etc/fstab
82 echo none /proc proc defaults 0 0 >>/etc/fstab
14 DanielBalster 83
22 AristotlePagaltzis 84 echo ''hostname-of-your-uml-machine'' >/etc/hostname
18 PerryLorier 85 </pre>
14 DanielBalster 86
87 and lets set up networking on boot
22 AristotlePagaltzis 88
18 PerryLorier 89 <pre>
22 AristotlePagaltzis 90 echo 'auto lo' >/etc/network/interfaces
91 echo 'iface lo inet loopback' >>/etc/network/interfaces
92 echo 'auto eth0' >>/etc/network/interfaces
93 echo 'iface eth0 inet static' >>/etc/network/interfaces
94 echo ' address ''address-of-your-uml-box''' >>/etc/network/interfaces
95 echo ' netmask ''netmask''' >>/etc/network/interfaces
96 echo ' network ''network''' >>/etc/network/interfaces
97 echo ' broadcast ''broadcast''' >>/etc/network/interfaces
98 echo ' gateway ''gateway''' >>/etc/network/interfaces
18 PerryLorier 99 </pre>
14 DanielBalster 100
101 and setting the hardware clock will always fail in uml
22 AristotlePagaltzis 102
18 PerryLorier 103 <pre>
22 AristotlePagaltzis 104 rm /etc/rcS.d/*hwclock*
18 PerryLorier 105 </pre>
14 DanielBalster 106
107 now, lets configure /etc/inittab correctly, replace tty1 with vc/0, tt1 with vc/1 in the file.
108
109 and now lets copy the modules over
22 AristotlePagaltzis 110
18 PerryLorier 111 <pre>
22 AristotlePagaltzis 112 mkdir -p /mnt/host
113 mount none /mnt/host -o / -t hostfs
114 mkdir -p /lib/modules/`uname -r`/kernel
115 cp -r /mnt/host/usr/lib/uml/modules/`uname -r`/kernel/* /lib/modules/`uname -r`/kernel
116 depmod -a
18 PerryLorier 117 </pre>
22 AristotlePagaltzis 118
14 DanielBalster 119 for me it complains about the scsi devices, since this is a virtual kernel, I figure i don't need them so I deleted them then rerun depmod
120
121 and now your box should be ready to boot again, so shutdown -h now the box then
22 AristotlePagaltzis 122
18 PerryLorier 123 <pre>
22 AristotlePagaltzis 124 linux devfs=mount eth0=tuntap,,,10.100.1.8 ro
18 PerryLorier 125 </pre>
14 DanielBalster 126
127 voila, it should boot up, pop up some windows and ask you to login!
22 AristotlePagaltzis 128
14 DanielBalster 129 -------------
22 AristotlePagaltzis 130
131 Or you can do it the easy way: copy <tt>/etc/rootstrap/rootstrap.conf</tt> into the current working directory, edit the networking config (don't meddle with too many of the options, many of them don't work if you change them, for instance installing sid doesn't work...) and run (in the same directory)
132
18 PerryLorier 133 <pre>
22 AristotlePagaltzis 134 ./rootstrap root_fs
18 PerryLorier 135 </pre>
22 AristotlePagaltzis 136
14 DanielBalster 137 wait a significant time. you now have a uml image installed. you can start it with
22 AristotlePagaltzis 138
18 PerryLorier 139 <pre>
22 AristotlePagaltzis 140 ./linux th0=tuntap,,,''ip-of-your-host-machine'' ro
18 PerryLorier 141 </pre>
14 DanielBalster 142
143 you're done.
16 JamieCurtis 144
145 --------------
146
147 If you want to reduce the size that your root_fs take up, try the following:
148
22 AristotlePagaltzis 149 * defrag the volume (DebianLinux: <tt>apt-get install defrag</tt>)
150 * zero the free space (eg. using [zerofree | http://intgat.tigress.co.uk/rmy/uml/sparsify.html])
16 JamieCurtis 151 * make the file sparse
18 PerryLorier 152 * either use sparsify from the above link or
22 AristotlePagaltzis 153 * <tt>cp --sparse=always <orig fs> <sparse fs></tt>
14 DanielBalster 154
155 --------------
156
157 !Traps for young players
158
159 If you receive the following error when trying to start your uml process with networking:
160
22 AristotlePagaltzis 161 <pre>
162 Exec of 'uml_net' failed - errno = 2
163 tuntap_open_tramp failed - errno = 22
164 SIOCSIFFLAGS: Invalid argument
165 </pre>
14 DanielBalster 166
167 I tried EVERYTHING to get rid of this. Finally the solution was VERY simple. Run as a standard user, who is in the uml-net group, and not as root. Note: This is a "works for me". I still don't know why this solved the problem, only that it did. Also, another oddity is that AFTER I had run it as a user, I could then run it as root with no problems. This smacks of tap0 being created with incorrect permissions or some oddity. Anyway, it works now.
168
22 AristotlePagaltzis 169 ! Mounting one of the pre-built Root FSes (ON THE HOST!)
14 DanielBalster 170
171 It took a while for me to work out how to mount a root FS for RH9 so I could change it before booting UML. The FS had two partitions and a partition table, so mount the_fs /mnt -o loop didn't work. It turns out you need to specify an offset to mount to skip past the partition table. You can find out how many bytes to skip by doing this:
172
18 PerryLorier 173 <pre>
22 AristotlePagaltzis 174 # fdisk redhat9.image.server-minimal.disk
175 Command (m for help): u
176 Changing display/entry units to sectors
14 DanielBalster 177
22 AristotlePagaltzis 178 Command (m for help): p
14 DanielBalster 179
22 AristotlePagaltzis 180 Disk redhat9.image.server-minimal.disk: 0 MB, 0 bytes
181 128 heads, 32 sectors/track, 0 cylinders, total 0 sectors
182 Units = sectors of 1 * 512 = 512 bytes
14 DanielBalster 183
22 AristotlePagaltzis 184 Device Boot Start End Blocks Id System
185 redhat9.image.server-minimal.disk1 * 32 3756031 1878000 83 Linux
186 redhat9.image.server-minimal.disk2 3756032 4194303 219136 82 Linux swap
14 DanielBalster 187
22 AristotlePagaltzis 188 Command (m for help): q
14 DanielBalster 189
22 AristotlePagaltzis 190 # bc
191 bc 1.06
192 Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
193 This is free software with ABSOLUTELY NO WARRANTY.
194 For details type `warranty'.
195 32*512
196 16384
197 # mount redhat9.image.server-minimal.disk /mnt -o loop,offset=16384 -t ext3
18 PerryLorier 198 </pre>
14 DanielBalster 199
200 Sorted.
20 AlastairPorter 201
202 ! Compiling your own kernel
22 AristotlePagaltzis 203
20 AlastairPorter 204 This is a fairly trivial task if you are used to compiling kernels. The main point to remember is to add
22 AristotlePagaltzis 205
20 AlastairPorter 206 <pre>
207 ARCH=um
208 </pre>
22 AristotlePagaltzis 209
20 AlastairPorter 210 to each command (or export it as a shell variable).
211
212 In brief:
22 AristotlePagaltzis 213
20 AlastairPorter 214 <pre>
22 AristotlePagaltzis 215 make defconfig ARCH=um
216 make ARCH=um
217 mount -o loop ./root_fs /mnt/uml
218 make modules_install INSTALL_MOD_PATH=/mnt/uml ARCH=um
219 umount /mnt/uml
20 AlastairPorter 220 </pre>
21 IanMcDonald 221
22 AristotlePagaltzis 222 If you're compiling on 64 bit Linux you will probably also need to add <tt>SUBARCH=i386</tt> as well.
23 AristotlePagaltzis 223
224 InNeedOfRefactor

PHP Warning

lib/blame.php:177: Warning: Invalid argument supplied for foreach()