UserModeMorphix

From MorphixWiki

Jump to: navigation, search

zelcpas boerda c4tgetba acellid elcoou

(I am Bill Burdick: bill at applied reasoning dot com)

Running a Live CD under UserModeMorphix is a matter of using a modified miniroot. You can find miniroot.gz on the liveCD, hiding in /base/boot.img, which is a dos disk image. 'Note' that these instructions do not encompass making X run. You can probably do that by creating a minimod that replaces X with Xnest and using the techniques presented herein to virtually add it to the liveCD.

Contents

[edit] To build it yourself...

[edit] Supplies

  • uml stuff: [1], You need the Morphix kernel source and the corresponding UML 'PATCH' and 'TOOLS'
  • morphix stuff: The KernelModifying page has cloop and tools, translucency, and loopAES. Also, you need a liveCD.


[edit] Activities

  • I'm not yet using loopAES, but if you are, you'll need to follow its instructions first ('DISABLING' the loop device, etc.).
  • Configure the kernel. Here are some instructions: [2]. 'NOTE:' you'll probably want to turn on 'ALL' of the nifty 'UML' features if you're not sure what you'll need in the future.
  • Compile the freshly patched kernel -- here are some instructions: [3]. You 'NEED' to follow the instructions (in particular, you need to specify ARCHum in 'EVERY' make command, including make dep ARCHum).
  • Compile cloop and translucency for the new UML kernel
  • Stuff the cloop.o module you compiled for uml into the miniroot.gz file system in /base/boot.img, in its /modules directory. Actually, you don't really need to put the miniroot back in your boot.img file. You can just keep it somewhere special for later. miniroot.gz is a gzip compressed minix file system, by the way.
  • Make sure you do a "make modules ARCHum". Next you probably want to set aside an install directory for your modules. You can place "export INSTALLMODPATH/home/bill/uml" in the top level Makefile to use your directory. Then do "make modules_install ARCHum" (note the tedious repetition of ARCHum).
  • copy the miniroot from the liveCD and mount it (mount -o loop mods mnt)
  • patch /linuxrc as follows (I'd paste a patch in here, but the wiki's markup interferes with it...). This will be a bit rough, because of the wiki markup rules...

After the mount -t devpts... line, place some code to detect whether it's running under user mode linux and if so, set the UML variable to true. It will look sort of like this:

 case "$(cat /proc/cpuinfo)" in 'User Mode Linux')
    UML=true
    echo "${RED}RUNNING UNDER USER MODE LINUX${NORMAL}"
    ;;
 esac

You don't need two stars in the case label, but this wiki eats them if I enclose it in single stars.

After the mountit /dev/cloop... line,

      if test -n "$UML"; then
          insmod -f /uml/cloop.o file=/cdrom/base/morphix
      else
          insmod -f /modules/cloop.o file=/cdrom/base/morphix
      fi
      mountit /dev/cloop /MorphixCD "-o ro" ||| FOUND_MORPHIX=""
      if test -n "$UML"; then
          /MorphixCD/bin/mount -t minix -o loop /uml/mods /lib/modules
      fi

Finally, if you want to add your own dynamic stuff for development, after the rm -f /linuxrc line,

   mkdir /tmp/mnt
   if /MorphixCD/bin/mount none /tmp/mnt -t hostfs -o uml-root; then
      /MorphixCD/bin/cp -aP /tmp/mnt /tmp/root
      /MorphixCD/bin/umount /tmp/mnt
   fi
   rmdir /tmp/mnt
   mkdir /tmp/oldbase
   /MorphixCD/bin/mount --bind /cdrom/base /tmp/oldbase
   if /MorphixCD/bin/mount none /cdrom/base -t hostfs -o uml-base; then
      ln -sf /tmp/oldbase/morphix.sh /cdrom/base/old-morphix.sh
      ln -sf /tmp/oldbase/boot.* /tmp/oldbase/morphix /cdrom/base
   else
      umount /tmp/oldbase
      rmdir /tmp/oldbase
   fi
  • create an empty minix file system called mods, big enough to hold your uml modules directory (mine is 128k):
dd if/dev/zero bs1024 count128 ofmods
  • mount it (mount -o loop mods mnt2)
  • copy the modules directory (mine is called 2.4.21-xfs-1um) into the mods filesystem and unmount it
  • create a directory the miniroot it called /uml and copy the cloop.o file and the mods file into it
  • This should be all you need to run your liveCD under uml==== ====

[edit] Running your UserModeMorphix liveCD

  • Copy or move your brand new linux executable out of your kernel source directory and put it somewhere special, along with your new modified miniroot (perhaps where you put the miniroot filesystem).
  • Ready? Here's the command to run it:

./linux initrdminiroot umida ubd0rmorph_cd devfsnomount ubd22 eth0tuntap,,,10.0.0.33

the initrd argument should contain your hacked miniroot filesystem

the ubd0r argument should contain your liveCD iso image

the eth0 argument contains the tunnel address, which should be a free IP. This creates a new tunnel interface on the 'host' system, not the virtual one. When you configure the virtual system, it will attach a tunnel device to the ip on the host that you provided. More here: [4].

For more details on running UML, see this: [5]

Please note that there seems to be a limit of 8 kernel arguments, so be careful. If you need to use more virtual file systems (other than hostfs, which is very convenient), you can use uml_mconsole to attatch more virtual devices once the machine is running.

[edit] Notes

The optional part of the linuxrc patch copies your uml-root directory (which should be in the current directory) to /tmp/root. This gives you a cheap way to get current files into your vm (like scripts and such) without much fuss. It then does some fast-talking and links the current contents of /base in your uml-base directory and then mounts your uml-base directory over /base. This is so you can put a morphix.sh file in there if you want to. It links the old morphix.sh as "oldmorphix.sh" so that your script can call it if it exists.

It may take some sneaky work to get minimods automatically inserted at run-time, but you can always fall back on placing a script in /tmp/root that you can run manually.

-- 'Update:' It did indeed take some sneaky work. I made my special morphix.sh file do some pretty eloborate sleight-of-hand to modify /etc/init.d/load-minimodules.sh -- this seems to be the best place to wedge in overrides. I changed that by catting a call to "preminimodules-hook.sh", followed by the original contents of load-minimodules.sh, followed by a call to "postminimodules-hook.sh". All this was done in league with a bunch of mount --bind and umount calls, so that only one extra mount was left, which seems unavoidable, because of the way the boot sequence goes. Anyway, using this technique, you can insert your own minimods into an unaltered liveCD at runtime with UML. This is what you would need to run X in UML, I believe. Feel free to contact me for the scripts, etc.

Personal tools