Penguin
Diff: UserModeLinux
EditPageHistoryDiffInfoLikePages

Differences between current version and predecessor to the previous major change of UserModeLinux.

Other diffs: Previous Revision, Previous Author, or view the Annotated Edit History

Newer page: version 23 Last edited on Wednesday, January 28, 2009 10:39:02 am by AristotlePagaltzis
Older page: version 20 Last edited on Wednesday, August 29, 2007 4:40:55 pm by AlastairPorter Revert
@@ -1,185 +1,224 @@
-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 User Mode Linux project was born. 
+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. 
  
 User mode linux is basically a program that lets you run linux as a normal process under linux. 
  
 To get it running under debian sid I did: 
+  
 <pre> 
- apt-get install user-mode-linux 
+apt-get install user-mode-linux 
 </pre> 
+  
 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 
  
 Then, I created a 512 mb "hard disk" 
+  
 <pre> 
- dd if=/dev/zero of=root_fs bs=1M count=512 
+dd if=/dev/zero of=root_fs bs=1M count=512 
 </pre> 
+  
 and formatted it with ext2 
+  
 <pre> 
- mke2fs ./root_fs 
+mke2fs ./root_fs 
 </pre> 
+  
 then mounted it as a loop back device 
+  
 <pre> 
- mkdir uml && mount -o loop ./root_fs uml 
+mkdir uml && mount -o loop ./root_fs uml 
 </pre> 
+  
 then built my disto on it 
+  
 <pre> 
- debootstrap woody uml /mirrors/debian 
+debootstrap woody uml /mirrors/debian 
 </pre> 
+  
 you can then boot uml 
+  
 <pre> 
- linux single rw devfs=mount eth0=tuntap,,,''the-ip-of-your-host-machine'' 
+linux single rw devfs=mount eth0=tuntap,,,''the-ip-of-your-host-machine'' 
 </pre> 
+  
 it'll boot up into single user mode so you can configure and finalise the installation 
+  
 <pre> 
- ifconfig eth0 ''the-ip-of-your-uml-machine'' netmask ''the-netmask''  
- route add -net 0 gw ''the-ip-of-your-gateway'' 
+ifconfig eth0 ''the-ip-of-your-uml-machine'' netmask ''the-netmask''  
+route add -net 0 gw ''the-ip-of-your-gateway'' 
 </pre> 
  
 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. 
  
 <pre> 
- apt-get update  
- apt-get upgrade 
+apt-get update  
+apt-get upgrade 
 </pre> 
  
 This failed on my system, but it passed after creating a /etc/apt/apt.conf file with the following content 
+  
 <pre> 
- APT::Default-Release "woody";  
- APT::Cache-Limit 10000000;  
- Apt::Get::Purge; 
+APT::Default-Release "woody";  
+APT::Cache-Limit 10000000;  
+Apt::Get::Purge; 
 </pre> 
  
 You don't need lilo, and it gets in the way, so lets get rid of it. 
+  
 <pre> 
- apt-get remove lilo 
+apt-get remove lilo 
 </pre> 
+  
 Now lets configure all the packages 
+  
 <pre> 
- dpkg-reconfigure -a  
- tzconfig 
+dpkg-reconfigure -a  
+tzconfig 
 </pre> 
+  
 now before we reboot we need to create some files that the installer usually creates 
+  
 <pre> 
- echo /dev/ubd/0 / ext2 defaults,errors=remount-ro 0 1 >/etc/fstab  
- echo none /proc proc defaults 0 0 >>/etc/fstab 
+echo /dev/ubd/0 / ext2 defaults,errors=remount-ro 0 1 >/etc/fstab  
+echo none /proc proc defaults 0 0 >>/etc/fstab 
  
- echo ''hostname-of-your-uml-machine'' >/etc/hostname 
+echo ''hostname-of-your-uml-machine'' >/etc/hostname 
 </pre> 
  
 and lets set up networking on boot 
+  
 <pre> 
- echo 'auto lo' >/etc/network/interfaces  
- echo 'iface lo inet loopback' >>/etc/network/interfaces  
- echo 'auto eth0' >>/etc/network/interfaces  
- echo 'iface eth0 inet static' >>/etc/network/interfaces  
- echo ' address ''address-of-your-uml-box''' >>/etc/network/interfaces  
- echo ' netmask ''netmask''' >>/etc/network/interfaces  
- echo ' network ''network''' >>/etc/network/interfaces  
- echo ' broadcast ''broadcast''' >>/etc/network/interfaces  
- echo ' gateway ''gateway''' >>/etc/network/interfaces 
+echo 'auto lo' >/etc/network/interfaces  
+echo 'iface lo inet loopback' >>/etc/network/interfaces  
+echo 'auto eth0' >>/etc/network/interfaces  
+echo 'iface eth0 inet static' >>/etc/network/interfaces  
+echo ' address ''address-of-your-uml-box''' >>/etc/network/interfaces  
+echo ' netmask ''netmask''' >>/etc/network/interfaces  
+echo ' network ''network''' >>/etc/network/interfaces  
+echo ' broadcast ''broadcast''' >>/etc/network/interfaces  
+echo ' gateway ''gateway''' >>/etc/network/interfaces 
 </pre> 
  
 and setting the hardware clock will always fail in uml 
+  
 <pre> 
- rm /etc/rcS.d/*hwclock* 
+rm /etc/rcS.d/*hwclock* 
 </pre> 
  
 now, lets configure /etc/inittab correctly, replace tty1 with vc/0, tt1 with vc/1 in the file. 
  
 and now lets copy the modules over 
+  
 <pre> 
- mkdir -p /mnt/host  
- mount none /mnt/host -o / -t hostfs  
- mkdir -p /lib/modules/`uname -r`/kernel  
- cp -r /mnt/host/usr/lib/uml/modules/`uname -r`/kernel/* /lib/modules/`uname -r`/kernel  
- depmod -a 
+mkdir -p /mnt/host  
+mount none /mnt/host -o / -t hostfs  
+mkdir -p /lib/modules/`uname -r`/kernel  
+cp -r /mnt/host/usr/lib/uml/modules/`uname -r`/kernel/* /lib/modules/`uname -r`/kernel  
+depmod -a 
 </pre> 
+  
 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 
  
 and now your box should be ready to boot again, so shutdown -h now the box then 
+  
 <pre> 
- linux devfs=mount eth0=tuntap,,,10.100.1.8 ro 
+linux devfs=mount eth0=tuntap,,,10.100.1.8 ro 
 </pre> 
  
 voila, it should boot up, pop up some windows and ask you to login! 
+  
 ------------- 
-or you can do it the easy way. copy /etc/rootstrap/rootstrap.conf 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) 
+  
+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)  
+  
 <pre> 
- ./rootstrap root_fs 
+./rootstrap root_fs 
 </pre> 
+  
 wait a significant time. you now have a uml image installed. you can start it with 
+  
 <pre> 
- ./linux th0=tuntap,,,''ip-of-your-host-machine'' ro 
+./linux th0=tuntap,,,''ip-of-your-host-machine'' ro 
 </pre> 
  
 you're done. 
  
 -------------- 
  
 If you want to reduce the size that your root_fs take up, try the following: 
  
-* defrag the volume (apt-get install defrag on debian )  
-* zero the free space (get zerofree from http://intgat.tigress.co.uk/rmy/uml/sparsify.html) 
+* defrag the volume (DebianLinux: <tt> apt-get install defrag</tt> )  
+* zero the free space (eg. using [ zerofree | http://intgat.tigress.co.uk/rmy/uml/sparsify.html]
 * make the file sparse 
  * either use sparsify from the above link or 
- * cp --sparse=always <orig fs> <sparse fs> 
+ * <tt> cp --sparse=always <orig fs> <sparse fs></tt
  
 -------------- 
  
 !Traps for young players 
  
 If you receive the following error when trying to start your uml process with networking: 
  
-Exec of 'uml_net' failed - errno = 2%%%  
-tuntap_open_tramp failed - errno = 22%%%  
-SIOCSIFFLAGS: Invalid argument%%%  
+<pre>  
+ Exec of 'uml_net' failed - errno = 2  
+tuntap_open_tramp failed - errno = 22  
+SIOCSIFFLAGS: Invalid argument  
+</pre>  
  
 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. 
  
-!Mounting one of the pre-built Root FSes (ON THE HOST!) 
+! Mounting one of the pre-built Root FSes (ON THE HOST!) 
  
 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: 
  
 <pre> 
- # fdisk redhat9.image.server-minimal.disk  
- Command (m for help): u  
- Changing display/entry units to sectors 
+# fdisk redhat9.image.server-minimal.disk  
+Command (m for help): u  
+Changing display/entry units to sectors 
  
- Command (m for help): p 
+Command (m for help): p 
  
- Disk redhat9.image.server-minimal.disk: 0 MB, 0 bytes  
- 128 heads, 32 sectors/track, 0 cylinders, total 0 sectors  
- Units = sectors of 1 * 512 = 512 bytes 
+Disk redhat9.image.server-minimal.disk: 0 MB, 0 bytes  
+128 heads, 32 sectors/track, 0 cylinders, total 0 sectors  
+Units = sectors of 1 * 512 = 512 bytes 
  
- Device Boot Start End Blocks Id System  
- redhat9.image.server-minimal.disk1 * 32 3756031 1878000 83 Linux  
- redhat9.image.server-minimal.disk2 3756032 4194303 219136 82 Linux swap 
+ Device Boot Start End Blocks Id System  
+redhat9.image.server-minimal.disk1 * 32 3756031 1878000 83 Linux  
+redhat9.image.server-minimal.disk2 3756032 4194303 219136 82 Linux swap 
  
- Command (m for help): q 
+Command (m for help): q 
  
- # bc  
- bc 1.06  
- Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.  
- This is free software with ABSOLUTELY NO WARRANTY.  
- For details type `warranty'.  
- 32*512  
- 16384  
- # mount redhat9.image.server-minimal.disk /mnt -o loop,offset=16384 -t ext3 
+# bc  
+bc 1.06  
+Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.  
+This is free software with ABSOLUTELY NO WARRANTY.  
+For details type `warranty'.  
+32*512  
+16384  
+# mount redhat9.image.server-minimal.disk /mnt -o loop,offset=16384 -t ext3 
 </pre> 
  
 Sorted. 
  
 ! Compiling your own kernel 
+  
 This is a fairly trivial task if you are used to compiling kernels. The main point to remember is to add 
+  
 <pre> 
 ARCH=um 
 </pre> 
+  
 to each command (or export it as a shell variable). 
  
 In brief: 
+  
 <pre> 
-host$ make defconfig ARCH=um  
-host$ make ARCH=um  
-host$ mount -o loop ./root_fs /mnt/uml  
-host$ make modules_install INSTALL_MOD_PATH=/mnt/uml ARCH=um  
-host$ umount /mnt/uml 
+make defconfig ARCH=um  
+make ARCH=um  
+mount -o loop ./root_fs /mnt/uml  
+make modules_install INSTALL_MOD_PATH=/mnt/uml ARCH=um  
+umount /mnt/uml 
 </pre> 
+  
+If you're compiling on 64 bit Linux you will probably also need to add <tt>SUBARCH=i386</tt> as well.  
+  
+InNeedOfRefactor