wiki:GentooNetkit

Gentoo Netkit Guest

In this page we are going to show how to build a Gentoo UML Guest Machine to use it with Netkit ( http://www.netkit.org )

You can follow this guide starting from ANY Linux distro. You will need ROOT privileges for many of the operations (mount umount..)

Gentoo Netkit root_fs

Execute the following commands to create a root_fs file with the gentoo stage3

Create the sparse file

cd ~/netkit2/fs/
dd if=/dev/zero of=netkit-fs-gentoo bs=1M count=0 seek=8000

We create a sparse file of 8GB, but feel free to adjust to your needs

Create a ext3 file system the sparse file, mount it and unpack the gentoo stage3 tarball

mke2fs -j -F netkit-fs-gentoo
mkdir /mnt/umlgentoo
sudo mount -o loop netkit-fs-gentoo /mnt/umlgentoo
cd /tmp/
wget ftp://ftp.unina.it/pub/linux/distributions/gentoo/releases/x86/2007.0/stages/stage3-i686-2007.0.tar.bz2
wget ftp://ftp.unina.it/pub/linux/distributions/gentoo/snapshots/portage-latest.tar.bz2
cd /mnt/umlgentoo
sudo tar -jxvf /tmp/stage3-i686-2007.0.tar.bz2
cd usr
sudo tar -jxvf /tmp/portage-latest.tar.bz2
cd /tmp
rm portage-latest.tar.bz2
rm stage3-i686-2007.0.tar.bz2

Of course select the mirror closest to you

Now edit /mnt/umlgentoo/etc/fstab

the new file will look like this:

# /etc/fstab: static file system information.
#
# noatime turns off atimes for increased performance (atimes normally aren't 
# needed; notail increases performance of ReiserFS (at the expense of storage 
# efficiency).  It's safe to drop the noatime options if you want and to 
# switch between notail / tail freely.
#
# The root filesystem should have a pass number of either 0 or 1.
# All other filesystems should have a pass number of 0 or greater than 1.
#
# See the manpage fstab(5) for more information.
#

# <fs>                  <mountpoint>    <type>          <opts>          <dump/pass>

# NOTE: If your BOOT partition is ReiserFS, add the notail option to opts.
#/dev/BOOT              /boot           ext2            noauto,noatime  1 2
/dev/ubda               /               ext3            noatime         0 1
#/dev/SWAP              none            swap            sw              0 0
#/dev/cdrom             /mnt/cdrom      audo            noauto,ro       0 0
#/dev/fd0               /mnt/floppy     auto            noauto          0 0

# glibc 2.2 and above expects tmpfs to be mounted at /dev/shm for 
# POSIX shared memory (shm_open, shm_unlink).
# (tmpfs is a dynamically expandable/shrinkable ramdisk, and will
#  use almost no memory if not populated with files)
shm                     /dev/shm        tmpfs           nodev,nosuid,noexec     0 0

chroot in the mount point and use passwd to set the root password.

Optional and untested

Get netkit-* files from the /etc/init.d of the default netkit root_fs and copy them in the /etc/init.d/ of the gentoo root_fs you are creating. Then into the chroot do the following:

rc-update add netkit-phase1 default
rc-update add netkit-phase2 default
rc-update add netkit-test-phase default

Umount the file system

cd ~/netkit2/fs/
umount /mnt/umlgentoo

TFC Kernel

If you need a TFC patched kernel go to NetkitTutorial

If you want a gentoo-sources kernel go on reading here ...

Gentoo Netkit Kernel

When you are into the chroot (remount the fs if you unmounted):

Sync the portage tree

echo nameserver 160.80.2.5 > /etc/resolv.conf
emerge --sync

Mask kernel sources and headers, because in latest kernel User Mode Linux does not work

echo '>'sys-kernel/linux-headers-2.6.17-r2 > /etc/portage/package.mask
echo '>'sys-kernel/gentoo-sources-2.6.19-r7 >> /etc/portage/package.mask

Emerge kernel sources

emerge gentoo-sources
cd /usr/src/linux
wget http://www.netkit.org/download/netkit-kernel/netkit-kernel-config-2.6.11.7-K2.2
mv netkit-kernel-config-2.6.11.7-K2.2 .config
make menuconfig ARCH=um

Customize your kernel config. Build static (is a specific UML option) if the host machine has different GLIBC than the machine you are creating.

make ARCH=um
make modules_install
exit

Once out of the chroot copy the vmlinuz file somewhere on your host file system

cp /mnt/umlgentoo/usr/src/linux/vmlinuz ~/netkit2/kernel/gentoo-kernel
cd /mnt/umlgentoo/usr/src/linux/
make modules_install INSTALL_MOD_PATH=$NETKIT_HOME/kernel/modules ARCH=um

Start your new Gentoo UML Guest Machine

vstart vm --verbose --con0=this -m netkit-fs-gentoo -k ~/netkit2/kernel/gentoo-kernel

Trouble with tty1

It should be noted that in /etc/inittab, the line should be using c0 and tty0. If using tty1 the system seems to hang after the line Starting local... but it is only missing the login prompt, the system is running in background.

Last modified 11 years ago Last modified on Dec 23, 2007, 2:52:36 PM