Tuesday, 30 November 2010

Backing up Entire Drives with [dd]

If you want to backup a partition use, [partimage]. It is excellent, and will happily achieve the task.

If, on the other hand, you want to backup the whole disk, there does not seem to me to be an OS alternative other than [dd].

To backup the [i]nput [f]ile (because in linux EVERYTHING is a file) [dev]ice [sda] in chunks with a [s]ize of 1 [M]ega[b]yte, [|] piping all data to the [bzip2] program set at the highest encryption setting [-9] to [>] the file [disk_image.301110.img.bz2] on the share [backup/reception] on the cifs server [readynasduo.local] from a live [ubuntu] user's account (having first browsed to the CIFS share, run this command:

sudo dd if=/dev/sda bs=1M | bzip2 -9 >'/home/ubuntu/.gvfs/backup on readynasduo.local/reception/disk_image.301110.img.bz2'

LFS - Powertop & acpi

Powertop is a system which is supposed to help you save battery life on a portable PC by identifying areas to optimise. Powertop requires lspci (optional) which in turn wants 'which', so:

wget ftp://ftp.gnu.org/gnu/which/which-2.20.tar.gz
tar -xzvf which-2.20.tar.gz
cd which-2.20
./configure --prefix=/usr &&
make
make install
cd ..
rm -rvf which-2.20

wget http://www.kernel.org/pub/software/utils/pciutils/pciutils-3.1.7.tar.bz2
tar -xjvf pciutils-3.1.7.tar.bz2
cd pciutils-3.1.7
make PREFIX=/usr ZLIB=no
make PREFIX=/usr install
make PREFIX=/usr install-lib
update-pciids
cd ..
rm -rvf pciutils-3.1.7

wget http://www.lesswatts.org/projects/powertop/download/powertop-1.13.tar.gz
tar -xzvf powertop-1.13.tar.gz
cd powertop-1.13
make
make install
cd ..
rm -rvf powertop-1.13.tar.gz

Just leave it running for 5+ minutes and you will get an estimate of usage.

Another useful power tool is acpi for getting battery information, and you install as follows:

wget http://sourceforge.net/projects/acpiclient/files/acpiclient/1.5/acpi-1.5.tar.gz/download
tar -xzvf acpi-1.5.tar.gz
cd acpi-1.5
./configure --prefix=/usr
make
make install
cd ..
rm -rvf acpi-1.5

Friday, 26 November 2010

Extra Openbox Menu Items

Some items to add to the Openbox menu:

Here is an entry for Firefox 4 beta:

<item label="firefox"><action name="Execute"><execute>/opt/firefox4/bin/firefox</execute></action></item>

Here is an entry to Suspend the machine to RAM. I cannot get this actual command to run, so I have to pop the command in a script and then run the script. There has to be a better way of doing this.

<item label="Suspend to RAM"><action name="Execute"><command>~/str.sh</command></action></item>

cat > ~/str.sh << "EOF"
echo mem > /sys/power/state
EOF

The next two items would be good in the system section - Powertop for useful battery information, and top for system process information.

<item label="Powertop"><action name="Execute"><command>xterm -e /usr/bin/powertop</command></action></item>

<item label="Top"><action name="Execute"><command>xterm -e /usr/bin/top -i</command></action></item>

Friday, 19 November 2010

LFS - Fonts

The standard font that X comes with is, bluntly, shit. So lets install some new fonts to brighten everything up.

Firstly, setup the directory to store the downloaded files in:

mkdir /sources/fonts
cd /sources/fonts

Next download a bog standard, and nice looking, free font, Dejavu. The commands basically 1. make a folder in /usr/share/fonts 2. copies all ttf files into that directory 3. runs the program fc-cache to load the ttf files.

wget http://sourceforge.net/projects/dejavu/files/dejavu/2.32/dejavu-fonts-ttf-2.32.tar.bz2/download
tar -jxvf dejavu-fonts-ttf-2.32.tar.bz2
cd dejavu-fonts-ttf-2.32/ttf
install -v -d -m755 /usr/share/fonts/dejavu &&
install -v -m644 *.ttf /usr/share/fonts/dejavu &&
fc-cache -v /usr/share/fonts/dejavu
cd ../../
rm -rf dejavu-fonts-ttf-2.32

Next we are going to install some Microsoft fonts - which are freely licensed. To do this we are going to need a bit of software to unpack the Microsoft archive:

wget http://www.cabextract.org.uk/cabextract-1.2.tar.gz
tar -xzvf cabextract-1.2.tar.gz
cd cabextract-1.2
./configure --prefix=/usr &&
make
make install
cd ..
rm -rf cabextract-1.2

Now we need to get the fonts:

wget http://sourceforge.net/projects/corefonts/files/the%20fonts/final/andale32.exe/download
wget http://sourceforge.net/projects/corefonts/files/the%20fonts/final/arial32.exe/download
wget http://sourceforge.net/projects/corefonts/files/the%20fonts/final/arialb32.exe/download
wget http://sourceforge.net/projects/corefonts/files/the%20fonts/final/comic32.exe/download
wget http://sourceforge.net/projects/corefonts/files/the%20fonts/final/courie32.exe/download
wget http://sourceforge.net/projects/corefonts/files/the%20fonts/final/georgi32.exe/download
wget http://sourceforge.net/projects/corefonts/files/the%20fonts/final/impact32.exe/download
wget http://sourceforge.net/projects/corefonts/files/the%20fonts/final/times32.exe/download
wget http://sourceforge.net/projects/corefonts/files/the%20fonts/final/trebuc32.exe/download
wget http://sourceforge.net/projects/corefonts/files/the%20fonts/final/verdan32.exe/download
wget http://sourceforge.net/projects/corefonts/files/the%20fonts/final/webdin32.exe/download

We then install the fonts using a bit of a script to automate the repetitive commands. Apart from the cabextract command basically we are doing the same as the Dejavu commands above.

for msfont in andale32 arial32 arialb32 comic32 courie32 georgi32 impact32 times32 trebuc32 verdan32 webdin32
do
mkdir $msfont
cabextract $msfont.exe -d $msfont
cd $msfont
install -v -d -m755 /usr/share/fonts/$msfont
install -v -m644 *.TTF /usr/share/fonts/$msfont
install -v -m644 *.ttf /usr/share/fonts/$msfont
fc-cache -v /usr/share/fonts/$msfont
cd ..
rm -rf $msfont
done

I am not entirely sure if this last step actually does anything, but it is supposed to make a config file which anti aliases the fonts.

cat > ~/.fonts.conf << "EOF"
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
 <match target="font">
   <edit name="autohint" mode="assign">
     <bool>true</bool>
   </edit>
 </match>
</fontconfig>
EOF

Friday, 12 November 2010

Command Line F1 Live Timing

Live Timing is pretty much essential for any self respecting F1 fan. It lets you follow what is going on for every car, so you are not restricted to what ever the (usually braindead) director chooses to show you from time to time.

Bad news. It needs Java to work. This is unfortunate if you want it to run on an inexpensive Netbook which struggles with Java. Also, it crashes from time to time, and restarting a browser and reloading a Java page is not much fun.

Helpfully some chap has written a command line client for live timing, and you can get it here:

wget http://launchpad.net/live-f1/0.2/0.2.10/+download/live-f1-0.2.10.tar.gz

You install it as follows:

tar -xzvf live-f1-0.2.10.tar.gz
cd live-f1_0.2.10
./configure
make

The software will now be available in the [./src] directory, and you can run it by typing:

./src/live-f1

You need to set up your user/password file in [~] as follows:

cat > ~/.f1rc << "EOF"
email YOUR_EMAIL_ADDRESS
password YOUR_PASSWORD
EOF

OBVIOUSLY you change the YOUR_X bits to match your log on details from the Live Timing's website.

Friday, 5 November 2010

Wireless Networking on Maverick

Once I shifted to Maverick Meercat, I found that the drivers became obstinate. Helpfully the Broadcom folks have uploaded a couple of patches which sorts this out. These are then, updated instructions on how to get the fucking thing to work.

cd /media/2G
wget http://www.broadcom.com/docs/linux_sta/hybrid-portsrc-x86_32-v5.60.48.36.tar.gz 
wget http://www.broadcom.com/docs/linux_sta/sta_5.60.48.36_2.6.33_kernel_patch.zip
wget http://www.broadcom.com/docs/linux_sta/sta_5.60.48.36_2.6.34_multicast_kernel_patch.zip

My USB Stick is called [2G] so Ubuntu automounts it into a directory with the same name in [/media]. The next command downloads the latest version of the hybrid driver. I am not sure what a hybrid driver is, but if I had to guess I would say it is a driver AND firmware contained in the same package. Incidentally, you could just use the same URL in windows and save the file to the USB Key. You then reboot to the USB Key and run the following commands (ideally from a script):

cd /tmp
cp /cdrom/hybrid-portsrc-x86_32-v5.60.48.36.tar.gz .
mkdir hybrid_wl 
cd hybrid_wl 
tar -xzvf ../hybrid-portsrc-x86_32-v5.60.48.36.tar.gz
unzip /cdrom/sta_5.60.48.36_2.6.33_kernel_patch.zip
patch -p0 < patch
unzip /cdrom/linux_sta/sta_5.60.48.36_2.6.34_multicast_kernel_patch.zip
patch -p0 < patch_hybrid_multicast
make clean
make
sudo rmmod b43 
sudo rmmod b44 
sudo rmmod b43legacy
sudo rmmod wl
sudo rmmod ssb 
sudo rmmod ndiswrapper 
sudo rmmod lib80211
sudo modprobe lib80211
sudo insmod wl.ko

The [cp] commands [c]o[p]ys the file we downloaded into the current [.] directory, which is [/tmp] because we just moved into it. The patch commands change the source code files in terms of the instructions contained in the special patch files.

There are lots of [r]e[m]ove [mod]ules commands, because there are so many modules which potentially interfere with the [wl] driver. Again, once this script has finished, the interface should be up and running. This one will take a little longer to run because it is building the module from source code each time.

Friday, 29 October 2010

Making a Maverick Live CD

This is a simple update of my live CD instructions, but this time updated for Maverick Meercat. This time I am going to leave the original CD image on removable media to cut down the space taken up by this operation.

First of all we are going to need some extra packages for our running system to manipulate the CD image. To install these, run this command from a terminal window.

sudo aptitude install squashfs-tools genisoimage

The CD image contains one large archive file which stores all of the disk environment for the LiveCD. The squashfs-tools handles this archive. Basically, we unpack everything, add our extra packages, and then repack everything. The genisoimage [gen]erates the final [iso] [image] which we put onto the USB Key in due course.

Now, make a working directory in [~] home, and copy the image file into it:

mkdir ~/live
cd ~/live

Next we are going to actually mount the CD image so we can use it as if we had burned it to a CD and inserted it. We need to create the mount point first of all:

mkdir mnt
sudo mount -o loop /media/[whatever]/ubuntu-10.10-desktop-i386.iso mnt

The [whatever] will differ depending on exactly where your system mounts the USB Key you just plugged in. The loop [o]ption allows us to mount the image file as a folder.

Now we need to copy all of the files off the mounted image APART from the large squashed file. Again we want a separate folder to store these files:

mkdir extract-cd
rsync --exclude=/casper/filesystem.squashfs -a mnt/ extract-cd

Next we need to extract the big archive file:

sudo unsquashfs mnt/casper/filesystem.squashfs

It uncompresses to a folder name we want to change by the typical linux method of [m]o[v]ing it.

sudo mv squashfs-root edit

We are going to be chrooting into the filesystem we just unpacked, and we want to use some of the files on our existing machine to point the way to the internet, and to give us access to our current hardware:

sudo cp /etc/resolv.conf edit/etc/
sudo cp /etc/hosts edit/etc/
sudo mount --bind /dev/ edit/dev

Now we chroot in and mount some virtual filesystems:

sudo chroot edit
mount -t proc none /proc
mount -t sysfs none /sys
mount -t devpts none /dev/pts

We also need to set some system variables and create a symbolic link for some reason or another.

export HOME=/root
export LC_ALL=C
dbus-uuidgen > /var/lib/dbus/machine-id
dpkg-divert --local --rename --add /sbin/initctl
ln -s /bin/true /sbin/initctl

I think the dbus command generates a code for this specific machine that some installation stuff may need. No idea what the [initctl] stuff is all about.
Excellent. We are now at the point where we can start to install stuff. First of all, and this was fucking frustrating trying to work this out, we need to enable the universe and multiverse repositories if we want to install packages from them. We need to do this in command line:

sudo nano /etc/apt/sources.list

This next command adds an external repository to the list of places we can download stuff from. It's a biggie but it basically is just a series of commands that run in sequence.

sudo wget http://www.medibuntu.org/sources.list.d/`lsb_release -cs`.list --output-document=/etc/apt/sources.list.d/medibuntu.list; sudo apt-get -q update; sudo apt-get --yes -q --allow-unauthenticated install medibuntu-keyring; sudo apt-get -q update

Before installing stuff, it might be a good idea to clean out some stuff we are not going to use. First of all have a look at all the installed packages in order of size:

dpkg-query -W --showformat='${Installed-Size} ${Package}\n' | sort -nr | less

The first on the list looks like a massive package, but what you have to understand is that this is showing you the UNCOMPRESSED sizes. Yeah, thanks for that. If you check on http://packages.ubuntu.com/lucid for the ubuntu-docs information, you find it is only taking up a few hundred Kb when squashed.
So what can you remove? Evolution is a prime candidate. Not much use on a LiveCD. You will be using webmail from a LiveCD.

dpkg-query -W --showformat='${Installed-Size} ${Package}\n' | sort -nr | grep evolution

This will show you all packages which have evolution in the title. It should look like this:

9760 evolution-common
5160 libevolution
2916 evolution-exchange
1540 evolution-data-server
1152 evolution-webcal
1076 evolution
700 evolution-plugins
368 evolution-data-server-common
128 evolution-indicator
128 evolution-couchdb

You can remove all, apart from evolution-data-server-common which is needed by other applications, by running this command:

apt-get remove --purge evolution-common libevolution evolution-exchange evolution-data-server evolution-webcal evolution evolution-plugins evolution-indicator evolution-couchdb

The language packs also take up a lot of space, and I do not need anything but English. Find these by running:

dpkg-query -W --showformat='${Installed-Size} ${Package}\n' | sort -nr | grep language-

and then remove the ones we do not want:

apt-get remove --purge language-pack-gnome-xh-base language-pack-xh-base language-pack-gnome-zh-hans-base language-pack-zh-hans-base language-pack-gnome-es-base language-pack-gnome-pt-base language-pack-gnome-de-base language-pack-pt-base language-pack-es-base language-pack-de-base language-pack-gnome-bn-base language-pack-bn-base

There are other language packs, but they are to small to worry about clearing up unless you are intent on getting this image as small as possible. The final obvious low hanging fruit are foreign font sets. Do a search for [t]rue[t]ype[f]ont packages:

dpkg-query -W --showformat='${Installed-Size} ${Package}\n' | sort -nr | grep ttf

12584 ttf-unfonts-core - Korean
6200 ttf-takao-pgothic - Japanese
5456 ttf-thai-tlwg - Thai
5184 ttf-wqy-microhei - Don't know for sure, better keep
4204 ttf-freefont - Latin, keep
2632 ttf-indic-fonts-core - Indian
2564 ttf-dejavu-core - Latin, keep
1724 ttf-liberation - Latin, keep
1708 ttf-opensymbol - Symbols, needed for OpenOffice, keep
592 ttf-khmeros-core Cambodian
216 ttf-punjabi-fonts - Punjabi
144 ttf-lao - Lao, where ever Lao is
116 ttf-kacst-one - Arabic

apt-get remove --purge ttf-unfonts-core ttf-takao-pgothic ttf-thai-tlwg ttf-wqy-microhei ttf-indic-fonts-core ttf-khmeros-core ttf-punjabi-fonts ttf-lao ttf-kacst-one

I am not going to be printing from the LiveCD so I can remove the software and drivers as follows. Do not worry about the ubuntu-desktop meta file - it is just an easy way of ensuring that all the ubuntu basic stuff is installed. As soon as printing is removed, the installation no longer qualifies as an ubuntu desktop but it doesn't actually remove the rest of the stuff.

apt-get remove --purge cups hplip-data

I am also going to remove rhythmbox, because it does take up a lot of space, and like evolution it is really the type of application you need to set up on an installed machine rather than running from a LiveCD.

apt-get remove --purge rhythmbox

Even after all of those deletions, once I recompressed the image I found I had saved a paltry 90Mb or so. Ho hum. Once you have carried out all the removals, a good strategy is to upgrade all your remaining packages to the latest versions. You do NOT want to upgrade the Kernel or Grub because that causes bad things to happen and will stop the Live USB stick booting. So, create the following files to 'pin' those packages to their current versions:

sudo cat > hold_back_kernel << "EOF"
Package: linux-generic linux-headers-generic linux-image-generic linux-restricted-modules-generic
Pin: version 2.6.35.22.23
Pin-Priority: 1001
EOF
sudo mv hold_back_kernel /etc/apt/preferences.d/
sudo cat > hold_back_grub << "EOF"
Package: grub-common
Pin: version 1.98+20100804-5ubuntu3
Pin-Priority: 1001
EOF
sudo mv hold_back_grub /etc/apt/preferences.d/
sudo apt-get update

You can check that the version numbers are correct (they should be for the Live CD you have downloaded) and check the system knows about the new rules by running these commands:

sudo apt-cache policy
dpkg -l linux-generic
dpkg -l grub-common

The last few lines of all of that should look like this (you can see the version numbers match up):

Pinned packages:
     linux-headers-generic -> 2.6.35.22.23
     linux-image-generic -> 2.6.35.22.23
     grub-common -> 1.98+20100804-5ubuntu3
     linux-generic -> 2.6.35.22.23
root@compaq:/# dpkg -l linux-generic
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                      Version                   Description
+++-=========================-=========================-==================================================================
ii  linux-generic             2.6.35.22.23              Complete Generic Linux kernel
root@compaq:/# dpkg -l grub-common
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                      Version                   Description
+++-=========================-=========================-==================================================================
ii  grub-common               1.98+20100804-5ubuntu3    GRand Unified Bootloader, version 2 (common files)

You should now be able to run the upgrade excluding those troublesome packages.

sudo apt-get upgrade

We can now run a massive install command to add the extra packages that we want.

sudo apt-get install \
\
build-essential linux-headers-generic libgtk2.0-dev patch bison texinfo \
\
xul-ext-adblock-plus flashplugin-installer openjdk-6-jre icedtea6-plugin \
\
openoffice.org-writer openoffice.org-java-common openoffice.org-l10n-en-gb openoffice.org-help-en-gb openoffice.org-style-human myspell-en-gb openoffice.org-hyphenation-en-us openoffice.org-thesaurus-en-us openoffice.org-java-common \
\
ttf-mscorefonts-installer \
\
smplayer vlc avidemux audacity pitivi \
\
totem totem-plugins-extra gstreamer0.10-pitfdll gstreamer0.10-ffmpeg gstreamer0.10-plugins-bad gstreamer0.10-plugins-bad-multiverse gstreamer0.10-plugins-ugly gstreamer0.10-plugins-ugly-multiverse \
\
non-free-codecs libavcodec-unstripped-52 libdvdcss2 libdvdread4 libdvdnav4 \
\
lame mjpegtools twolame mpeg2dec liba52-0.7.4-dev ffmpeg ffmpeg2theora w32codecs \
\
keepassx \
\
xchm comix ghostscript ghostscript-x gqview \
\
wine \
\
transmission \
\
f-spot dcraw gimp gimp-data-extras gimp-help-en \
\
celestia celestia-common celestia-common-nonfree stellarium googleearth-package \
\
subversion yasm \
autoconf libtool zlib1g-dev libbz2-dev intltool libglib2.0-dev \
libdbus-glib-1-dev libgtk2.0-dev libgudev-1.0-dev \
libwebkit-dev libnotify-dev libgstreamer0.10-dev \
libgstreamer-plugins-base0.10-dev \
\
monodevelop

To install Google Earth from the package downloaded above, you run:

make-googleearth-package

I also want a couple of bits of software which are not available in the repositories. The first is Handbrake which is used to auto convert between video formats, and then Truecrypt which is a handy encryption system.

The lump of packages near the end of the long list above (subversion to libgstreamer) contains the dependencies for Handbrake. Handbrake itself is installed using the svn system:

cd /tmp
svn checkout svn://svn.handbrake.fr/HandBrake/trunk hb-trunk
cd hb-trunk
./configure --launch
cd build
make install

Truecrypt is a pain in the arse since they want you to accept their stupid licence instead of just releasing under the GPL.

cd /tmp
wget http://www.truecrypt.org/download/truecrypt-7.0a-linux-x86.tar.gz
tar -xzvf truecrypt-7.0a-linux-x86.tar.gz
./truecrypt-7.0a-setup-x86

Extract the package file - it automatically stores it in /tmp. We need to extract it to /, and it auto installs to the correct folders. So:

cd /
tar -xzvf /tmp/truecrypt_7.0a_i386.tar.gz

And that is that for Truecrypt.

If you were stupid enough to upgrade the kernel package, it is extremely likely that doing a upgrade of all the packages will change the kernel version. To ensure that the new kernel is actually used, you need to go into the ...
~/live/edit/boot
...folder and copy the latest versions of the vmlinuz compressed kernel and the initrd.img files to the ...
~/live/extract-cd/casper
...folder. You then need to delete the existing initrd.lz file, and rename the initrd.img file you just copied over to replace it. Do the same with the vmlinuz files. This has NEVER worked for me so I do not upgrade the kernel package.

If you want the clock in the LiveCD machine to show the proper time, take a moment and set your time zone and keyboard for UK use:

sudo setxkbmap gb
sudo cp -v --remove-destination /usr/share/zoneinfo/Europe/London /etc/localtime

Of course, the keyboard command does not fucking work. I now have no fucking idea how to change the keyboard map from the command line. Brilliant. I mean there must be a file somewhere, anywhere, that actually stores these settings. Where? No fucking clue. Moving on:

We now need to clean up some user account stuff incase any of the installed packages made changes:

awk -F: '$3 > 999' /etc/passwd
usermod -u 500 $hit #where hit is any user ID greater than 999

Right, and we are good to do a general clean up:

apt-get clean
rm -rf /tmp/* ~/.bash_history
rm /etc/resolv.conf
rm /var/lib/dbus/machine-id
rm /sbin/initctl
dpkg-divert --rename --remove /sbin/initctl
umount /proc
umount /sys
umount /dev/pts
exit
sudo umount edit/dev

The [rm] commands obviously [r]e[m]ove stuff, and the remaining commands undo the setup commands we used to get into the [chroot] environment. Virtually every time I do this I get a fucking annoying error telling me that it can't umount these things because they are in use. Well, you know what I say to that? Hello Mr. Reboot.

Once the system has come back on, fire up a terminal and:

cd ~/live

Now, update the .manifest file which is a list of installed packages:
chmod +w extract-cd/casper/filesystem.manifest
sudo chroot edit dpkg-query -W --showformat='${Package} ${Version}\n' > extract-cd/casper/filesystem.manifest
sudo cp extract-cd/casper/filesystem.manifest extract-cd/casper/filesystem.manifest-desktop
sudo sed -i '/ubiquity/d' extract-cd/casper/filesystem.manifest-desktop
sudo sed -i '/casper/d' extract-cd/casper/filesystem.manifest-desktop

Now delete the existing squashed archive and replace it. Don't worry if it cannot find one, there shouldn't be one the first time you run through these instructions.
sudo rm extract-cd/casper/filesystem.squashfs
sudo mksquashfs edit extract-cd/casper/filesystem.squashfs

That last command will take most time of anything here, as it (re)compressess all the packages we want. If you are feeling particularly narcisstic you can edit the disk details (change the image name) that pop up on boot:

sudo nano extract-cd/README.diskdefines

Now we need to rebuild the md5sum check file:
cd extract-cd
sudo rm md5sum.txt
find -type f -print0 | sudo xargs -0 md5sum | grep -v isolinux/boot.cat | sudo tee md5sum.txt

That will probably take two [sudo] password requests - one for the straight [sudo] and one for the [| sudo] piped version. Do not know why. Irritating as fuck.

And finally we need to build a new iso image:

sudo mkisofs -D -r -V "$IMAGE_NAME" -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o ../ubuntu-10.10-desktop-i386-custom.iso .

Once you have that image you use the unetbootin software (which comes in both windows and linux flavours) to load the image onto the USB Key. You need to use version 494 at least to get it to work with Maverick. Job done.