Jump to: navigation, search

How to create a mini rootfilesystem starting from a N3VLR image


Download N3VLR image from http://www.n3network.ch/resources/n3vlr/n3vlr-0.11-uml.tar.bz2

Extract the rootfs image:

tar xvfj n3vlr-0.11-uml.tar.bz2

Copy the original rootfs image to a new file and mount it :

cp n3vlr-0.11-uml.img n3vlr-0.11-vnuml.img
mount -o loop n3vlr-0.11-vnuml.img /mnt/

Create vnuml directories and umlboot link:

mkdir /mnt/mnt/vnuml
mkdir /mnt/mnt/hostfs
ln -s /mnt/vnuml/umlboot /mnt/etc/init.d/S40bootuml
echo "/dev/ubdb     /mnt/vnuml iso9660     defaults    0 0" >> /mnt/etc/fstab

Change the content of /mnt/etc/inittab to:

tty0::respawn:/sbin/getty 38400 tty0
tty1::respawn:/sbin/getty 38400 tty1
tty2::respawn:/sbin/getty 38400 tty2

Create the /dev/ubd[a-h] nodes using the makeUBDdev.sh script (see the complete script below taken from http://www.theshore.net/~caker/uml/)

cd /mnt/dev

Change root password:

chroot /mnt /bin/ash
passwd root
  (set password to xxxx)

Edit the file /mnt/etc/ssh/sshd_config in order to make it work with ssh v1:

# What ports, IPs and protocols we listen for
Port 22
Protocol 2,1
# HostKeys for protocol version 1
HostKey /etc/ssh/ssh_host_key
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes
# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
ServerKeyBits 768
# Logging
SyslogFacility AUTH
LogLevel INFO
# Authentication:
LoginGraceTime 120
PermitRootLogin yes
StrictModes yes
RSAAuthentication yes
PubkeyAuthentication yes
# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords no
# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no
X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
#UseLogin no
# Allow client to pass locale environment variables
AcceptEnv LANG LC_*
Subsystem sftp /usr/lib/openssh/sftp-server
UsePAM yes

Install bash shell in mini rootfs:

  1. Download from http://downloads.openwrt.org/kamikaze/7.09/x86-2.6/ the file openwrt-x86-2.6-ext2.fs and mount in ~/tmp ,for example.
  2. Download from http://downloads.openwrt.org/kamikaze/packages/i386/ the package bash_3.2-1_i386.ipk
  3. Do
chroot ~/tmp /bin/ash
ipkg install bash_3.2-1_i386.ipk
cp ~/tmp/bin/bash /mnt/bin/
cp ~/tmp/lib/libgcc_s.so.1 /mnt/lib
umount ~/tmp

Change the content of /mnt/etc/passwd to:


Create symbolic links to have quagga daemons accesible through the same path than root_fs_tutorial:

cd usr/lib/
mkdir quagga
cd quagga/
ln -s /usr/sbin/zebra 
ln -s /usr/sbin/ospfd
ln -s /usr/sbin/ospf6d
ln -s /usr/sbin/ripd
ln -s /usr/sbin/ripngd
ln -s /usr/sbin/bgpd

Create /etc/root_fs-version with content:


Unmount the filesystem:

umount /mnt


  1. In order to use this mini rootfs, you must apply the patch that includes the following changes:
    1. Replacement of the command line in shell scripts because lots of filesystem don't include that command.
    2. Replacement of the uml_console command cad because it doesn't work with this mini rootfs.
  2. Shell. You have to force the shell to be used by vnuml in the virtual machine to /bin/bash with: <shell>/bin/bash</shell>
  3. The directory of demons is usr/sbin/. You can try this mini rootfs with these examples:
    1. Example-OSPF (ospf_lab.xml, ospf_lab_tiny.xml, ospf_lab_conf.tar)
    2. Example-BGP (bgp.xml, bgp.tar)

makeUBDdev.sh script

for u in a b c d e f g h
        do dev=$device$u
        mknod $dev b $major $minor
        chmod 660 $dev
        chgrp disk $dev
        for i in $(seq 1 15)
                mknod $dev$i b $major $(($minor + $i)) 
                chmod 660 $dev$i
                chgrp disk $dev$i
        minor=$(($minor + 16))