--- /dev/null
+
+Technical details of creating the USB key boot images. Unless
+you want to rebuild (remaster) the iso boot image, you will not
+need this.
+
+The directory "remaster" contains the scripts that allow picking
+apart a Kubuntu Hardy ISO and then updating and recombining the
+parts into a USB boot image. The information below is somewhat
+low level and should not be needed unless you want to do your
+own remastering either starting from the Kubuntu release or from
+the Bacula remastered release.
+
+Note, the sqfs.tar.gz is the whole squashfs unsquashed.
+
+The kernel image (vmlinuz) is a copy of the most recent kernel i.e.
+
+ sqfs/boot/vmlinuz-2.6.24-23-generic
+
+and initrd.gz is a copy of the most recent initrd.img i.e
+
+ sqfs/boot/initrd.img-2.6.24-23-generic
+
+they are renamed and put in the kubuntu8 partition in:
+
+ casper/vmlinuz
+and
+ casper/initrd.gz
+
+respectively.
+
+The above updates are automatically done when running
+the write_sqfs_to_disk_image script. Then the final
+step is to tar up kubuntu8.
+
+Note, initrd.gz is made after fixing the bug in
+/usr/share/initramfs-tools/scripts/casper
+see note 2. in bugs with Kubuntu boot process below.
+
+When updating the USB root partition (changing something), I
+strongly recommend that you work with the disk image then
+repack it (pack_disk_image) and then run load_disk_image.
+
+
+Packages needed:
+apt-get install syslinux mbr
+
+
+Kubuntu boot tricks:
+1. Booting with persistence added to the kernel options will permit
+ mounting of a USB casper-rw and home-rw partitions on the USB key.
+ casper-rw is used to store changed OS files, and home-rw is the
+ home directory.
+
+Bugs with Kubuntu boot process:
+1. The initrd.gz image must be opened, fixed and the repacked.
+2. The fix involves removing the ,mode=755 from the mount line for
+ the persistent OS partition (casper-rw) or /cow
+ in /usr/share/initramfs-tools/scripts/casper
+3. I have removed /etc/rc0.d/S89casper and /etc/rc6.d/S89casper
+ because they are related to a CDROM boot and create false
+ errors when booting from a USB key.
--- /dev/null
+
+Copyright (C) Kern E. Sibbald, 2009
+
+This directory is used to build a USB key containing a Kubuntu 8.04 LiveCD
+with persistent OS files and persistent /home files.
+
+You will need to run as root for most things ...
+
+Packages needed:
+apt-get install syslinux mbr
+
+
+1. Start by editing the "config" file. Be sure to get your USB_DEV
+ definition correct. Note: you can see what devices you have
+ connected by running:
+
+ lsscsi
+
+ For example, I get:
+
+ $ lsscsi
+ [1:0:0:0] cd/dvd _NEC DVD+RW ND-1100A 108B /dev/scd0
+ [1:0:1:0] cd/dvd PHILIPS DVD+-RW DVD8631 9D03 /dev/scd1
+ [9:0:0:0] disk Kingston DataTraveler 2.0 PMAP /dev/sda
+
+ and in my case, the USB device is the Kingston DataTraveler on
+ device /dev/sda.
+
+ Alternatively you can do:
+
+ fdisk -l
+
+2. The scripts you need to partition the key and
+ to write the boot image to it are all in this (usb) directory.
+
+3. If you ever want to put the key back to its prior state, *before*
+ running the partition_usb_key, you might consider doing a:
+
+ sfdisk -d /dev/key-device >save_me
+
+ where key-device is the key device name (e.g. sda). The
+ output file can be fed back into sfdisk to recreate the original
+ with:
+
+ sfdisk /dev/key-device <save_me
+
+4. The next step is to get a copy of kubuntu8.tar.gz, which is the
+ USB boot image. Currently, it can be downloaded from:
+
+ www.bacula.org/downloads/kubuntu8.tar.gz
+
+ or from:
+
+ www.sibbald.com/download/kubuntu8.tar.gz
+
+5. Edit the file "config" and fill in the values that correspond
+ to your setup.
+
+6. After editing the config file, run:
+
+ ./partition_usb_key
+
+ Note, this script will destroy *all* data on the key, and assumes
+ that you have a 3GB or bigger key. It may work for a 2GB key,
+ but you might want to reduce the size of the second partition.
+
+
+ The partition_usb_key script creates three partitions:
+
+ 1. kubuntu8 -- USB boot partition containing the OS
+ 2. casper-rw -- A writable ext3 partition for saving OS changes
+ 3. home-rw -- A writable ext3 partition for saving /home
+
+6. Mount your USB key and detar the kubuntu8.tar.gz image
+ into the first partition. Do this with:
+
+ ./write_usb_boot_partition
+
+ This can take a good amount of time (5 mins) since it must format
+ the new partitions then copy the boot image.
+
+7. You should now have a USB stick that can be booted providing the
+ machine permits booting from the USB port -- this can be adjusted
+ by modifying the BIOS boot sequence. On Dell machines, you can
+ enter the BIOS setup by pressing F2 just after power on.
+
+ Alternatively, most machines let you boot from an alternate device.
+ For example if you press F11 while a Sony Viao is powering up, it
+ will boot from the USB port.
+
+ On Dell machines during power on, if you press F12, you will be
+ able to select any boot device (one time only) other than the one
+ that is the default (normally the CDROM or HDD).
+
+8. When the key is booted, assuming you choose the first option
+ (LiveCD), you will be running as user "ubuntu" the password is
+ "bacula", and you will be in /home/ubuntu.
+
+9. Before booting, you might want to remove the USB key, using the
+ remove safely mode, then plug it back in so that you can access
+ the home-rw partition. Here you can put anything you want from
+ your system. However, you must use care to ensure that the files
+ are written with UID=1000 and GID=1000, which is ubuntu:ubuntu when
+ your boot the USB key.
+
+10. Finally, if you are running with a KDE desktop on Kubuntu 8.04,
+ you can copy it to the key with:
+
+ ./copy_kubuntu_desktop_to_usb
+
+ If you are not using Kubuntu, you can modify the script to
+ adapt it to your situation or simply create a new script.
+
+===
+
+If you want to add additional OS tools to your USB stick, there are two
+ways:
+
+1. Remaster the iso boot image (a bit complicated) see README.technotes
+2. Simply use sudo apt-get install ... when booted into your USB stick.
+ The changes will be written to the casper-rw partition (the
+ read/write OS partition).
+
+If you want to add something to your USB home directory simply mount
+the home-rw partition and write to it in the appropriate place as noted
+in item #9 above.
+
+One slightly annoying thing about the USB key is that the casper-rw and the
+home-rw partitions must be ext3 (with journaling turned on), and journaling
+is not really the best way to run with USB keys that have a finite write
+lifetime. Switching the partitions to ext2 seems to prevent them from being
+written correctly, which means a lot of things such as starting X do not
+work.
--- /dev/null
+#
+# You must define certain environment variables in this file
+# so that the scripts know where to find things.
+#
+
+CWD=`pwd`
+
+#
+# Set your home directory here (do not use $HOME !!!)
+# This is used when coping your desktop files to the
+# USB key.
+#
+MY_HOME=
+
+#
+# The device name of your USB device (e.g. /dev/sda)
+# You can find it by plugging it in then doing
+#
+# fdisk -l
+#
+# If you are unsure remove the USB device and rerun the fdisk -l
+# If you get this wrong, your harddisk could be wiped out.
+# It is probably "/dev/sda" or "/dev/sdb" or "/dev/sdc", however, on my latest
+# machine (HP Pavilion), it is /dev/sdg (see the lsscsi listing below)
+#
+# [0:0:0:0] disk ATA WDC WD6400AAKS-6 01.0 /dev/sda
+# [1:0:0:0] cd/dvd HL-DT-ST BDDVDRW GBC-H20L 1.B8 /dev/scd0
+# [2:0:0:0] disk ATA WDC WD6400AAKS-6 01.0 /dev/sdb
+# [6:0:0:0] disk Generic- Compact Flash 1.00 /dev/sdc
+# [6:0:0:1] disk Generic- SM/xD-Picture 1.00 /dev/sdd
+# [6:0:0:2] disk Generic- SD/MMC 1.00 /dev/sde
+# [6:0:0:3] disk Generic- MS/MS-Pro 1.00 /dev/sdf
+# [7:0:0:0] disk Crucial Gizmo! 1100 /dev/sdg
+#
+USB_DEV=
+
+#
+# When your USB key is mounted, what is the mount directory?
+#
+MOUNT_POINT=/media
+
+#
+# This is where you downloaded the USB boot image
+#
+BOOT_IMAGE=${CWD}/kubuntu8.tar.gz
+
+#
+# Disk image of boot partition of USB key -- this is where you
+# unpacked the kubuntu8.tar.bz2 image. Unpacking the image
+# is not necessary unless you want to change it.
+#
+DISK_IMAGE=${CWD}/kubuntu8
+
+#
+# If you are remastering a Ubuntu or Kubuntu ISO (not normally done)
+# Point to the ISO image
+# Used when picking apart a new ISO (i.e. upgrade or something)
+#
+ISO_IMAGE=
+
+#
+# Partition 1 (kubuntu) size
+#
+SIZE_PART1="+750M"
+
+#
+# Partition 2 (casper-rw) size
+#
+SIZE_PART2="+1000M"
+
+#
+# Partition 3 uses whatever is left on the USB key
--- /dev/null
+#!/bin/sh
+#
+# If you are running on a Kubuntu desktop and you would like to have
+# the same desktop on the usb key, you can do so by running this
+# script. You must be root.
+#
+. ./config
+
+if [ ! `whoami` = "root" ] ; then
+ echo ""
+ echo "You need to be root to run this shell script"
+ echo ""
+ exit 1
+fi
+echo " "
+echo "This script will overwrite a number of directories on the USB key"
+echo "for example: .kde .ssh .bashrc .bash_logout .gnupg .mozilla ..."
+echo " "
+echo "Answer yes to continue "
+read a
+if [ "$a" != "yes" ] ; then
+ echo "Device $USB_DEV unchanged"
+ exit 1
+fi
+
+if [ ! -d ${MOUNT_POINT}/home-rw ] ; then
+ mount ${USB_DEV}3 ${MOUNT_POINT}/home-rw
+fi
+if [ ! -d ${MOUNT_POINT}/home-rw ] ; then
+ echo "Mount of home-rw USB partition failed."
+ echo "Please pre-mount the USB stick and run this script again."
+ exit 1
+fi
+cd ${MOUNT_POINT}/home-rw
+if [ $? -ne 0 ] ; then
+ echo "Could not cd to home-rw USB partition"
+ exit 1
+fi
+
+mkdir -p ubuntu
+chown 1000:1000 ubuntu
+cd ubuntu
+# Do files
+for i in .bashrc .bash_logout ; do
+ if [ -f ${MY_HOME}/$i ] ; then
+ cp -f ${MY_HOME}/$i .
+ chown 1000:1000 $i
+ fi
+done
+#
+# Special case for .kde
+#
+echo "Copying .kde ..."
+rm -rf .kde
+mkdir -p .kde
+cd .kde
+cp -a $MY_HOME/.kde/share .
+cd ..
+chown -R 1000:1000 .kde
+
+# Do directories
+for i in .gnupg .ssh .mozilla Desktop ; do
+ if [ -d ${MY_HOME}/$i ] ; then
+ rm -rf $i
+ cp -a ${MY_HOME}/$i .
+ chown -R 1000:1000 $i
+ fi
+done
+sync
+sync
--- /dev/null
+#!/bin/sh
+#
+# Create bootstrap information files -- prelude to creating a
+# Bacula Rescue data for USB key
+#
+# Kern Sibbald, December MMII
+# This source distributed under the GPLv2
+#
+export LANG=C
+cwd=`pwd`
+os=`uname -s`
+if [ ! "x$1" = "x" ] ; then
+ host=$1
+else
+ host=`hostname`
+fi
+echo "Host specific data will be saved in the directory: ${host}"
+echo " "
+mkdir -p $host
+di=${cwd}/$host/diskinfo
+scr=${cwd}/$host/scripts
+
+case $os in
+ Linux)
+ ;;
+ FreeBSD | SunOS | IRIX)
+ echo ""
+ echo "This code is not yet adapted to this OS"
+ exit 1
+ ;;
+ *)
+ echo ""
+ echo "Unknown operating system type: $os"
+ exit 1
+ ;;
+esac
+if [ ! `whoami` = "root" ] ; then
+ echo ""
+ echo "You need to be root to run this script ..."
+ echo ""
+ exit 1
+fi
+
+#
+# First collect information
+#
+rm -rf format.* partition.* $di create-* $scr
+echo "Begin collecting system info ..."
+mkdir -p $di
+cd $di
+mount -l >mount.bsi
+mount -l -t ext2 >mount.ext2.bsi
+mount -l -t ext3 >mount.ext3.bsi
+mount -l -t reiserfs >mount.rei.bsi
+cp /etc/fstab fstab.bsi
+cp /etc/mtab mtab.bsi
+df -Tl >df.bsi
+# Pickup all disks except USB_DEV
+sfdisk -s | grep -v "${USB_DEV}" >sfdisk.disks.bsi
+grep "^/dev/" sfdisk.disks.bsi | sed -n 's%\(^/dev/[A-Za-z]*\):.*$%\1%p' >disks.bsi
+for i in `cat disks.bsi`; do
+ j=`echo $i | cut -c6-`
+ sfdisk -l $i >sfdisk.$j.bsi
+ sfdisk -d $i >sfdisk.make.$j.bsi
+done
+cat /proc/swaps > swaps.bsi
+route -n >route.bsi
+ifconfig >ifconfig.bsi
+
+# Gather LVM information
+# Only tested on LVM2
+dolvm=0
+if which lvm > /dev/null 2>/dev/null ; then
+ echo "Gathering LVM information"
+ dolvm=1
+
+ lvm pvs --noheadings --nosuffix -o pv_name,vg_name | cat > lvm-pv.bsi
+ lvm vgs --noheadings --nosuffix -o vg_name,vg_extent_size --units=k | cat > lvm-vg.bsi
+ lvm lvs --noheadings --nosuffix -o lv_name,vg_name,lv_size --units=k | cat > lvm-lv.bsi
+fi
+
+echo "Done collecting info."
+
+#
+# Done collecting information
+#
+
+
+echo "Begin creating scripts ..."
+#
+# First create partitioning script(s)
+#
+mkdir -p $scr
+for i in `cat disks.bsi`; do
+ j=`echo $i | cut -c6-`
+ cat >$scr/partition.$j <<END_OF_DATA
+
+#!/bin/sh
+#
+# Partition disk $i -- created by getdiskinfo
+echo ""
+echo "This script will repartition disk $i."
+echo ""
+echo "IT WILL DESTROY ALL DATA ON DISK $i !!!!"
+echo ""
+echo -n "Are you sure you want to continue? yes/no: "
+read a
+if [ x\$a != xyes ] ; then
+ exit 1
+fi
+echo "Partitioning disk $i"
+# zap partition info
+dd if=/dev/zero of=$i bs=512 count=2
+# repartition
+sfdisk $i <$di/sfdisk.make.$j.bsi | less
+echo ""
+echo "The previous partitioning was:"
+cat $di/sfdisk.$j.bsi
+#
+echo ""
+echo "The new partitioning is:"
+sfdisk -l $i
+echo ""
+echo "If the disk is correctly partitioned, you should"
+echo "now run the \"format.$j\" script."
+echo ""
+END_OF_DATA
+
+
+chmod 755 $scr/partition.$j
+done
+echo "Done making partitioning scripts"
+
+if [ $dolvm -eq 1 ] ; then
+#
+# LVM phase 1: create the Physical Volumess
+#
+ cat > $scr/create-pv <<EOF
+#!/bin/sh
+#
+# Create PVs for LVM -- created by getdiskinfo
+echo ""
+echo "This script will format all partitions listed in diskinfo/lvm-pv.bsi"
+echo ""
+echo "IT WILL DESTROY ALL DATA ON THESE PARTITIONS!!!!"
+echo ""
+EOF
+ for pv in `cat lvm-pv.bsi | awk '{print $1}'`; do
+ echo "echo \" $pv\"" >> $scr/create-pv
+ done
+
+ cat >> $scr/create-pv <<EOF
+echo ""
+echo -n "Are you sure you want to continue? yes/no: "
+read a
+if [ x\$a != xyes ] ; then
+ exit 1
+fi
+EOF
+ for pv in `cat lvm-pv.bsi | awk '{print $1}'`; do
+ echo "echo \"Creating PV on $pv\"" >> $scr/create-pv
+ echo "lvm pvcreate -ff -y -v $pv" >> $scr/create-pv
+ done
+ echo "echo \"Done.\"" >> $scr/create-pv
+ echo "echo \"If there were no errors, run create-vg to create the volume groups.\"" >> $scr/create-pv
+ chmod +x $scr/create-pv
+
+#
+# LVM phase 2: create Volume Groups
+#
+ cat > $scr/create-vg <<EOF
+#!/bin/sh
+echo ""
+echo "This script will create all volume groups listed in diskinfo/lvm-vg.bsi"
+echo "You must have sucesfully run create-pv to create the requesite PVs first"
+echo ""
+echo -n "Are you sure you want to continue? yes/no: "
+read a
+if [ x\$a != xyes ] ; then
+ exit 1
+fi
+EOF
+ cat lvm-vg.bsi | awk '{print $1, $2}' | while read vg pesize ; do
+ echo "echo \"Creating VG $vg PE extent size $pesize kbytes"\" >> $scr/create-vg
+ pelist=""
+ for pv in `cat lvm-pv.bsi | awk "\\\$2 == \"$vg\" { print \\\$1 }"` ; do
+ pelist="$pelist $pv"
+ done
+ echo "lvm vgcreate $vg -v -s ${pesize}k $pelist" >> $scr/create-vg
+ done
+ echo "echo \"Done.\"" >> $scr/create-vg
+ echo "echo \"If there were no errors, run create-lv to create the logical volumes.\"" >> $scr/create-vg
+ chmod +x $scr/create-vg
+
+
+#
+# LVM phase 3: create Logical Volumes
+#
+# One quick sidenote: this script creates LVs with a size based on the
+# physical extent count, rather than the size in bytes. This is because
+# at the time of writing this script, lvdisplay erroneously prints out
+# the size in 512 byte sector count rather than 1024 byte blocks.
+# Using the extent count should allow this script to continue to work
+# even after the bug is fixed.
+
+ cat > $scr/create-lv <<EOF
+#!/bin/sh
+echo ""
+echo "This script will create all logical volumes listed in diskinfo/lvm-lv.bsi"
+echo "You must have sucesfully run create-vg to create the requesite VGs first"
+echo ""
+echo -n "Are you sure you want to continue? yes/no: "
+read a
+if [ x\$a != xyes ] ; then
+ exit 1
+fi
+EOF
+ cat lvm-lv.bsi | awk '{print $1, $2, $3}' | while read lv vg lvsize ; do
+ # lv=`echo $lv | sed -e 's/.*\///'`
+ echo "echo \"Creating LV $lv\"" >> $scr/create-lv
+ echo "lvm lvcreate -L ${lvsize}k $vg -n $lv" >> $scr/create-lv
+ done
+ chmod +x $scr/create-lv
+fi
+
+#
+# Create formatting script(s)
+#
+echo "Begin making formatting script(s) ..."
+for i in `cat disks.bsi`; do
+ j=`echo $i | cut -c6-`
+ cat >$scr/format.$j <<END_OF_DATA
+#!/bin/sh
+#
+# Format all partitions on disk $i -- created by getdiskinfo
+#
+echo ""
+echo "This script will format all partitions on disk $i."
+echo ""
+echo "IT WILL DESTROY ALL DATA ON DISK $i !!!!"
+echo ""
+echo -n "Are you sure you want to continue? yes/no: "
+read a
+if [ x\$a != xyes ] ; then
+ exit 1
+fi
+echo "Do you want to do a disk check for bad blocks?"
+echo -n "It is recommended, but takes time. yes/no: "
+read a
+if [ x\$a = xyes ] ; then
+ check="-c"
+else
+ check=
+fi
+END_OF_DATA
+
+ # Find swap partitions in output from sfdisk
+ k=`grep "^$i.*82 Linux swap" sfdisk.$j.bsi | cut -d ' ' -f 1`
+ for disk in $k; do
+ echo "echo \"Formatting $disk -- swap partition\"" >>$scr/format.$j
+ echo "mkswap $check $disk" >>$scr/format.$j
+ echo "echo \"\"" >>$scr/format.$j
+ done
+ # Find ext2 partitions in mount output
+ k=`grep "^$i" mount.ext2.bsi | cut -d ' ' -f 1`
+ for disk in $k; do
+ echo "echo \"Formating $disk -- ext2 partition\"" >>$scr/format.$j
+ label=`grep "^$disk" mount.ext2.bsi | cut -d ' ' -f 7 | cut -c2- | cut -d ] -f 1`
+ if [ x$label = x ] ; then
+ echo "mke2fs -v \$check $disk" >>$scr/format.$j
+ else
+ echo "mke2fs -v \$check -L $label $disk" >>$scr/format.$j
+ fi
+ echo "echo \"\"" >>$scr/format.$j
+ done
+ # Find ext3 partitions in mount output
+ k=`grep "^$i" mount.ext3.bsi | cut -d ' ' -f 1`
+ for disk in $k; do
+ echo "echo \"Formating $disk -- ext3 partition\"" >>$scr/format.$j
+ label=`grep "^$disk" mount.ext3.bsi | cut -d ' ' -f 7 | cut -c2- | cut -d ] -f 1`
+ if [ x$label = x ] ; then
+ echo "mke2fs -v -j \$check $disk" >>$scr/format.$j
+ else
+ echo "mke2fs -v -j \$check -L $label $disk" >>$scr/format.$j
+ fi
+ echo "echo \"\"" >>$scr/format.$j
+ done
+ # Find reiserfs partitions in mount output
+ k=`grep "^$i" mount.rei.bsi | cut -d ' ' -f 1`
+ for disk in $k; do
+ echo "echo \"Formating $disk -- reiser partition\"" >>$scr/format.$j
+ label=`grep "^$disk" mount.rei.bsi | cut -d ' ' -f 7 | cut -c2- | cut -d ] -f 1`
+ if [ x$label = x ] ; then
+ echo "mkereiserfs -V \$check $disk" >>$scr/format.$j
+ else
+ echo "mkereiserfs -V \$check -L $label $disk" >>$scr/format.$j
+ fi
+ echo "echo \"\"" >>$scr/format.$j
+ done
+ chmod 755 $scr/format.$j
+done
+
+#
+# Create LVM formatting scripts(s)
+#
+# Somebody more clever than I with bash scripting
+# could probably factor a lot of this code out.
+#
+if [ $dolvm -eq 1 ] ; then
+ echo "Begin making LVM formatting script(s) ..."
+ for i in `cat lvm-vg.bsi | awk '{print $1}'`; do
+ cat >$scr/format.$i <<END_OF_DATA
+#!/bin/sh
+#
+# Format all partitions on VG $i -- created by getdiskinfo
+#
+echo ""
+echo "This script will format all LVs on VG $i."
+echo ""
+echo "IT WILL DESTROY ALL DATA ON DISK $i !!!!"
+echo ""
+echo -n "Are you sure you want to continue? yes/no: "
+read a
+if [ x\$a != xyes ] ; then
+ exit 1
+fi
+echo "Do you want to do a disk check for bad blocks?"
+echo -n "It is recommended, but takes time. yes/no: "
+read a
+if [ x\$a = xyes ] ; then
+ check="-c"
+else
+ check=
+fi
+END_OF_DATA
+# set -x
+ # Find swap partitions in output from sfdisk
+ mapper="/dev/mapper/${i}"
+ k=`grep "^$mapper" swaps.bsi | awk '{print $1}'`
+ for disk in $k; do
+ echo "echo \"Formatting $disk -- swap partition\"" >>$scr/format.$i
+ echo "mkswap $check $disk" >>$scr/format.$i
+ echo "echo \"\"" >>$scr/format.$i
+ done
+ # Find ext2 partitions in mount output
+ k=`grep "^$mapper" mount.ext2.bsi | cut -d ' ' -f 1`
+ for disk in $k; do
+ echo "echo \"Formating $disk -- ext2 partition\"" >>$scr/format.$i
+ label=`grep "^$disk on" mount.ext2.bsi | cut -d ' ' -f 7 | cut -c2- | cut -d ] -f 1`
+ if [ x$label = x ] ; then
+ echo "mke2fs -v \$check $disk" >>$scr/format.$i
+ else
+ echo "mke2fs -v \$check -L $label $disk" >>$scr/format.$i
+ fi
+ echo "echo \"\"" >>$scr/format.$i
+ done
+ # Find ext3 partitions in mount output
+ k=`grep "^$mapper" mount.ext3.bsi | cut -d ' ' -f 1`
+ for disk in $k; do
+ echo "echo \"Formating $disk -- ext3 partition\"" >>$scr/format.$i
+ label=`grep "^$disk on" mount.ext3.bsi | cut -d ' ' -f 7 | cut -c2- | cut -d ] -f 1`
+ if [ x$label = x ] ; then
+ echo "mke2fs -v -j \$check $disk" >>$scr/format.$i
+ else
+ echo "mke2fs -v -j \$check -L $label $disk" >>$scr/format.$i
+ fi
+ echo "echo \"\"" >>$scr/format.$i
+ done
+ # Find reiserfs partitions in mount output
+ k=`grep "^$mapper" mount.rei.bsi | cut -d ' ' -f 1`
+ for disk in $k; do
+ echo "echo \"Formating $disk -- reiser partition\"" >>$scr/format.$i
+ label=`grep "^$disk on" mount.rei.bsi | cut -d ' ' -f 7 | cut -c2- | cut -d ] -f 1`
+ if [ x$label = x ] ; then
+ echo "mkereiserfs -V \$check $disk" >>$scr/format.$i
+ else
+ echo "mkereiserfs -V \$check -L $label $disk" >>$scr/format.$i
+ fi
+ echo "echo \"\"" >>$scr/format.$i
+ done
+ chmod 755 $scr/format.$i
+ done
+fi
+
+cd $scr
+
+#
+# Create network start script
+#
+ifconfig eth0 2>/dev/null >/dev/null
+if [ $? = 0 ] ; then
+ ip=`ifconfig eth0 | grep inet | head -1 | sed -n 's/\ \+inet addr:\([0-9]\+\(\.[0-9]\+\)\{3\}\).*/\1/p'`
+ cat >start_network <<END_OF_DATA
+#!/bin/sh
+#
+# Start network -- created by getdiskinfo
+#
+ip=$ip
+dev=eth0
+ifconfig lo up
+ifconfig \$dev up \$ip
+END_OF_DATA
+else
+ echo "Warning, no eth0 found."
+ echo "#!/bin/sh" >start_network
+fi
+# Try eth1
+ifconfig eth1 2>/dev/null >/dev/null
+if [ $? = 0 ] ; then
+ ip=`ifconfig eth1 | grep inet | head -1 | sed -n 's/\ \+inet addr:\([0-9]\+\(\.[0-9]\+\)\{3\}\).*/\1/p'`
+ cat >>start_network <<END_OF_DATA
+ip1=$ip
+dev1=eth1
+ifconfig \$dev1 up \$ip1
+END_OF_DATA
+fi
+ip=`route -n | grep UG | head -1 | awk '{print $2}'`
+dev=`route -n | grep UG | head -1 | awk '{print $8}'`
+cat >>start_network <<END_OF_DATA
+route add default gw $ip dev $dev
+END_OF_DATA
+
+chmod 755 start_network
+
+cat >$scr/mount_drives <<END_OF_DATA
+#!/bin/sh
+#
+# Mount disk drives -- created by getdiskinfo
+#
+PATH=$PATH:/mnt/disk/sbin:/mnt/disk/bin
+END_OF_DATA
+TMP1=`mktemp gdi.1.XXXXXXXXXX`
+TMP2=`mktemp gdi.2.XXXXXXXXXX`
+if test x${TMP1} = x; then
+ TMP1="/tmp/1$$"
+ if test -f ${TMP1}; then
+ echo "Temp file security problem on: ${TMP1}"
+ exit 1
+ fi
+fi
+if test x${TMP2} = x; then
+ TMP2="/tmp/2$$"
+ if test -f ${TMP2}; then
+ echo "Temp file security problem on: ${TMP2}"
+ rm -f ${TMP1}
+ exit 1
+ fi
+fi
+sed -n 's/\(^.*\)\ on\ \(.*\)\ type.*$/\1 \/mnt\/disk\2/p' $di/mount.ext2.bsi >${TMP1}
+sed -n 's/\(^.*\)\ on\ \(.*\)\ type.*$/\1 \/mnt\/disk\2/p' $di/mount.ext3.bsi >>${TMP1}
+sed -n 's/\(^.*\)\ on\ \(.*\)\ type.*$/\1 \/mnt\/disk\2/p' $di/mount.rei.bsi >>${TMP1}
+# sort so that / is first
+sort -k 2 <${TMP1} >${TMP2}
+# output mkdir followed by its mount
+sed -n 's/\(^.*\)\ \(.*$\)/mkdir -p \2\
+mount \1 \2/p' ${TMP2} >>$scr/mount_drives
+
+# Now build unmount_drives
+cat >$scr/umount_drives <<END_OF_DATA
+#!/bin/sh
+#
+# Unmount disk drives -- created by getdiskinfo
+#
+END_OF_DATA
+sort -r -k 2 <${TMP1} >${TMP2}
+sed -n 's/\(^.*\)\ \(.*$\)/umount \2/p' ${TMP2} >>$scr/umount_drives
+echo "umount /mnt/cdrom 2>/dev/null >/dev/null" >>$scr/umount_drives
+echo "sync" >>$scr/umount_drives
+echo "sync" >>$scr/umount_drives
+
+rm -f ${TMP1} ${TMP2}
+
+chmod 755 $scr/mount_drives $scr/umount_drives
+echo "Done building scripts."
--- /dev/null
+#
+# You must define certain environment variables in this file
+# so that the scripts know where to find things.
+#
+
+CWD=`pwd`
+
+#
+# Set your home directory here (do not use $HOME !!!)
+# This is used when coping your desktop files to the
+# USB key.
+#
+MY_HOME=/home/kern
+
+#
+# The device name of your USB device (e.g. /dev/sda)
+# You can find it by plugging it in then doing
+#
+# fdisk -l
+#
+# If you are unsure remove the USB device and rerun the fdisk -l
+# If you get this wrong, your harddisk could be wiped out.
+# It is probably "sda" or "sdb" or "sdc"
+#
+USB_DEV=/dev/sdg
+
+#
+# When your USB key is mounted, what is the mount directory?
+#
+MOUNT_POINT=/media
+
+#
+# This is where you downloaded the USB boot image
+#
+BOOT_IMAGE=${CWD}/kubuntu8.tar.gz
+
+#
+# Disk image of boot partition of USB key -- this is where you
+# unpacked the kubuntu8.tar.bz2 image. Unpacking the image
+# is not necessary unless you want to change it.
+#
+DISK_IMAGE=${CWD}/kubuntu8
+
+#
+# If you are remastering a Ubuntu or Kubuntu ISO (not normally done)
+# Point to the ISO image
+# Used when picking apart a new ISO (i.e. upgrade or something)
+#
+ISO_IMAGE=
+
+#
+# Partition 1 (kubuntu) size
+#
+SIZE_PART1="+750M"
+
+#
+# Partition 2 (casper-rw) size
+#
+SIZE_PART2="+1000M"
+
+#
+# Partition 3 uses whatever is left on the USB key
--- /dev/null
+#!/bin/sh
+#
+# Partition the USB stick -- the stick is assumed to be at least 3GB in size
+#
+# First delete all existing partitions
+#
+. ./config
+
+if [ ! `whoami` = "root" ] ; then
+ echo ""
+ echo "You need to be root to run this shell script"
+ echo ""
+ exit 1
+fi
+if [ "x$USB_DEV" = "x" ] ; then
+ if [ "x$1" = "x" ] ; then
+ echo "You must supply the USB device name on the command line or in USB_DEV"
+ exit 1
+ else
+ USB_DEV=$1
+ fi
+fi
+echo "This script will distroy everything on $dev"
+fdisk -l $USB_DEV
+echo " "
+echo "Answer yes to continue "
+read a
+if [ "$a" != "yes" ] ; then
+ echo "Device $USB_DEV unchanged"
+ exit 1
+fi
+sfdisk -l $USB_DEV >original-partitioning.txt
+fdisk $USB_DEV <<EOF
+d
+4
+d
+3
+d
+2
+d
+1
+n
+p
+1
+
+${SIZE_PART1}
+t
+6
+a
+1
+n
+p
+2
+
+${SIZE_PART2}
+n
+p
+3
+
+
+p
+w
+EOF
+umount ${USB_DEV}1
+mkfs.vfat -F 16 -n kubuntu8 ${USB_DEV}1
+umount ${USB_DEV}2
+mkfs.ext3 -j -b 4096 -L casper-rw ${USB_DEV}2
+# Do fs checking every 100 mounts or 360 days
+tune2fs -c 100 -i 360 ${USB_DEV}2
+umount ${USB_DEV}3
+mkfs.ext3 -j -b 4096 -L home-rw ${USB_DEV}3
+tune2fs -c 100 -i 360 ${USB_DEV}3
+sync
+
+echo "New partitioning is:"
+fdisk -l ${USB_DEV}
--- /dev/null
+#!/bin/sh
+#
+. ./config
+
+mkdir -p cdrom
+mount -o loop -t iso9660 $ISO_IMAGE cdrom
--- /dev/null
+#!/bin/sh
+#
+# tar the disk image
+#
+. ../config
+
+rm -f kubuntu8.tar.gz
+cd $DISK_IMAGE
+# Update checksum
+find . -type f -print0 | xargs -0 md5sum >md5sum.txt
+tar cfz $CWD/kubuntu8.tar.gz .
+cd $CWD
+ls -l kubuntu8.tar.gz
--- /dev/null
+#!/bin/sh
+#
+if [ ! -d initrd ] ; then
+ echo "Cannot find initrd directory."
+ exit 1
+fi
+cd initrd
+echo "Packing initrd to initrd.gz ..."
+find . | cpio -o -H newc | gzip -9 > ../initrd.gz
+if [ "x$SUID_UID" != "x" ] ; then
+ if [ "x$SUID_GID" = "x" ] ; then
+ chown $SUID_UID ../initrd.gz
+ else
+ chown $SUID_UID:$SUID_GID ../initrd.gz
+ fi
+fi
--- /dev/null
+#!/bin/sh
+#
+. ../config
+
+if [ ! -d sqfs ] ; then
+ echo "Cannot find sqfs ..."
+ exit 1
+fi
+rm -f filesystem.squashfs
+echo "Squashing the filesystem ..."
+mksquashfs sqfs filesystem.squashfs
+rm -f filesystem.manifest
+cp sqfs/filesystem.manifest .
--- /dev/null
+#!/bin/sh
+#
+
+umount cdrom
+if [ $? -eq 0 ] ; then
+ rmdir cdrom
+fi
--- /dev/null
+#!/bin/sh
+#
+rm -rf initrd
+mkdir -p initrd
+cd initrd
+echo "Unpacking initrd.gz into initrd ..."
+gzip -dc ../cdrom/casper/initrd.gz | cpio -i
--- /dev/null
+#!/bin/sh
+#
+mkdir -p sqfs
+mkdir cdsqfs
+mount -o loop -t squashfs cdrom/casper/filesystem.squashfs cdsqfs
+if [ $? -ne 0 ] ; then
+ echo "Error mounting squashfs ..."
+ rm -rf cdsqfs
+ exit 1
+fi
+echo "Copying ISO squashfs to sqfs ..."
+rsync -avx -P cdsqfs/. sqfs/.
+#
+umount cdsqfs/
+if [ $? -ne 0 ] ; then
+ umount cdsqfs/
+ if [ $? -ne 0 ] ; then
+ echo "Could not umount cdsqfs ..."
+ exit 1
+ fi
+fi
+rmdir cdsqfs
--- /dev/null
+#!/bin/sh
+#
+# Update squashfs -- assumes you start with a Hardy 8.04.1 desktop,
+# but it should work even if you have already updated it.
+#
+
+if [ ! -d sqfs ] ; then
+ echo "Cannot find squashfs (sqfs directory)"
+ exit 1
+fi
+chroot sqfs /bin/sh
+mount -t proc none /proc/
+mount -t sysfs non /sys/
+export HOME=/root
+
+# remove packages
+apt-get remove --purge `dpkg-query -W --showformat '${Package}\n' | grep language-pack | egrep -v '\-en'`
+apt-get remove --purge `dpkg-query -W --showformat '${Package}\n' | grep openoffice\.org-`
+apt-get remove --purge amarok dictionaries-common
+
+cat >/etc/resolv.conf <<EOF
+search sibbald.com
+nameserver 192.168.68.254
+nameserver 208.67.222.222
+nameserver 208.67.220.220
+EOF
+
+cat >/etc/apt/sources.list <<EOF
+deb http://archive.ubuntu.com/ubuntu/ hardy main restricted
+deb http://archive.ubuntu.com/ubuntu/ hardy-updates main restricted
+deb http://archive.ubuntu.com/ubuntu/ hardy universe
+deb http://archive.ubuntu.com/ubuntu/ hardy-updates universe
+deb http://archive.ubuntu.com/ubuntu/ hardy multiverse
+deb http://archive.ubuntu.com/ubuntu/ hardy-security main restricted
+deb http://archive.ubuntu.com/ubuntu/ hardy-security universe
+deb http://archive.ubuntu.com/ubuntu/ hardy-security multiverse
+deb http://archive.ubuntu.com/ubuntu/ hardy-updates multiverse
+EOF
+apt-get update
+apt-get upgrade
+
+# Add new packages
+apt-get install openssh-server subversion kdetoys kicker-applets kgpg \
+ gftp firefox sg3-utils
+apt-get install flashplugin-nonfree aircrack-ng g++ nvidia-glx-new \
+ gfxboot syslinux mtools
+apt-get install sshfs kile kate lsscsi m4 mtx nfs-common \
+ nfs-kernel-server patch \
+ squashfs-tools strace sg3-utils screen scsiadd system-tools-backends \
+ telnet dpkg traceroute usbutils whois apt-file autofs busybox \
+ chkrootkit clamav dmidecode unrar
+
+apt-get install linux-generic linux-headers-generic
+
+# Add held back packages
+apt-get install bind9-host dnsutils libbind9-30 libisccc30 libisccfg30 \
+ linux-generic linux-headers-generic linux-image-generic \
+ linux-restricted-modules-generic ssl-cert
+
+# Remove old kernel
+apt-get remove linux-headers-2.6.24-22 linux-headers-2.6.24-22-generic \
+ linux-image-2.6.24-22-generic linux-restricted-modules-2.6.24-22-generic \
+ linux-restricted-modules-2.6.24-22-generic linux-ubuntu-modules-2.6.24-22-generic
+
+cd /
+dpkg-query -W --showformat='${Package} ${Version}\n' >filesystem.manifest
+
+apt-get clean
+rm -rf /tmp/*
+rm -f /etc/hosts /etc/resolv.conf
+umount /proc/
+umount /sys/
+exit
+cp sqfs/filesystem.manifest .
+rm -f sqfs/filsystem.manifest
+
+echo "Warning!!!! At this point, it may be better to reboot, since"
+echo " upgrading packages may have restarted some daemons such as"
+echo " cups, which uses sqfs/proc. If you thn try to pack the sqfs"
+echo " you will get lots of errors reference /proc. Rebooting"
+echo " resolves this problem."
+echo " "
--- /dev/null
+#!/bin/sh
+#
+# Put a new squashfs on the disk image
+#
+
+. ../config
+
+
+if [ ! -d ${DISK_IMAGE}/casper ] ; then
+ echo "Cannot find ${DISK_IMAGE}/casper directory -- possibly not detarred"
+ exit 1
+fi
+
+if [ ! -f filesystem.squashfs ] ; then
+ echo "Cannot find filesystem.squashfs ..."
+ exit 1
+fi
+
+echo "Removing old squashfs"
+rm -f ${DISK_IMAGE}/casper/filesystem.squashfs ${DISK_IMAGE}/casper/filesystem.manifest
+rm -f ${DISK_IMAGE}/casper/filesystem.manifest-desktop
+
+echo "Moving new squashfs to ${DISK_IMAGE}"
+cp filesystem.manifest ${DISK_IMAGE}/casper/
+cp filesystem.manifest ${DISK_IMAGE}/casper/filesystem.manifest-desktop
+mv filesystem.squashfs ${DISK_IMAGE}/casper/
+
+echo "Removing old initrd and kernel image"
+rm -f ${DISK_IMAGE}/casper/initrd.gz
+rm -f ${DISK_IMAGE}/casper/vmlinuz
+
+echo "Copying new initrd and kernel image"
+cp sqfs/initrd.img ${DISK_IMAGE}/casper/initrd.gz
+cp sqfs/vmlinuz ${DISK_IMAGE}/casper/vmlinuz
+sync
+
+echo "Now you just need to tar up ${DISK_IMAGE}"
--- /dev/null
+#!/bin/sh
+#
+# write the disk info from the current system to the USB
+# stick. We write it in the home-rw partition
+#
+. ./config
+
+if [ ! `whoami` = "root" ] ; then
+ echo ""
+ echo "You need to be root to run this shell script"
+ echo ""
+ exit 1
+fi
+
+echo " "
+echo "This script will write your current system information to the USB"
+echo "stick in the home-rw partition (/home/ubuntu)"
+
+if [ ! -d ${MOUNT_POINT}/home-rw ] ; then
+ mount ${USB_DEV}3 ${MOUNT_POINT}/home-rw
+fi
+if [ ! -d ${MOUNT_POINT}/home-rw ] ; then
+ echo "Mount of home-rw USB partition failed."
+ echo "Please pre-mount the USB stick and run this script again."
+ exit 1
+fi
+cd ${MOUNT_POINT}/home-rw
+if [ $? -ne 0 ] ; then
+ echo "Could not cd to home-rw USB partition"
+ exit 1
+fi
+
+mkdir -p ubuntu
+chown 1000:1000 ubuntu
+cd ubuntu
+export USB_DEV
+${CWD}/getdiskinfo
+cp -f ${CWD}/write_disk_info_to_usb .
+sync
--- /dev/null
+#!/bin/sh
+#
+# tar the disk image
+#
+. ./config
+
+if [ ! `whoami` = "root" ] ; then
+ echo ""
+ echo "You need to be root to run this shell script"
+ echo ""
+ exit 1
+fi
+if [ ! -f ${BOOT_IMAGE} ] ; then
+ echo "Could not find boot image: ${BOOT_IMAGE}"
+ exit 1
+fi
+if [ "`which syslinux`x" = "x" ] ; then
+ echo ""
+ echo "Could not find syslinux. Try \"apt-get install syslinux\""
+ echo ""
+ exit 1
+fi
+if [ "`which install-mbr`x" = "x" ] ; then
+ echo ""
+ echo "Could not find install-mbr. Try \"apt-get install mbr\""
+ echo ""
+ exit 1
+fi
+
+umount ${USB_DEV}1 2>/dev/null 1>/dev/null
+
+echo "Reformat USB boot partition"
+mkfs.vfat -F 16 -n kubuntu8 ${USB_DEV}1
+if [ ! -d ${MOUNT_POINT}/kubuntu8 ] ; then
+ mkdir -p ${MOUNT_POINT}/kubuntu8
+ created="yes"
+fi
+mount ${USB_DEV}1 ${MOUNT_POINT}/kubuntu8
+if [ $? -ne 0 ] ; then
+ echo "Mount of USB boot partition failed."
+ exit 1
+fi
+cd ${MOUNT_POINT}/kubuntu8
+if [ $? -ne 0 ] ; then
+ echo "Could not cd to USB boot partition"
+ exit 1
+fi
+
+echo "Detaring boot image ..."
+tar xfz ${BOOT_IMAGE}
+# original-partioning.txt was created by partition_usb_key
+if [ -e ${CWD}/original-partitioning.txt ] ; then
+ cp -f ${CWD}/original-partitioning.txt .
+ rm -f ${CWD}/original-partitioning.txt
+fi
+cd ${CWD}
+
+syslinux -sf ${USB_DEV}1
+install-mbr -p1 ${USB_DEV}
+echo "syncing ..."
+sync
+sync
+umount ${MOUNT_POINT}/kubuntu8
+if [ "x$created" = "xyes" ] ; then
+ rmdir ${MOUNT_POINT}/kubuntu8
+fi
+++ /dev/null
-
-Technical details of creating the USB key boot images. Unless
-you want to rebuild (remaster) the iso boot image, you will not
-need this.
-
-The directory "remaster" contains the scripts that allow picking
-apart a Kubuntu Hardy ISO and then updating and recombining the
-parts into a USB boot image. The information below is somewhat
-low level and should not be needed unless you want to do your
-own remastering either starting from the Kubuntu release or from
-the Bacula remastered release.
-
-Note, the sqfs.tar.gz is the whole squashfs unsquashed.
-
-The kernel image (vmlinuz) is a copy of the most recent kernel i.e.
-
- sqfs/boot/vmlinuz-2.6.24-23-generic
-
-and initrd.gz is a copy of the most recent initrd.img i.e
-
- sqfs/boot/initrd.img-2.6.24-23-generic
-
-they are renamed and put in the kubuntu8 partition in:
-
- casper/vmlinuz
-and
- casper/initrd.gz
-
-respectively.
-
-The above updates are automatically done when running
-the write_sqfs_to_disk_image script. Then the final
-step is to tar up kubuntu8.
-
-Note, initrd.gz is made after fixing the bug in
-/usr/share/initramfs-tools/scripts/casper
-see note 2. in bugs with Kubuntu boot process below.
-
-When updating the USB root partition (changing something), I
-strongly recommend that you work with the disk image then
-repack it (pack_disk_image) and then run load_disk_image.
-
-
-Packages needed:
-apt-get install syslinux mbr
-
-
-Kubuntu boot tricks:
-1. Booting with persistence added to the kernel options will permit
- mounting of a USB casper-rw and home-rw partitions on the USB key.
- casper-rw is used to store changed OS files, and home-rw is the
- home directory.
-
-Bugs with Kubuntu boot process:
-1. The initrd.gz image must be opened, fixed and the repacked.
-2. The fix involves removing the ,mode=755 from the mount line for
- the persistent OS partition (casper-rw) or /cow
- in /usr/share/initramfs-tools/scripts/casper
-3. I have removed /etc/rc0.d/S89casper and /etc/rc6.d/S89casper
- because they are related to a CDROM boot and create false
- errors when booting from a USB key.
+++ /dev/null
-
-Copyright (C) Kern E. Sibbald, 2009
-
-This directory is used to build a USB key containing a Kubuntu 8.04 LiveCD
-with persistent OS files and persistent /home files.
-
-You will need to run as root for most things ...
-
-Packages needed:
-apt-get install syslinux mbr
-
-
-1. Start by editing the "config" file. Be sure to get your USB_DEV
- definition correct. Note: you can see what devices you have
- connected by running:
-
- lsscsi
-
- For example, I get:
-
- $ lsscsi
- [1:0:0:0] cd/dvd _NEC DVD+RW ND-1100A 108B /dev/scd0
- [1:0:1:0] cd/dvd PHILIPS DVD+-RW DVD8631 9D03 /dev/scd1
- [9:0:0:0] disk Kingston DataTraveler 2.0 PMAP /dev/sda
-
- and in my case, the USB device is the Kingston DataTraveler on
- device /dev/sda.
-
- Alternatively you can do:
-
- fdisk -l
-
-2. The scripts you need to partition the key and
- to write the boot image to it are all in this (usb) directory.
-
-3. If you ever want to put the key back to its prior state, *before*
- running the partition_usb_key, you might consider doing a:
-
- sfdisk -d /dev/key-device >save_me
-
- where key-device is the key device name (e.g. sda). The
- output file can be fed back into sfdisk to recreate the original
- with:
-
- sfdisk /dev/key-device <save_me
-
-4. The next step is to get a copy of kubuntu8.tar.gz, which is the
- USB boot image. Currently, it can be downloaded from:
-
- www.bacula.org/downloads/kubuntu8.tar.gz
-
- or from:
-
- www.sibbald.com/download/kubuntu8.tar.gz
-
-5. Edit the file "config" and fill in the values that correspond
- to your setup.
-
-6. After editing the config file, run:
-
- ./partition_usb_key
-
- Note, this script will destroy *all* data on the key, and assumes
- that you have a 3GB or bigger key. It may work for a 2GB key,
- but you might want to reduce the size of the second partition.
-
-
- The partition_usb_key script creates three partitions:
-
- 1. kubuntu8 -- USB boot partition containing the OS
- 2. casper-rw -- A writable ext3 partition for saving OS changes
- 3. home-rw -- A writable ext3 partition for saving /home
-
-6. Mount your USB key and detar the kubuntu8.tar.gz image
- into the first partition. Do this with:
-
- ./write_usb_boot_partition
-
- This can take a good amount of time (5 mins) since it must format
- the new partitions then copy the boot image.
-
-7. You should now have a USB stick that can be booted providing the
- machine permits booting from the USB port -- this can be adjusted
- by modifying the BIOS boot sequence. On Dell machines, you can
- enter the BIOS setup by pressing F2 just after power on.
-
- Alternatively, most machines let you boot from an alternate device.
- For example if you press F11 while a Sony Viao is powering up, it
- will boot from the USB port.
-
- On Dell machines during power on, if you press F12, you will be
- able to select any boot device (one time only) other than the one
- that is the default (normally the CDROM or HDD).
-
-8. When the key is booted, assuming you choose the first option
- (LiveCD), you will be running as user "ubuntu" the password is
- "bacula", and you will be in /home/ubuntu.
-
-9. Before booting, you might want to remove the USB key, using the
- remove safely mode, then plug it back in so that you can access
- the home-rw partition. Here you can put anything you want from
- your system. However, you must use care to ensure that the files
- are written with UID=1000 and GID=1000, which is ubuntu:ubuntu when
- your boot the USB key.
-
-10. Finally, if you are running with a KDE desktop on Kubuntu 8.04,
- you can copy it to the key with:
-
- ./copy_kubuntu_desktop_to_usb
-
- If you are not using Kubuntu, you can modify the script to
- adapt it to your situation or simply create a new script.
-
-===
-
-If you want to add additional OS tools to your USB stick, there are two
-ways:
-
-1. Remaster the iso boot image (a bit complicated) see README.technotes
-2. Simply use sudo apt-get install ... when booted into your USB stick.
- The changes will be written to the casper-rw partition (the
- read/write OS partition).
-
-If you want to add something to your USB home directory simply mount
-the home-rw partition and write to it in the appropriate place as noted
-in item #9 above.
-
-One slightly annoying thing about the USB key is that the casper-rw and the
-home-rw partitions must be ext3 (with journaling turned on), and journaling
-is not really the best way to run with USB keys that have a finite write
-lifetime. Switching the partitions to ext2 seems to prevent them from being
-written correctly, which means a lot of things such as starting X do not
-work.
+++ /dev/null
-#
-# You must define certain environment variables in this file
-# so that the scripts know where to find things.
-#
-
-CWD=`pwd`
-
-#
-# Set your home directory here (do not use $HOME !!!)
-# This is used when coping your desktop files to the
-# USB key.
-#
-MY_HOME=
-
-#
-# The device name of your USB device (e.g. /dev/sda)
-# You can find it by plugging it in then doing
-#
-# fdisk -l
-#
-# If you are unsure remove the USB device and rerun the fdisk -l
-# If you get this wrong, your harddisk could be wiped out.
-# It is probably "/dev/sda" or "/dev/sdb" or "/dev/sdc", however, on my latest
-# machine (HP Pavilion), it is /dev/sdg (see the lsscsi listing below)
-#
-# [0:0:0:0] disk ATA WDC WD6400AAKS-6 01.0 /dev/sda
-# [1:0:0:0] cd/dvd HL-DT-ST BDDVDRW GBC-H20L 1.B8 /dev/scd0
-# [2:0:0:0] disk ATA WDC WD6400AAKS-6 01.0 /dev/sdb
-# [6:0:0:0] disk Generic- Compact Flash 1.00 /dev/sdc
-# [6:0:0:1] disk Generic- SM/xD-Picture 1.00 /dev/sdd
-# [6:0:0:2] disk Generic- SD/MMC 1.00 /dev/sde
-# [6:0:0:3] disk Generic- MS/MS-Pro 1.00 /dev/sdf
-# [7:0:0:0] disk Crucial Gizmo! 1100 /dev/sdg
-#
-USB_DEV=
-
-#
-# When your USB key is mounted, what is the mount directory?
-#
-MOUNT_POINT=/media
-
-#
-# This is where you downloaded the USB boot image
-#
-BOOT_IMAGE=${CWD}/kubuntu8.tar.gz
-
-#
-# Disk image of boot partition of USB key -- this is where you
-# unpacked the kubuntu8.tar.bz2 image. Unpacking the image
-# is not necessary unless you want to change it.
-#
-DISK_IMAGE=${CWD}/kubuntu8
-
-#
-# If you are remastering a Ubuntu or Kubuntu ISO (not normally done)
-# Point to the ISO image
-# Used when picking apart a new ISO (i.e. upgrade or something)
-#
-ISO_IMAGE=
-
-#
-# Partition 1 (kubuntu) size
-#
-SIZE_PART1="+750M"
-
-#
-# Partition 2 (casper-rw) size
-#
-SIZE_PART2="+1000M"
-
-#
-# Partition 3 uses whatever is left on the USB key
+++ /dev/null
-#!/bin/sh
-#
-# If you are running on a Kubuntu desktop and you would like to have
-# the same desktop on the usb key, you can do so by running this
-# script. You must be root.
-#
-. ./config
-
-if [ ! `whoami` = "root" ] ; then
- echo ""
- echo "You need to be root to run this shell script"
- echo ""
- exit 1
-fi
-echo " "
-echo "This script will overwrite a number of directories on the USB key"
-echo "for example: .kde .ssh .bashrc .bash_logout .gnupg .mozilla ..."
-echo " "
-echo "Answer yes to continue "
-read a
-if [ "$a" != "yes" ] ; then
- echo "Device $USB_DEV unchanged"
- exit 1
-fi
-
-if [ ! -d ${MOUNT_POINT}/home-rw ] ; then
- mount ${USB_DEV}3 ${MOUNT_POINT}/home-rw
-fi
-if [ ! -d ${MOUNT_POINT}/home-rw ] ; then
- echo "Mount of home-rw USB partition failed."
- echo "Please pre-mount the USB stick and run this script again."
- exit 1
-fi
-cd ${MOUNT_POINT}/home-rw
-if [ $? -ne 0 ] ; then
- echo "Could not cd to home-rw USB partition"
- exit 1
-fi
-
-mkdir -p ubuntu
-chown 1000:1000 ubuntu
-cd ubuntu
-# Do files
-for i in .bashrc .bash_logout ; do
- if [ -f ${MY_HOME}/$i ] ; then
- cp -f ${MY_HOME}/$i .
- chown 1000:1000 $i
- fi
-done
-#
-# Special case for .kde
-#
-echo "Copying .kde ..."
-rm -rf .kde
-mkdir -p .kde
-cd .kde
-cp -a $MY_HOME/.kde/share .
-cd ..
-chown -R 1000:1000 .kde
-
-# Do directories
-for i in .gnupg .ssh .mozilla Desktop ; do
- if [ -d ${MY_HOME}/$i ] ; then
- rm -rf $i
- cp -a ${MY_HOME}/$i .
- chown -R 1000:1000 $i
- fi
-done
-sync
-sync
+++ /dev/null
-#!/bin/sh
-#
-# Create bootstrap information files -- prelude to creating a
-# Bacula Rescue data for USB key
-#
-# Kern Sibbald, December MMII
-# This source distributed under the GPLv2
-#
-export LANG=C
-cwd=`pwd`
-os=`uname -s`
-if [ ! "x$1" = "x" ] ; then
- host=$1
-else
- host=`hostname`
-fi
-echo "Host specific data will be saved in the directory: ${host}"
-echo " "
-mkdir -p $host
-di=${cwd}/$host/diskinfo
-scr=${cwd}/$host/scripts
-
-case $os in
- Linux)
- ;;
- FreeBSD | SunOS | IRIX)
- echo ""
- echo "This code is not yet adapted to this OS"
- exit 1
- ;;
- *)
- echo ""
- echo "Unknown operating system type: $os"
- exit 1
- ;;
-esac
-if [ ! `whoami` = "root" ] ; then
- echo ""
- echo "You need to be root to run this script ..."
- echo ""
- exit 1
-fi
-
-#
-# First collect information
-#
-rm -rf format.* partition.* $di create-* $scr
-echo "Begin collecting system info ..."
-mkdir -p $di
-cd $di
-mount -l >mount.bsi
-mount -l -t ext2 >mount.ext2.bsi
-mount -l -t ext3 >mount.ext3.bsi
-mount -l -t reiserfs >mount.rei.bsi
-cp /etc/fstab fstab.bsi
-cp /etc/mtab mtab.bsi
-df -Tl >df.bsi
-# Pickup all disks except USB_DEV
-sfdisk -s | grep -v "${USB_DEV}" >sfdisk.disks.bsi
-grep "^/dev/" sfdisk.disks.bsi | sed -n 's%\(^/dev/[A-Za-z]*\):.*$%\1%p' >disks.bsi
-for i in `cat disks.bsi`; do
- j=`echo $i | cut -c6-`
- sfdisk -l $i >sfdisk.$j.bsi
- sfdisk -d $i >sfdisk.make.$j.bsi
-done
-cat /proc/swaps > swaps.bsi
-route -n >route.bsi
-ifconfig >ifconfig.bsi
-
-# Gather LVM information
-# Only tested on LVM2
-dolvm=0
-if which lvm > /dev/null 2>/dev/null ; then
- echo "Gathering LVM information"
- dolvm=1
-
- lvm pvs --noheadings --nosuffix -o pv_name,vg_name | cat > lvm-pv.bsi
- lvm vgs --noheadings --nosuffix -o vg_name,vg_extent_size --units=k | cat > lvm-vg.bsi
- lvm lvs --noheadings --nosuffix -o lv_name,vg_name,lv_size --units=k | cat > lvm-lv.bsi
-fi
-
-echo "Done collecting info."
-
-#
-# Done collecting information
-#
-
-
-echo "Begin creating scripts ..."
-#
-# First create partitioning script(s)
-#
-mkdir -p $scr
-for i in `cat disks.bsi`; do
- j=`echo $i | cut -c6-`
- cat >$scr/partition.$j <<END_OF_DATA
-
-#!/bin/sh
-#
-# Partition disk $i -- created by getdiskinfo
-echo ""
-echo "This script will repartition disk $i."
-echo ""
-echo "IT WILL DESTROY ALL DATA ON DISK $i !!!!"
-echo ""
-echo -n "Are you sure you want to continue? yes/no: "
-read a
-if [ x\$a != xyes ] ; then
- exit 1
-fi
-echo "Partitioning disk $i"
-# zap partition info
-dd if=/dev/zero of=$i bs=512 count=2
-# repartition
-sfdisk $i <$di/sfdisk.make.$j.bsi | less
-echo ""
-echo "The previous partitioning was:"
-cat $di/sfdisk.$j.bsi
-#
-echo ""
-echo "The new partitioning is:"
-sfdisk -l $i
-echo ""
-echo "If the disk is correctly partitioned, you should"
-echo "now run the \"format.$j\" script."
-echo ""
-END_OF_DATA
-
-
-chmod 755 $scr/partition.$j
-done
-echo "Done making partitioning scripts"
-
-if [ $dolvm -eq 1 ] ; then
-#
-# LVM phase 1: create the Physical Volumess
-#
- cat > $scr/create-pv <<EOF
-#!/bin/sh
-#
-# Create PVs for LVM -- created by getdiskinfo
-echo ""
-echo "This script will format all partitions listed in diskinfo/lvm-pv.bsi"
-echo ""
-echo "IT WILL DESTROY ALL DATA ON THESE PARTITIONS!!!!"
-echo ""
-EOF
- for pv in `cat lvm-pv.bsi | awk '{print $1}'`; do
- echo "echo \" $pv\"" >> $scr/create-pv
- done
-
- cat >> $scr/create-pv <<EOF
-echo ""
-echo -n "Are you sure you want to continue? yes/no: "
-read a
-if [ x\$a != xyes ] ; then
- exit 1
-fi
-EOF
- for pv in `cat lvm-pv.bsi | awk '{print $1}'`; do
- echo "echo \"Creating PV on $pv\"" >> $scr/create-pv
- echo "lvm pvcreate -ff -y -v $pv" >> $scr/create-pv
- done
- echo "echo \"Done.\"" >> $scr/create-pv
- echo "echo \"If there were no errors, run create-vg to create the volume groups.\"" >> $scr/create-pv
- chmod +x $scr/create-pv
-
-#
-# LVM phase 2: create Volume Groups
-#
- cat > $scr/create-vg <<EOF
-#!/bin/sh
-echo ""
-echo "This script will create all volume groups listed in diskinfo/lvm-vg.bsi"
-echo "You must have sucesfully run create-pv to create the requesite PVs first"
-echo ""
-echo -n "Are you sure you want to continue? yes/no: "
-read a
-if [ x\$a != xyes ] ; then
- exit 1
-fi
-EOF
- cat lvm-vg.bsi | awk '{print $1, $2}' | while read vg pesize ; do
- echo "echo \"Creating VG $vg PE extent size $pesize kbytes"\" >> $scr/create-vg
- pelist=""
- for pv in `cat lvm-pv.bsi | awk "\\\$2 == \"$vg\" { print \\\$1 }"` ; do
- pelist="$pelist $pv"
- done
- echo "lvm vgcreate $vg -v -s ${pesize}k $pelist" >> $scr/create-vg
- done
- echo "echo \"Done.\"" >> $scr/create-vg
- echo "echo \"If there were no errors, run create-lv to create the logical volumes.\"" >> $scr/create-vg
- chmod +x $scr/create-vg
-
-
-#
-# LVM phase 3: create Logical Volumes
-#
-# One quick sidenote: this script creates LVs with a size based on the
-# physical extent count, rather than the size in bytes. This is because
-# at the time of writing this script, lvdisplay erroneously prints out
-# the size in 512 byte sector count rather than 1024 byte blocks.
-# Using the extent count should allow this script to continue to work
-# even after the bug is fixed.
-
- cat > $scr/create-lv <<EOF
-#!/bin/sh
-echo ""
-echo "This script will create all logical volumes listed in diskinfo/lvm-lv.bsi"
-echo "You must have sucesfully run create-vg to create the requesite VGs first"
-echo ""
-echo -n "Are you sure you want to continue? yes/no: "
-read a
-if [ x\$a != xyes ] ; then
- exit 1
-fi
-EOF
- cat lvm-lv.bsi | awk '{print $1, $2, $3}' | while read lv vg lvsize ; do
- # lv=`echo $lv | sed -e 's/.*\///'`
- echo "echo \"Creating LV $lv\"" >> $scr/create-lv
- echo "lvm lvcreate -L ${lvsize}k $vg -n $lv" >> $scr/create-lv
- done
- chmod +x $scr/create-lv
-fi
-
-#
-# Create formatting script(s)
-#
-echo "Begin making formatting script(s) ..."
-for i in `cat disks.bsi`; do
- j=`echo $i | cut -c6-`
- cat >$scr/format.$j <<END_OF_DATA
-#!/bin/sh
-#
-# Format all partitions on disk $i -- created by getdiskinfo
-#
-echo ""
-echo "This script will format all partitions on disk $i."
-echo ""
-echo "IT WILL DESTROY ALL DATA ON DISK $i !!!!"
-echo ""
-echo -n "Are you sure you want to continue? yes/no: "
-read a
-if [ x\$a != xyes ] ; then
- exit 1
-fi
-echo "Do you want to do a disk check for bad blocks?"
-echo -n "It is recommended, but takes time. yes/no: "
-read a
-if [ x\$a = xyes ] ; then
- check="-c"
-else
- check=
-fi
-END_OF_DATA
-
- # Find swap partitions in output from sfdisk
- k=`grep "^$i.*82 Linux swap" sfdisk.$j.bsi | cut -d ' ' -f 1`
- for disk in $k; do
- echo "echo \"Formatting $disk -- swap partition\"" >>$scr/format.$j
- echo "mkswap $check $disk" >>$scr/format.$j
- echo "echo \"\"" >>$scr/format.$j
- done
- # Find ext2 partitions in mount output
- k=`grep "^$i" mount.ext2.bsi | cut -d ' ' -f 1`
- for disk in $k; do
- echo "echo \"Formating $disk -- ext2 partition\"" >>$scr/format.$j
- label=`grep "^$disk" mount.ext2.bsi | cut -d ' ' -f 7 | cut -c2- | cut -d ] -f 1`
- if [ x$label = x ] ; then
- echo "mke2fs -v \$check $disk" >>$scr/format.$j
- else
- echo "mke2fs -v \$check -L $label $disk" >>$scr/format.$j
- fi
- echo "echo \"\"" >>$scr/format.$j
- done
- # Find ext3 partitions in mount output
- k=`grep "^$i" mount.ext3.bsi | cut -d ' ' -f 1`
- for disk in $k; do
- echo "echo \"Formating $disk -- ext3 partition\"" >>$scr/format.$j
- label=`grep "^$disk" mount.ext3.bsi | cut -d ' ' -f 7 | cut -c2- | cut -d ] -f 1`
- if [ x$label = x ] ; then
- echo "mke2fs -v -j \$check $disk" >>$scr/format.$j
- else
- echo "mke2fs -v -j \$check -L $label $disk" >>$scr/format.$j
- fi
- echo "echo \"\"" >>$scr/format.$j
- done
- # Find reiserfs partitions in mount output
- k=`grep "^$i" mount.rei.bsi | cut -d ' ' -f 1`
- for disk in $k; do
- echo "echo \"Formating $disk -- reiser partition\"" >>$scr/format.$j
- label=`grep "^$disk" mount.rei.bsi | cut -d ' ' -f 7 | cut -c2- | cut -d ] -f 1`
- if [ x$label = x ] ; then
- echo "mkereiserfs -V \$check $disk" >>$scr/format.$j
- else
- echo "mkereiserfs -V \$check -L $label $disk" >>$scr/format.$j
- fi
- echo "echo \"\"" >>$scr/format.$j
- done
- chmod 755 $scr/format.$j
-done
-
-#
-# Create LVM formatting scripts(s)
-#
-# Somebody more clever than I with bash scripting
-# could probably factor a lot of this code out.
-#
-if [ $dolvm -eq 1 ] ; then
- echo "Begin making LVM formatting script(s) ..."
- for i in `cat lvm-vg.bsi | awk '{print $1}'`; do
- cat >$scr/format.$i <<END_OF_DATA
-#!/bin/sh
-#
-# Format all partitions on VG $i -- created by getdiskinfo
-#
-echo ""
-echo "This script will format all LVs on VG $i."
-echo ""
-echo "IT WILL DESTROY ALL DATA ON DISK $i !!!!"
-echo ""
-echo -n "Are you sure you want to continue? yes/no: "
-read a
-if [ x\$a != xyes ] ; then
- exit 1
-fi
-echo "Do you want to do a disk check for bad blocks?"
-echo -n "It is recommended, but takes time. yes/no: "
-read a
-if [ x\$a = xyes ] ; then
- check="-c"
-else
- check=
-fi
-END_OF_DATA
-# set -x
- # Find swap partitions in output from sfdisk
- mapper="/dev/mapper/${i}"
- k=`grep "^$mapper" swaps.bsi | awk '{print $1}'`
- for disk in $k; do
- echo "echo \"Formatting $disk -- swap partition\"" >>$scr/format.$i
- echo "mkswap $check $disk" >>$scr/format.$i
- echo "echo \"\"" >>$scr/format.$i
- done
- # Find ext2 partitions in mount output
- k=`grep "^$mapper" mount.ext2.bsi | cut -d ' ' -f 1`
- for disk in $k; do
- echo "echo \"Formating $disk -- ext2 partition\"" >>$scr/format.$i
- label=`grep "^$disk on" mount.ext2.bsi | cut -d ' ' -f 7 | cut -c2- | cut -d ] -f 1`
- if [ x$label = x ] ; then
- echo "mke2fs -v \$check $disk" >>$scr/format.$i
- else
- echo "mke2fs -v \$check -L $label $disk" >>$scr/format.$i
- fi
- echo "echo \"\"" >>$scr/format.$i
- done
- # Find ext3 partitions in mount output
- k=`grep "^$mapper" mount.ext3.bsi | cut -d ' ' -f 1`
- for disk in $k; do
- echo "echo \"Formating $disk -- ext3 partition\"" >>$scr/format.$i
- label=`grep "^$disk on" mount.ext3.bsi | cut -d ' ' -f 7 | cut -c2- | cut -d ] -f 1`
- if [ x$label = x ] ; then
- echo "mke2fs -v -j \$check $disk" >>$scr/format.$i
- else
- echo "mke2fs -v -j \$check -L $label $disk" >>$scr/format.$i
- fi
- echo "echo \"\"" >>$scr/format.$i
- done
- # Find reiserfs partitions in mount output
- k=`grep "^$mapper" mount.rei.bsi | cut -d ' ' -f 1`
- for disk in $k; do
- echo "echo \"Formating $disk -- reiser partition\"" >>$scr/format.$i
- label=`grep "^$disk on" mount.rei.bsi | cut -d ' ' -f 7 | cut -c2- | cut -d ] -f 1`
- if [ x$label = x ] ; then
- echo "mkereiserfs -V \$check $disk" >>$scr/format.$i
- else
- echo "mkereiserfs -V \$check -L $label $disk" >>$scr/format.$i
- fi
- echo "echo \"\"" >>$scr/format.$i
- done
- chmod 755 $scr/format.$i
- done
-fi
-
-cd $scr
-
-#
-# Create network start script
-#
-ifconfig eth0 2>/dev/null >/dev/null
-if [ $? = 0 ] ; then
- ip=`ifconfig eth0 | grep inet | head -1 | sed -n 's/\ \+inet addr:\([0-9]\+\(\.[0-9]\+\)\{3\}\).*/\1/p'`
- cat >start_network <<END_OF_DATA
-#!/bin/sh
-#
-# Start network -- created by getdiskinfo
-#
-ip=$ip
-dev=eth0
-ifconfig lo up
-ifconfig \$dev up \$ip
-END_OF_DATA
-else
- echo "Warning, no eth0 found."
- echo "#!/bin/sh" >start_network
-fi
-# Try eth1
-ifconfig eth1 2>/dev/null >/dev/null
-if [ $? = 0 ] ; then
- ip=`ifconfig eth1 | grep inet | head -1 | sed -n 's/\ \+inet addr:\([0-9]\+\(\.[0-9]\+\)\{3\}\).*/\1/p'`
- cat >>start_network <<END_OF_DATA
-ip1=$ip
-dev1=eth1
-ifconfig \$dev1 up \$ip1
-END_OF_DATA
-fi
-ip=`route -n | grep UG | head -1 | awk '{print $2}'`
-dev=`route -n | grep UG | head -1 | awk '{print $8}'`
-cat >>start_network <<END_OF_DATA
-route add default gw $ip dev $dev
-END_OF_DATA
-
-chmod 755 start_network
-
-cat >$scr/mount_drives <<END_OF_DATA
-#!/bin/sh
-#
-# Mount disk drives -- created by getdiskinfo
-#
-PATH=$PATH:/mnt/disk/sbin:/mnt/disk/bin
-END_OF_DATA
-TMP1=`mktemp gdi.1.XXXXXXXXXX`
-TMP2=`mktemp gdi.2.XXXXXXXXXX`
-if test x${TMP1} = x; then
- TMP1="/tmp/1$$"
- if test -f ${TMP1}; then
- echo "Temp file security problem on: ${TMP1}"
- exit 1
- fi
-fi
-if test x${TMP2} = x; then
- TMP2="/tmp/2$$"
- if test -f ${TMP2}; then
- echo "Temp file security problem on: ${TMP2}"
- rm -f ${TMP1}
- exit 1
- fi
-fi
-sed -n 's/\(^.*\)\ on\ \(.*\)\ type.*$/\1 \/mnt\/disk\2/p' $di/mount.ext2.bsi >${TMP1}
-sed -n 's/\(^.*\)\ on\ \(.*\)\ type.*$/\1 \/mnt\/disk\2/p' $di/mount.ext3.bsi >>${TMP1}
-sed -n 's/\(^.*\)\ on\ \(.*\)\ type.*$/\1 \/mnt\/disk\2/p' $di/mount.rei.bsi >>${TMP1}
-# sort so that / is first
-sort -k 2 <${TMP1} >${TMP2}
-# output mkdir followed by its mount
-sed -n 's/\(^.*\)\ \(.*$\)/mkdir -p \2\
-mount \1 \2/p' ${TMP2} >>$scr/mount_drives
-
-# Now build unmount_drives
-cat >$scr/umount_drives <<END_OF_DATA
-#!/bin/sh
-#
-# Unmount disk drives -- created by getdiskinfo
-#
-END_OF_DATA
-sort -r -k 2 <${TMP1} >${TMP2}
-sed -n 's/\(^.*\)\ \(.*$\)/umount \2/p' ${TMP2} >>$scr/umount_drives
-echo "umount /mnt/cdrom 2>/dev/null >/dev/null" >>$scr/umount_drives
-echo "sync" >>$scr/umount_drives
-echo "sync" >>$scr/umount_drives
-
-rm -f ${TMP1} ${TMP2}
-
-chmod 755 $scr/mount_drives $scr/umount_drives
-echo "Done building scripts."
+++ /dev/null
-#
-# You must define certain environment variables in this file
-# so that the scripts know where to find things.
-#
-
-CWD=`pwd`
-
-#
-# Set your home directory here (do not use $HOME !!!)
-# This is used when coping your desktop files to the
-# USB key.
-#
-MY_HOME=/home/kern
-
-#
-# The device name of your USB device (e.g. /dev/sda)
-# You can find it by plugging it in then doing
-#
-# fdisk -l
-#
-# If you are unsure remove the USB device and rerun the fdisk -l
-# If you get this wrong, your harddisk could be wiped out.
-# It is probably "sda" or "sdb" or "sdc"
-#
-USB_DEV=/dev/sdg
-
-#
-# When your USB key is mounted, what is the mount directory?
-#
-MOUNT_POINT=/media
-
-#
-# This is where you downloaded the USB boot image
-#
-BOOT_IMAGE=${CWD}/kubuntu8.tar.gz
-
-#
-# Disk image of boot partition of USB key -- this is where you
-# unpacked the kubuntu8.tar.bz2 image. Unpacking the image
-# is not necessary unless you want to change it.
-#
-DISK_IMAGE=${CWD}/kubuntu8
-
-#
-# If you are remastering a Ubuntu or Kubuntu ISO (not normally done)
-# Point to the ISO image
-# Used when picking apart a new ISO (i.e. upgrade or something)
-#
-ISO_IMAGE=
-
-#
-# Partition 1 (kubuntu) size
-#
-SIZE_PART1="+750M"
-
-#
-# Partition 2 (casper-rw) size
-#
-SIZE_PART2="+1000M"
-
-#
-# Partition 3 uses whatever is left on the USB key
+++ /dev/null
-#!/bin/sh
-#
-# Partition the USB stick -- the stick is assumed to be at least 3GB in size
-#
-# First delete all existing partitions
-#
-. ./config
-
-if [ ! `whoami` = "root" ] ; then
- echo ""
- echo "You need to be root to run this shell script"
- echo ""
- exit 1
-fi
-if [ "x$USB_DEV" = "x" ] ; then
- if [ "x$1" = "x" ] ; then
- echo "You must supply the USB device name on the command line or in USB_DEV"
- exit 1
- else
- USB_DEV=$1
- fi
-fi
-echo "This script will distroy everything on $dev"
-fdisk -l $USB_DEV
-echo " "
-echo "Answer yes to continue "
-read a
-if [ "$a" != "yes" ] ; then
- echo "Device $USB_DEV unchanged"
- exit 1
-fi
-sfdisk -l $USB_DEV >original-partitioning.txt
-fdisk $USB_DEV <<EOF
-d
-4
-d
-3
-d
-2
-d
-1
-n
-p
-1
-
-${SIZE_PART1}
-t
-6
-a
-1
-n
-p
-2
-
-${SIZE_PART2}
-n
-p
-3
-
-
-p
-w
-EOF
-umount ${USB_DEV}1
-mkfs.vfat -F 16 -n kubuntu8 ${USB_DEV}1
-umount ${USB_DEV}2
-mkfs.ext3 -j -b 4096 -L casper-rw ${USB_DEV}2
-# Do fs checking every 100 mounts or 360 days
-tune2fs -c 100 -i 360 ${USB_DEV}2
-umount ${USB_DEV}3
-mkfs.ext3 -j -b 4096 -L home-rw ${USB_DEV}3
-tune2fs -c 100 -i 360 ${USB_DEV}3
-sync
-
-echo "New partitioning is:"
-fdisk -l ${USB_DEV}
+++ /dev/null
-#!/bin/sh
-#
-. ./config
-
-mkdir -p cdrom
-mount -o loop -t iso9660 $ISO_IMAGE cdrom
+++ /dev/null
-#!/bin/sh
-#
-# tar the disk image
-#
-. ../config
-
-rm -f kubuntu8.tar.gz
-cd $DISK_IMAGE
-# Update checksum
-find . -type f -print0 | xargs -0 md5sum >md5sum.txt
-tar cfz $CWD/kubuntu8.tar.gz .
-cd $CWD
-ls -l kubuntu8.tar.gz
+++ /dev/null
-#!/bin/sh
-#
-if [ ! -d initrd ] ; then
- echo "Cannot find initrd directory."
- exit 1
-fi
-cd initrd
-echo "Packing initrd to initrd.gz ..."
-find . | cpio -o -H newc | gzip -9 > ../initrd.gz
-if [ "x$SUID_UID" != "x" ] ; then
- if [ "x$SUID_GID" = "x" ] ; then
- chown $SUID_UID ../initrd.gz
- else
- chown $SUID_UID:$SUID_GID ../initrd.gz
- fi
-fi
+++ /dev/null
-#!/bin/sh
-#
-. ../config
-
-if [ ! -d sqfs ] ; then
- echo "Cannot find sqfs ..."
- exit 1
-fi
-rm -f filesystem.squashfs
-echo "Squashing the filesystem ..."
-mksquashfs sqfs filesystem.squashfs
-rm -f filesystem.manifest
-cp sqfs/filesystem.manifest .
+++ /dev/null
-#!/bin/sh
-#
-
-umount cdrom
-if [ $? -eq 0 ] ; then
- rmdir cdrom
-fi
+++ /dev/null
-#!/bin/sh
-#
-rm -rf initrd
-mkdir -p initrd
-cd initrd
-echo "Unpacking initrd.gz into initrd ..."
-gzip -dc ../cdrom/casper/initrd.gz | cpio -i
+++ /dev/null
-#!/bin/sh
-#
-mkdir -p sqfs
-mkdir cdsqfs
-mount -o loop -t squashfs cdrom/casper/filesystem.squashfs cdsqfs
-if [ $? -ne 0 ] ; then
- echo "Error mounting squashfs ..."
- rm -rf cdsqfs
- exit 1
-fi
-echo "Copying ISO squashfs to sqfs ..."
-rsync -avx -P cdsqfs/. sqfs/.
-#
-umount cdsqfs/
-if [ $? -ne 0 ] ; then
- umount cdsqfs/
- if [ $? -ne 0 ] ; then
- echo "Could not umount cdsqfs ..."
- exit 1
- fi
-fi
-rmdir cdsqfs
+++ /dev/null
-#!/bin/sh
-#
-# Update squashfs -- assumes you start with a Hardy 8.04.1 desktop,
-# but it should work even if you have already updated it.
-#
-
-if [ ! -d sqfs ] ; then
- echo "Cannot find squashfs (sqfs directory)"
- exit 1
-fi
-chroot sqfs /bin/sh
-mount -t proc none /proc/
-mount -t sysfs non /sys/
-export HOME=/root
-
-# remove packages
-apt-get remove --purge `dpkg-query -W --showformat '${Package}\n' | grep language-pack | egrep -v '\-en'`
-apt-get remove --purge `dpkg-query -W --showformat '${Package}\n' | grep openoffice\.org-`
-apt-get remove --purge amarok dictionaries-common
-
-cat >/etc/resolv.conf <<EOF
-search sibbald.com
-nameserver 192.168.68.254
-nameserver 208.67.222.222
-nameserver 208.67.220.220
-EOF
-
-cat >/etc/apt/sources.list <<EOF
-deb http://archive.ubuntu.com/ubuntu/ hardy main restricted
-deb http://archive.ubuntu.com/ubuntu/ hardy-updates main restricted
-deb http://archive.ubuntu.com/ubuntu/ hardy universe
-deb http://archive.ubuntu.com/ubuntu/ hardy-updates universe
-deb http://archive.ubuntu.com/ubuntu/ hardy multiverse
-deb http://archive.ubuntu.com/ubuntu/ hardy-security main restricted
-deb http://archive.ubuntu.com/ubuntu/ hardy-security universe
-deb http://archive.ubuntu.com/ubuntu/ hardy-security multiverse
-deb http://archive.ubuntu.com/ubuntu/ hardy-updates multiverse
-EOF
-apt-get update
-apt-get upgrade
-
-# Add new packages
-apt-get install openssh-server subversion kdetoys kicker-applets kgpg \
- gftp firefox sg3-utils
-apt-get install flashplugin-nonfree aircrack-ng g++ nvidia-glx-new \
- gfxboot syslinux mtools
-apt-get install sshfs kile kate lsscsi m4 mtx nfs-common \
- nfs-kernel-server patch \
- squashfs-tools strace sg3-utils screen scsiadd system-tools-backends \
- telnet dpkg traceroute usbutils whois apt-file autofs busybox \
- chkrootkit clamav dmidecode unrar
-
-apt-get install linux-generic linux-headers-generic
-
-# Add held back packages
-apt-get install bind9-host dnsutils libbind9-30 libisccc30 libisccfg30 \
- linux-generic linux-headers-generic linux-image-generic \
- linux-restricted-modules-generic ssl-cert
-
-# Remove old kernel
-apt-get remove linux-headers-2.6.24-22 linux-headers-2.6.24-22-generic \
- linux-image-2.6.24-22-generic linux-restricted-modules-2.6.24-22-generic \
- linux-restricted-modules-2.6.24-22-generic linux-ubuntu-modules-2.6.24-22-generic
-
-cd /
-dpkg-query -W --showformat='${Package} ${Version}\n' >filesystem.manifest
-
-apt-get clean
-rm -rf /tmp/*
-rm -f /etc/hosts /etc/resolv.conf
-umount /proc/
-umount /sys/
-exit
-cp sqfs/filesystem.manifest .
-rm -f sqfs/filsystem.manifest
-
-echo "Warning!!!! At this point, it may be better to reboot, since"
-echo " upgrading packages may have restarted some daemons such as"
-echo " cups, which uses sqfs/proc. If you thn try to pack the sqfs"
-echo " you will get lots of errors reference /proc. Rebooting"
-echo " resolves this problem."
-echo " "
+++ /dev/null
-#!/bin/sh
-#
-# Put a new squashfs on the disk image
-#
-
-. ../config
-
-
-if [ ! -d ${DISK_IMAGE}/casper ] ; then
- echo "Cannot find ${DISK_IMAGE}/casper directory -- possibly not detarred"
- exit 1
-fi
-
-if [ ! -f filesystem.squashfs ] ; then
- echo "Cannot find filesystem.squashfs ..."
- exit 1
-fi
-
-echo "Removing old squashfs"
-rm -f ${DISK_IMAGE}/casper/filesystem.squashfs ${DISK_IMAGE}/casper/filesystem.manifest
-rm -f ${DISK_IMAGE}/casper/filesystem.manifest-desktop
-
-echo "Moving new squashfs to ${DISK_IMAGE}"
-cp filesystem.manifest ${DISK_IMAGE}/casper/
-cp filesystem.manifest ${DISK_IMAGE}/casper/filesystem.manifest-desktop
-mv filesystem.squashfs ${DISK_IMAGE}/casper/
-
-echo "Removing old initrd and kernel image"
-rm -f ${DISK_IMAGE}/casper/initrd.gz
-rm -f ${DISK_IMAGE}/casper/vmlinuz
-
-echo "Copying new initrd and kernel image"
-cp sqfs/initrd.img ${DISK_IMAGE}/casper/initrd.gz
-cp sqfs/vmlinuz ${DISK_IMAGE}/casper/vmlinuz
-sync
-
-echo "Now you just need to tar up ${DISK_IMAGE}"
+++ /dev/null
-#!/bin/sh
-#
-# write the disk info from the current system to the USB
-# stick. We write it in the home-rw partition
-#
-. ./config
-
-if [ ! `whoami` = "root" ] ; then
- echo ""
- echo "You need to be root to run this shell script"
- echo ""
- exit 1
-fi
-
-echo " "
-echo "This script will write your current system information to the USB"
-echo "stick in the home-rw partition (/home/ubuntu)"
-
-if [ ! -d ${MOUNT_POINT}/home-rw ] ; then
- mount ${USB_DEV}3 ${MOUNT_POINT}/home-rw
-fi
-if [ ! -d ${MOUNT_POINT}/home-rw ] ; then
- echo "Mount of home-rw USB partition failed."
- echo "Please pre-mount the USB stick and run this script again."
- exit 1
-fi
-cd ${MOUNT_POINT}/home-rw
-if [ $? -ne 0 ] ; then
- echo "Could not cd to home-rw USB partition"
- exit 1
-fi
-
-mkdir -p ubuntu
-chown 1000:1000 ubuntu
-cd ubuntu
-export USB_DEV
-${CWD}/getdiskinfo
-cp -f ${CWD}/write_disk_info_to_usb .
-sync
+++ /dev/null
-#!/bin/sh
-#
-# tar the disk image
-#
-. ./config
-
-if [ ! `whoami` = "root" ] ; then
- echo ""
- echo "You need to be root to run this shell script"
- echo ""
- exit 1
-fi
-if [ ! -f ${BOOT_IMAGE} ] ; then
- echo "Could not find boot image: ${BOOT_IMAGE}"
- exit 1
-fi
-if [ "`which syslinux`x" = "x" ] ; then
- echo ""
- echo "Could not find syslinux. Try \"apt-get install syslinux\""
- echo ""
- exit 1
-fi
-if [ "`which install-mbr`x" = "x" ] ; then
- echo ""
- echo "Could not find install-mbr. Try \"apt-get install mbr\""
- echo ""
- exit 1
-fi
-
-umount ${USB_DEV}1 2>/dev/null 1>/dev/null
-
-echo "Reformat USB boot partition"
-mkfs.vfat -F 16 -n kubuntu8 ${USB_DEV}1
-if [ ! -d ${MOUNT_POINT}/kubuntu8 ] ; then
- mkdir -p ${MOUNT_POINT}/kubuntu8
- created="yes"
-fi
-mount ${USB_DEV}1 ${MOUNT_POINT}/kubuntu8
-if [ $? -ne 0 ] ; then
- echo "Mount of USB boot partition failed."
- exit 1
-fi
-cd ${MOUNT_POINT}/kubuntu8
-if [ $? -ne 0 ] ; then
- echo "Could not cd to USB boot partition"
- exit 1
-fi
-
-echo "Detaring boot image ..."
-tar xfz ${BOOT_IMAGE}
-# original-partioning.txt was created by partition_usb_key
-if [ -e ${CWD}/original-partitioning.txt ] ; then
- cp -f ${CWD}/original-partitioning.txt .
- rm -f ${CWD}/original-partitioning.txt
-fi
-cd ${CWD}
-
-syslinux -sf ${USB_DEV}1
-install-mbr -p1 ${USB_DEV}
-echo "syncing ..."
-sync
-sync
-umount ${MOUNT_POINT}/kubuntu8
-if [ "x$created" = "xyes" ] ; then
- rmdir ${MOUNT_POINT}/kubuntu8
-fi