Table of Contents

Cubuntu

Updated for Ubuntu Natty Narwhal 11.04

This page details the actions that I followed to create a network bootable copy of Ubuntu that was suitable for using in an internet cafe. The instructions show how to set up the server to serve a copy of the CD over NFS, along with the required network boot options, so that any client on the network can use Live Ubuntu just by network booting.

The instructions are written as a reminder for me on how to do it, but hopefully they are clear enough for anyone else to use. Feel free to update them to make it clearer!

Set up server for NFS booting

I make the assumption that the server runs Debian, but any server should do the job with the right packages.

Install required packages

Set up export images

/srv/ubuntu 10.0.0.1/255.255.0.0(ro,no_root_squash,async,subtree_check)
DEFAULT netboot

LABEL netboot
KERNEL vmlinuz
APPEND noapic initrd=initrd.lz lang=uk nfsroot=10.0.0.1:/srv/ubuntu netboot=nfs root=/dev/nfs boot=casper

Explicitly specify port numbers (optional)

If you want to close all the ports on your server, but open up the required ones for NFS, then you will need to fix the port numbers that NFS uses. To do this, do the following:

STATDOPTS="--port 32765 --outgoing-port 32766"
RPCMOUNTDOPTS="-p 32767"
RPCRQUOTADOPTS="-p 32769"
options lockd nlm_udpport=32768 nlm_tcpport=32768
# NFS ports as per the NFS-HOWTO
# http://www.tldp.org/HOWTO/NFS-HOWTO/security.html#FIREWALLS
# Listing here does not mean they will bind to these ports. 
rpc.nfsd        2049/tcp                        # RPC nfsd
rpc.nfsd        2049/udp                        # RPC nfsd
rpc.statd-bc    32765/tcp                       # RPC statd broadcast
rpc.statd-bc    32765/udp                       # RPC statd broadcast
rpc.statd       32766/tcp                       # RPC statd listen
rpc.statd       32766/udp                       # RPC statd listen
rpc.mountd      32767/tcp                       # RPC mountd
rpc.mountd      32767/udp                       # RPC mountd
rcp.lockd       32768/tcp                       # RPC lockd/nlockmgr
rcp.lockd       32768/udp                       # RPC lockd/nlockmgr
rpc.quotad      32769/tcp                       # RPC quotad
rpc.quotad      32769/udp                       # RPC quotad

Set up DHCP server

This is fully detailed in the other section on the site about a Setting up a captive portal from scratch using Debian, so it's best to check that for full details, but essentially you need the following lines in your /etc/dhcp3/dhcpd.conf file:

option root-path "10.0.0.1:/opt/ubuntu";
  filename "pxelinux.0";
  next-server 10.0.0.1;

Customising Ubuntu

This section is optional but recommended. If you already have a customised Ubuntu image, or are happy with the default one provided, then skip to the next step.

I won't provide full details here for extraction - please see the reference at the bottom of the page.

Customise as required

I assume that the squash filesystem has already been extracted and chrooted into.

Add/remove packages

Now use apt-get to add/remove packages as required. I did the following:

apt-get install joe

apt-get update

apt-get install lynx

apt-get install ubuntu-restricted-extras

Set up pre and post Gnome scripts

The following two scripts are set to run before Gnome starts and after Gnome has started. They call scripts on the NFS file store to copy in further customisations for the user. The reason for this is because once the squashfs image has been mastered it is difficult to alter small settings. These 2 scripts allow alterations to be carried out on the scripts in the NFS file store easily in the future.

This script looks for the /cdrom directory (which is the NFS mount point) and runs any scripts in /cdrom/custom/pre-gnome. This means that on the NFS share, files can be put in /srv/ubuntu/custom and copied using scripts in /srv/ubuntu/custom/pre-gnome

# pre-gnome - run any commands from the nfs share during boot

description     "copy files before gnome starts"
start on starting mountall
task

script
    . /etc/default/rcS

        if [ -x /cdrom/custom/pre-gnome ]; then
                for file in `ls /cdrom/custom/pre-gnome`; do
                        if [ "${file}" != "${file%""~""}" ]; then
                                continue
                        fi
                        /cdrom/custom/pre-gnome/$file /cdrom/custom/
                done
        fi

end script
#!/bin/sh

. /lib/lsb/init-functions

if [ -x /cdrom/custom/post-gnome ]; then
        log_begin_msg "Running post-gnome scripts (/cdrom/custom)"
        for file in `ls /cdrom/custom/post-gnome`; do
                if [ "${file}" != "${file%""~""}" ]; then
                        continue
                fi
                /cdrom/custom/post-gnome/$file /cdrom/custom/
        done
fi

chmod +x /usr/bin/post-gnome

[Desktop Entry]
Name=Remote Configure Script
Encoding=UTF-8
Version=1.0
Name[en_GB]=post-gnome
Exec=post-gnome
Comment=Copies over any files after Gnome has started
GenericName=Post Gnome Copy
Terminal=false
Type=Application
X-GNOME-Autostart-Delay=5
#!/bin/bash

while [ 1 ]
do
    # check that firefox is not already running
    if ps aux|grep 'firefox-bin'|grep -v 'grep' > /dev/null
    then
        echo nothing > /dev/null
    else
        # disable client from browsing web, forcing them to sign syops
        lynx -dump http://earth.wardroom/disable.php > /dev/null
        
        /usr/bin/firefox $1
        rm -fr /home/ubuntu/.mozilla/firefox/
    fi
    sleep 2
done

chmod +x /usr/bin/firefox.sh

Create /etc/xdg/autostart/firefox.sh.desktop

[Desktop Entry]
Version=1.0
Name=Firefox restart shell
Comment=Browse the World Wide Web
GenericName=Web Browser
Terminal=false
Type=Application
Exec=firefox.sh
X-GNOME-Autostart-Delay=5
Name[en_GB]=Firefox.sh

Other customisation

XKBMODEL="pc105"
XKBLAYOUT="gb"

Customise /etc/skel

/etc/skel contains the skeleton layout of the to-be-created ubuntu user. Add and remove files as required. (I just removed the Examples link)

Recreate image

rm /var/lib/dbus/machine-id
rm /sbin/initctl
dpkg-divert --rename --remove /sbin/initctl
rm /etc/resolv.conf
umount /proc || umount -lf /proc
umount /sys
umount /dev/pts

Exit from chroot

sudo umount edit/dev || sudo umount -lf edit/dev
rm filesystem.squashfs
sudo mksquashfs edit filesystem.squashfs

Set up scripts and files on server (optional - only required using customisation above)

Create directories /srv/ubuntu/custom/pre-gnome and /srv/ununtu/custom/post-gnome on the server and insert scripts as follows. The directories and the contents referenced in the scripts should also be created as required with custom settings in. To get the required settings, I ran a Live copy of Ubuntu, made my changes, and then copied the appropriate changed files to the server.

#!/bin/bash

cp -a $1/home/.gconf /home/ubuntu/.gconf
chown -R ubuntu.ubuntu /home/ubuntu/.gconf
cp -a $1/home/.mozilla /home/ubuntu/.mozilla
chown -R ubuntu /home/ubuntu/.mozilla
cp -a $1/home/.local /home/ubuntu/.local
chown -R ubuntu /home/ubuntu/.local
cp -a $1/home/.config /home/ubuntu/.config
chown -R ubuntu /home/ubuntu/.config

cp $1/printers.conf /etc/cups
cp $1/LaserJet-4050.ppd /etc/cups/ppd
/etc/init.d/cupsys force-reload

cp $1/ubuntumenu.png /opt

# A complete hack. ESD (for sounds) seems to make an error
# come up about gnome-settings-daemon
rm /usr/bin/esd
rm /etc/localtime
ln -s /usr/share/zoneinfo/Europe/London /etc/localtime
ntpdate -u pool.ntp.org
#!/bin/bash
echo "DefaultSession=gnome-classic" >> /etc/gdm/custom.conf

chmod +x /srv/ubuntu/custom/pre-gnome/ntp
chmod +x /srv/ubuntu/custom/pre-gnome/timezone
chmod +x /srv/ubuntu/custom/pre-gnome/gdm

#!/bin/bash

# This script runs on start up of gnome, to put hacks in that I couldn't get working

# A real hack to get the panel configured as required
# I couldn't get the default settings to work from /etc/gconf, so this
# script copies them in once gnome has started, and then restarts the panel.

sleep 4
rm -fr ~/.gconf
cp -a /cdrom/custom/home/.gconf .
gconftool-2 --shutdown
killall gnome-panel

Make the 2 scripts above executable (chmod +x copy)

The above example copy in the settings from /opt/ubuntu/custom/home. An example set of scripts that can be placed there are contained at http://www.andybev.com/web-portal/home.tar.gz. To use:

cd /srv/ubuntu/custom
wget http://www.andybev.com/web-portal/home.tar.gz
tar -zxvf home.tar.gz

Adding a printer

#!/bin/bash
cp $1/printers.conf /etc/cups
cp $1/LaserJet-4050.ppd /etc/cups/ppd
/etc/init.d/cupsys force-reload

chmod +x /srv/ubuntu/custom/pre-gnome/printer

References