Vyatta‎ > ‎

How-to create a vyatta image for netkit

[italian version]

It's quite easy to create a vyatta image for netkit (www.netkit.org).

First of all, Vyatta requires a kernel with unionfs support. So, let's recompile a netkit kernel patched with unionfs:
we must download unionfs patch from the unionfs website, and copy the diff file onto the kernel/patches directory of our netkit installation (supposed /opt/netkit).
Then, from the kernel directory, exec

# make -f Makefile.devel kernel

(I had some problems recompiling with bash4, must use bash3)

To created the filesystem image I started from vyatta's vmware official one.
Using qemu-img I converted the vmware image to a simple raw image:

# qemu-img convert -O raw VyattaCommunity5.vmdk VyattaCommunity5.img

and I used fdisk to read the partition table:

# fdisk -lu VyattaCommunity5.img
Disco VyattaCommunity5.img: 0 MB, 0 byte
255 testine, 63 settori/tracce, 0 cilindri, totale 0 settori
Unità = settori di 1 * 512 = 512 byte
Identificativo disco: 0x0000df0c

          Dispositivo Boot      Start         End      Blocks   Id  System
VyattaCommunity5.img1              63     4192964     2096451   83  Linux

I created a sparse image file, I mounted it and I copied the vyatta system data into it:

# dd if=/dev/zero of=vyatta-root-fs bs=1M count=1 seek=2000
# mke2fs -j -O large_file vyatta-root-fs
# mkdir mnt1 mnt2
# mount -o loop,offset=32256 VyattaCommunity5.img mnt1/
# mount -o loop vyatta-root-fs mnt2/
# rsync -vatP mnt1/ mnt2/
# umount mnt1

(offset is 63 * 512)

Now we have to "customize" the filesystem image: I moved to the "root" mount directory:

# cd mnt2

I created some required devices:

# cd dev
# mknod ubda b 98 0
# cd ..

The file etc/fstab must be like the following:

/dev/ubda / ext3 defaults 0 1

and I copied the kernel modules from the netkit kernel directory:

# cd lib/modules
# cp -a /opt/netkit/kernel/modules/lib/modules/2.6.26.5-netkit-K2.7 .
# cd ../..


Then I copied some customized init scripts from the netkit fs directory:

# cd etc/init.d
# cp /opt/netkit/fs/fs-build/netkit-tweaks/filesystem-tweaks/etc/init.d/netkit-phase1 .
# cp /opt/netkit/fs/fs-build/netkit-tweaks/filesystem-tweaks/etc/init.d/netkit-phase2 .
# cd ../rc2.d
# ln -s ../init.d/netkit-phase1 S00netkit-phase1
# ln -s ../init.d/netkit-phase2 S99netkit-phase2
# cd ../..

I chrooted into the root_fs image to install the mingetty debian package:

# chroot .
(chroot)# echo "nameserver 194.20.8.1" > /etc/resolv.conf
(chroot)# mount -t proc proc /proc
(chroot)# cd /root
(chroot)# wget http://debian.fastweb.it/debian/pool/main/m/mingetty/mingetty_1.07-1_i386.deb
(chroot)# dpkg -i mingetty_1.07-1_i386.deb
(chroot)# rm mingetty_1.07-1_i386.deb
(chroot)# umunt /proc
(chroot)# exit


and finally I edited the etc/inittab file, having the system console section like this:

1:2345:respawn:/sbin/mingetty --noclear --noissue --autologin vyatta tty0
2:23:respawn:/sbin/getty 38400 tty1
#3:23:respawn:/sbin/getty 38400 tty3
#4:23:respawn:/sbin/getty 38400 tty4
#5:23:respawn:/sbin/getty 38400 tty5
#6:23:respawn:/sbin/getty 38400 tty6

and the serial console section commented like this:
#T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100

Now we can umount our root image:

# umount mnt2

and try it out with netkit :)

$ vstart vyatta1 --verbose -M 64 -m vyatta-root-fs --eth0=lan1 --eth1=lan2




ċ
netkit-kernel-i386-K2.7.tar.bz2
(2887k)
Stefano Sasso,
20 set 2009, 04:21