Gentoo 1.4_rc2 in RedHat 8.0 using UML
This document describes one case to install Gentoo Linux 1.4_rc2 into
RedHat 8.0 using User Mode Linux.
Warning: This document is still under revising.
Besides, the link to the original document doesn't work.
Sorry for the inconvenience.
Gentoo in RedHat? Yes, actually. If you want to try Gentoo and you
have free partition in your disk, you can install Gentoo just by
following the standard installation procedure (e.g. one for x86). But some of you
cannot do it due to lack of free partition or disk, just because you
have already assigned entire disk space to your former installation.
You would have some other reason to leave the current OS. In those
cases, UML (User
Mode Linux) will be a choice. UML is a linux kernel runs as
a non-root user process. Necessary filesystems are given as files.
You can install any distribution using UML if its installer works well
on UML. But it seems that always some hacks are necessary for it
because an installer has to check devices automatically but UML
doesn't have it.
If you are using Gentoo and want to run UML with Gentoo, see Gentoo Linux Developer's guide to system testing
with User-Mode Linux . If you are using rpm-based distro and
plan to run UML with rpm-based distro, UML Builder will help
you a lot. But I wanted to install Gentoo but leave RedHat as I used
before. I found no document targetting such specific case, so I
thought it would be nice to write a document for it.
I didn't research so deeply why these steps are required. I just
followed the boot sequence and added some steps required on UML. In
case you find faster/simpler procedure than I wrote, please give me a
- Install Gentoo 1.4_rc2 into UML on RedHat 8.0 in an x86 machine.
- Without compiling UML kernel. Use the standard UML kernel 2.4.19-5um provided in
RPM file available from UML Project.
Summary in short
This chapter describes what to be prepared to boot up the installer
||LiveCD ISO image
||RAM disk image to boot at first
||filesystem for installation: converted from /livecd.cloop in
the ISO image filesystem
||root filesystem for UML you install Gentoo
||swap filesystem for UML
Additionally you need to install UML using RPM file. It will require
root privilege on the host system and the use of the command
If you know how to prepare them, or you already made it and going
through the procedure described in this page, go boot.
Extract initrd from ISO image
Code listing 3.1
% isoinfo -i /path/to/gentoo-basic-x86-1.4_rc2.iso -x '/ISOLINUX/INITRD.;1' > initrd
Kernel starts with initial ramdisk image (aka initrd).
It is usually on a bootable intstall CD with a kernel and starts at
the CD booting procedure. You will have to do it with the UML kernel.
So you have to extract initrd in advance.
Retrieve cloop extractor and extract livecd
livecd.cloop is another filesystem which contains the
installation environment used after the first boot. It is mounted via
the compressed loopback (aka cloop) filesystem in a normal
installation procedure using LiveCD. But the standard UML kernel
available at the
UML project page cannot use cloop module in the LiveCD. So I
decompressed it in my preparation stage so that I can easily mount it
in a normal way. This section consists of two steps.
The first step is to make the decompress command. It is provided
in a cloop package available at Knopper's website.
Code listing 3.2
% wget http://www.knopper.net/download/knoppix/cloop_0.66-1.tar.gz
% tar xzf cloop_0.66-1.tar.gz
% cd cloop-0.66
% vi Makefile
% make zcode
% make extract_compressed_fs
% cd ..
The second step is to extract livecd.cloop and
Code listing 3.3
% isoinfo -i /path/to/gentoo-basic-x86-1.4_rc2.iso -x '/LIVECD.CLOOP;1' > livecd.cloop
% cloop-0.66/extract_compressed_fs livecd.cloop > livecd
Note: livecd is an ext2 filesystem.
Install UML and extract modules for 2.4.19-5um
Here you need to run UML with a pre-built UML kernel and a pre-built
filesystem. It will not take time if you install UML using RPM file.
After that, boot the UML kernel and log in as root. Please refer
other documents for details to run a UML kernel with a pre-built
After starting you UML with non-Gentoo distro, you need to extract
module files to avoid errors during UML network configuration for your
Gentoo installation later. Just make a tarball of modules from UML.
Code listing 3.4
# rpm -ivh user_mode_linux-184.108.40.206um-0.i386.rpm
% linux ubd0=root_fs.rh-7.2-full.pristine.20020312
# mkdir /mnt/loop
# mount none /mnt/loop -t hostfs -o /path/to/gentoo-working-dir
# cd /
# tar cf /mnt/loop/modules-2.4.19-5um.tar lib/modules/2.4.19-um
# shutdown -h now
/path/to/gentoo-working-dir is the path of the working
directory in your host filesystem.
Create root and swap filesystem
You will need root filesystem and swap filesystem as a normal file to
install Gentoo Linux into. This example configures the size to 500MB
for / and 200MB for swap.
Code listing 3.5
% dd if=/dev/zero of=rootfs_gt1.4 seek=500 count=1 bs=1M
% mke2fs -F rootfs_gt1.4
% dd if=/dev/zero of=swapfs seek=200 count=1 bs=1M
% mkswap -f swapfs
Check your preparation
Check if you get these files in your working directory.
Code listing 3.6
Boot the installer with the UML kernel
Code listing 4.1
% linux \
Warning: IP address in the command line has to be modified to assign your
host's IP to the tap device.
Important: Some of the kernel command line options could be unnecessary or
need to be modified to fit your case.
In this "booting" there is an IP address specified in the kernel
options. This is an address for tap0, which is a virtual
device to route packets between the host and UML. It is okay to
specify the same IP address which is assigned to the host's real
device. The IP address for the UML virutla machine will be configured
Initial RC command
After invoking /linuxrc,
you will be requested to select the keymap.
Then, you will get an error that CD drive is not detected.
That's okay because your UML kernel doesn't have any CD drive,
though your host system should have.
Code listing 4.2
You may want to start the kernel with init=/linuxrc argument.
In that case, you don't get the virtual consoles
and important error output during installation will go away
with the normal output.
Mount ISO image in your host
Now you are running UML kernel with (virtually) no CD drive, but
the CD image file is on your host's current directory. You can use it
within UML by mounting the host's filesystem.
Code listing 4.3
# mkdir -p /mnt/host
# mount none /mnt/host -t hostfs -o /path/to/gentoo-working-dir
# mount /mnt/host/gentoo-basic-x86-1.4_rc2.iso /newroot/mnt/cdrom -o loop
# mount -o ro,loop -t ext2 /mnt/host/livecd /newroot/mnt/cloop
Continue the boot process by hand
Code listing 4.4
# cd /newroot
# ln -s mnt/cloop/bin
# ln -s mnt/cloop/sbin
# ln -s mnt/cloop/boot
# ln -s mnt/cloop/usr
# ln -s mnt/cloop/opt
# mkdir initrd proc tmp
# chmod 1777 tmp
# (cd /newroot/mnt/cloop; cp -a etc root home var lib /newroot)
# tar xf /mnt/host/modules-2.4.19-5um.tar
# echo "6" > /proc/sys/kernel/printk
# umount /proc
# pivot_root . initrd
# chroot .
Configure UML network
Code listing 5.1
# mount /proc
# net-setup eth0
Important: You have to assign different IP from the UML tap's.
Warning: The author couldn't configure well on the host which has two
network connections and host's eth0 was not connected. If you are
trying that case, please check the routing command lines shown on the
virtual console. The author recommends to use a host with only one
Optional: Proxy configuration
If you use a proxy to access outside, set these variables.
Code listing 5.2
# export http_proxy="proxy.of.company.com:1234"
# export ftp_proxy="$http_proxy"
# export RSYNC_PROXY="$http_proxy"
Mount filesystems for installation
Code listing 5.3
# swapon /dev/ubd/1
# mkdir /mnt/gentoo
# mount /dev/ubd/0 /mnt/gentoo
# mkdir /mnt/gentoo/proc
# mkdir /mnt/gentoo/dev
# umount /proc
# cd /mnt/gentoo
# tar xjpf /mnt/cdrom/gentoo/stage1-x86-1.4_rc2.tbz2
# mount -o bind /proc /mnt/gentoo/proc
# mount -o bind /dev /mnt/gentoo/dev
# nano -w /etc/resolv.conf
# cp /etc/resolv.conf /mnt/gentoo/etc
# chroot /mnt/gentoo /bin/bash
If you forget to swapon,
installation would fail due to lack of memory space.
6.After chroot again
Try to emerge!
Code listing 6.1
# source /etc/profile
# emerge sync
# source /etc/profile
# emerge sync
Here you reached just at the start line of the the normal installation
from stage1 tarball.
Code listing 7.1
# cd /usr/portage
It will take quite a while for this stage
because UML is rather slow especially for disk access.
In the author's case,
it doesn't finish in half a day using a notebook (PCG-C1VSX/K) with a
TM5600@667MHz and 256MB memory and running a UML kernel with mem=128m.
In arthor's case, the UML kernel finally stopped with a message of
out of memory followed by kernel panic.
Stage2 and more
You will need to go on to the next stage. Just follow the instruction
shown in Gentoo Linux
1.4_rc2 Installation Instructions.
At least you will need to emerge some times and umount two filesystems
for Gentoo and swap for UML after the installation of Gentoo 1.4_rc2.
Note: This document describes only the case using Stage 1 tar ball.
You can use Stage 2 or 3 tar ball to accelerate your installation.
Important: This document doesn't cover whole installation procedure after
Stage 1. You are encouraged to refer to the installation-related
documents: Gentoo Linux 1.4_rc2
Installation Instructions and Gentoo
Linux Developer's guide to system testing with User-Mode Linux.
8.Starting your UML with Gentoo 1.4_rc2
Once you install Gentoo 1.4_rc2, you can start it simply with no network configuration:
Code listing 8.1: Starting Gentoo 1.4_rc2
% linux ubd0=root_gt1.4 ubd1=swapfs
or with some more arguments:
Code listing 8.2: Starting Gentoo 1.4_rc2 #2
% linux umid=Gentoo1.4_rc2 ubd0=root_gt1.4 ubd1=swapfs mem=128m eth0=ethertap,tap0,,192.168.x.x
Warning: Again, IP address in the command line has to be modified to
assign your host's IP to the tap device.