=====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 ====
* apt-get install tftpd-hpa
* apt-get install syslinux
* apt-get install nfs-kernel-server
==== Set up export images ====
* mkdir -p /srv/ubuntu/casper
* Copy filesystem.squashfs file from casper directory on Ubuntu live CD into /srv/ubuntu/casper/ (this will be customised later)
* Edit /etc/exports and add
/srv/ubuntu 10.0.0.1/255.255.0.0(ro,no_root_squash,async,subtree_check)
* cp /usr/lib/syslinux/pxelinux.0 /srv/tftp
* mkdir /srv/tftp/pxelinux.cfg
* Create the file /srv/tftp/pxelinux.cfg/default:
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
* Copy initrd.lz and vmlinuz from casper directory on Ubuntu CD into /srv/tftp/
* Restart the NFS server ''%%/etc/init.d/nfs-kernel-server%%'' ''%%restart%%''
* Start the TFTP server ''%%/etc/init.d/tftpd-hpa%%'' ''%%start%%''
==== 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:
* Edit /etc/default/nfs-common and add
STATDOPTS="--port 32765 --outgoing-port 32766"
* Edit /etc/default/nfs-kernel-server and add
RPCMOUNTDOPTS="-p 32767"
* Edit /etc/default/quota and add
RPCRQUOTADOPTS="-p 32769"
* Create /etc/modprobe.d/local.conf with the contents
options lockd nlm_udpport=32768 nlm_tcpport=32768
* Update /etc/services (not strictly necessary, but helps):
# 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|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:
* Install joe text editor
''%%apt-get install joe%%''
* Edit /etc/apt/sources.list to include universe and multiverse repositories (scroll to the end of the file and uncomment the repositories.)
* Update package lists:
''%%apt-get update%%''
* Install Lynx (needed for me to reset user's agreement of T&C)
''%%apt-get install lynx%%''
* Install non-freee packages (flash, java, etc)
''%%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.
* Pre-gnome
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
* /etc/init/pre-gnome.conf
# 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
* Create the post gnome script /usr/bin/post-gnome
#!/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
* Make it executable
''%%chmod +x /usr/bin/post-gnome%%''
* Enable it by creating /etc/xdg/autostart/post-gnome.desktop
[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
* Add firefox script (/usr/bin/firefox.sh) to automatically wipe out history and restart firefox when closed. The lynx dump logs onto our server to force it to disable the client temporarily and thus re-present the user with T&C.
#!/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
* Make it executable:
''%%chmod +x /usr/bin/firefox.sh%%''
* Make it autostart:
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 ===
* Delete /usr/share/applications/ubiquity-gtkui.desktop to disable install icon on desktop
* Delete /etc/xdg/autostart/update-notifier.desktop
* Delete /etc/xdg/autostart/nm-applet.desktop
* Delete /etc/skel/examples.desktop
* Run apt-get upgrade
* Edit /etc/default/keyboard for correct keyboard layout:
''%%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 ====
* See reference for full details
''%%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.
* /srv/ubuntu/custom/pre-gnome/copy
#!/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
* /srv/ubuntu/custom/pre-gnome/timezone
rm /etc/localtime
ln -s /usr/share/zoneinfo/Europe/London /etc/localtime
* Script to set the time automatically. Create /srv/ubuntu/custom/pre-gnome/ntp
ntpdate -u pool.ntp.org
* /srv/ubuntu/custom/pre-gnome/gdm (Script to set default window manager to gnome)
#!/bin/bash
echo "DefaultSession=gnome-classic" >> /etc/gdm/custom.conf
* Make them executable
''%%chmod +x /srv/ubuntu/custom/pre-gnome/ntp%%''\\
''%%chmod +x /srv/ubuntu/custom/pre-gnome/timezone%%''\\
''%%chmod +x /srv/ubuntu/custom/pre-gnome/gdm%%''
* /srv/ubuntu/custom/pre-gnome/copy
#!/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 ====
* To add a network printer, boot up into the live network copy of Ubuntu and install a printer to create the required cups files.
* Copy the following files from the local client into /srv/ubuntu/custom on the server:
* /etc/cups/printers.conf
* /etc/cups/pppd/printer-name.ppd
* Create a script in /srv/ubuntu/custom/pre-gnome (called printer) to copy the files on boot:
#!/bin/bash
cp $1/printers.conf /etc/cups
cp $1/LaserJet-4050.ppd /etc/cups/ppd
/etc/init.d/cupsys force-reload
* Make the script executable:
''%%chmod +x /srv/ubuntu/custom/pre-gnome/printer%%''
===== References =====
* [[https://help.ubuntu.com/community/LiveCDCustomization/6.06|Ubuntu Help - LiveCD customisation]]