Installation of RedHat Linux into User Mode Linux Kernel HOWTO.

I will only cover NFS-based installation of RedHat version 8.0 and 9 in here, but other versions should be pretty similar. FTP installation is similar except that netstg1.img should be modified instead of stage2.img
If you want to install Fedora Core 1 into UML, there is a simpler way to do this: See here
  1. First of all you need to obtain copy of RedHat 8.0 or 9 installation disks (first three disks of the 5 disks set). Unfortunatelly since average netizens do not have access to modify files on RedHat ftp site, you won't be able to install RedHat into UML directly from RedHat's ftp site.
  2. Also you need to get compiled user-mode kernel, here is config that worked for me, if you do not want this config, make sure that you must enable these options in your config:
    Without these options RedHat installation procedure is not able to see any hard disks for some reason.
    If you won't enable LVM, then RedHat disk detection subrotinue will crash and installation will be impossible
    CONFIG_UML_NET=y and also enable one of the transports
    Since we are going to install through virtual network, you need these network drivers.
    RedHat insatllation disk depend on initrd functioning
    Loopback mounts are also important for installation procedure.
    Initrd images are ext2 filesystem based, but stage2 images are CRAMS, so you need both of these filesystems.
    I am covering NFS based install here, so we need NFS support.
  3. Get bootnet.img file from images directory on 1st CD, (for RedHat 9 file name is boot.iso) loopback mount it (e.g. mount /path/bootnet.img /mnt -o loop) and save initrd.img file from there, you will need that file during installation.
  4. Copy content of RedHat directory of all three disks to some NFS-exported place, e.g. /exports, make sure that you have /exports/RedHat with two subdirs: base and RPMS.
  5. Now you need to modify base/stage2.img file in RedHat subdir, this is CRAMFS image. You need to mount it and copy all the files from there to some other subdir, say /tmp/img. Now you need to replace /tmp/img/usr/sbin/probe with this shell script. /usr/sbin/probe is a programs that detects pcmcia bridges, unfortunatelly it deadloops when run inside user-mode-linux. Don't forget to make that new /tmp/img/usr/sbin/probe executable. Here's the content of probe script for your reference:
    echo PCI bridge probe: not found.
    echo Intel PCIC probe: not found.
    echo Databook TCIC-2 probe: not found.
    exit 0

    Now you need to recreate stage2.img with new content, you can do this by using mkcramfs command. If your distribution does not contain this tool, you can get it from the kernel source in scripts/cramfs/mkcramfs.c. (It can be compiled with gcc -o /usr/local/sbin/mkcramfs /path/to/linuxsource/scripts/cramfs/mkcramfs.c -lz). Just run mkcramfs /tmp/img /exports/RedHat/base/stage2.img. Now you can remove content of /tmp.img. Or if you do not want to mess with all of that, you can get replacement stage2.img file from here (NO, I am sorry, there is nothing, if you can offer a hosting for this ~60M file, contact me) and put it in RedHat/base directory.
  6. Next step is to create a file in which your RedHat installation will live. For space-saving reasons I have created "sparse" file, so that only actually used blocks are allocated and take space on real disk. You can do this by this command: dd if=/dev/zero of=/path/uml_hdd bs=1024k count=1 seek=1024.. the seek=1024 specifies that resulting file will be 1024 megabytes in size, you can vary that number.
  7. Now we are ready to install. Run user-mode kernel with these parameters: /path/linux-2.4.19-uml/linux expert noprobe text initrd=/path/initrd.img lang= devfs=nomount ramdisk_size=10240 mem=240M eth0=tuntap,,, ubd0=/path/uml_hdd fakehd fake_ide con=xterm ubd=3. Don't forget to adjust paths accordingly. Also change eth0= parameters to suit your needs (read documentation here if necessary).
  8. Several xetrms will pop up on the screen and one of them will contain interface for installation program. Below are screenshots of all the menus you will be persented with with some explanations if needed.
    Sample view of the start of installation. We do not need any driver disks
    Choose language of installation program
    I am demonstrating nfs-based install
    Enter network configuration data.
    Enter NFS address and path to installation. In my case NFS server is located on host machine.
    We do not need any more device drivers.
    Of course our empty file doe not have any partition table, so let installer to create one
    I created one small swap partition and one big root partition
    Well, we do not really need any bootloaders ;)
    Confirm that we do not need bootloaders
    Confirm network settings, if you need networking after installation is complete - check "Activate on boot" box
    Now you have a change to finetune your packageselection
    Installation is now copying files, this m ight take some time.
    Of course we do not need any kind of bootdisks.
    When this xterm disappears, stop the UML with ^C.
  9. Now the insatllation is complete, but we need to adjust some misunderstandings made by installer. Run user-mode linux like this: /path/linux lang= devfs=mount mem=240M eth0=tuntap,,, ubd0=/path/uml_hdd fakehd fake_ide con=xterm ubd=3 root=6201.(See below on how I got 6201 number)
    Notice devfs=mount part, without it you would not be able to boot, since RH installer forgot to install necessary device files for unknown reason. We are going to correct that.
    Some xterm windows will appear on screen once again, but none of them will contain login prompt. This is because Installer thought we are installing via serial console, so it did not started any gettys on virtual terminals. Also you might spotted there were other errors doring initial bootup. We will fix those too.
    login into UML by it's previously assigned network address ( in my case) with slogin. Also copy dev-3.3.1-2.i386.rpm file from RedHat/RPMS directory into virtaul machine (e.g. by using scp). Become root.
    Now the tricky part - we cannot directly install that dev-3.3.1-2.i386.rpm package since /dev is mounted as devfs. To overcome that issue mount /dev/root /mnt command. Now we have copy of our / on /mnt except that it is true / without filesystems mounted over it. Now we can install the package with: rpm -i --root /mnt /path/dev-3.3.1-2.i386.rpm
    Also open /etc/fstab and replace LABEL=/ substring in there with /dev/hda1, this is necessary to avoid subsequent mount segfaults.
    Edit /etc/inittab: put a '#' sign in front of co:2345:respawn:/sbin/agetty ttyS0 38400 vt100 line since we are not really need serial console, and uncomment some lines with mingetty (they are located just after newly commented line). Amount of lines you uncomment will equal to number of virtual terminals with login prompts on subsequent boots.
  10. Now halt the UML. by issuing halt command.
  11. You can now build another user-mode kernel image with all the cruft nt compiled in. To start the virtual machine with RedHat you should issue this comand: /path/linux mem=240M eth0=tuntap,,, ubd0=/path/uml_hdd fakehd fake_ide con=xterm ubd=3 root=6201. Of course you can vary networking and available memory parameters as usual. The important parameters are: root=6201 and ubd=3. Note that number 6201 implies that your virtual root partition is located at virtual /dev/hda1 device, if you put it in other place - be sure to replace the 1 in that number with correct partition number. (If you compile devfs to automatically mount at boot or if you use "recommended" kernel RPMs from site then you also need to add this command line option: devfs=nomount

Brought to you by Oleg Drokin