From 1a90ea1f9904c09d1d02c38c6a605d2a9213e75d Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Mon, 5 Jan 2009 15:25:08 +0000 Subject: [PATCH] Update --- rescue/linux/usb/README.usb | 124 ----- rescue/linux/usb/config | 45 -- rescue/linux/usb/copy_kubuntu_desktop_to_usb | 57 --- rescue/linux/usb/getdiskinfo | 465 ------------------ rescue/linux/usb/partition_usb_key | 70 --- rescue/linux/usb/remaster/mount_iso | 6 - rescue/linux/usb/remaster/pack_disk_image | 13 - rescue/linux/usb/remaster/pack_initrd | 16 - rescue/linux/usb/remaster/pack_sqfs | 13 - rescue/linux/usb/remaster/unmount_iso | 7 - rescue/linux/usb/remaster/unpack_initrd | 7 - rescue/linux/usb/remaster/unpack_sqfs | 22 - rescue/linux/usb/remaster/update_packages | 61 --- .../usb/remaster/write_sqfs_to_disk_image | 27 - rescue/linux/usb/write_usb_boot_partition | 49 -- 15 files changed, 982 deletions(-) delete mode 100644 rescue/linux/usb/README.usb delete mode 100644 rescue/linux/usb/config delete mode 100755 rescue/linux/usb/copy_kubuntu_desktop_to_usb delete mode 100755 rescue/linux/usb/getdiskinfo delete mode 100755 rescue/linux/usb/partition_usb_key delete mode 100755 rescue/linux/usb/remaster/mount_iso delete mode 100755 rescue/linux/usb/remaster/pack_disk_image delete mode 100755 rescue/linux/usb/remaster/pack_initrd delete mode 100755 rescue/linux/usb/remaster/pack_sqfs delete mode 100755 rescue/linux/usb/remaster/unmount_iso delete mode 100755 rescue/linux/usb/remaster/unpack_initrd delete mode 100755 rescue/linux/usb/remaster/unpack_sqfs delete mode 100644 rescue/linux/usb/remaster/update_packages delete mode 100755 rescue/linux/usb/remaster/write_sqfs_to_disk_image delete mode 100755 rescue/linux/usb/write_usb_boot_partition diff --git a/rescue/linux/usb/README.usb b/rescue/linux/usb/README.usb deleted file mode 100644 index 31bbf90..0000000 --- a/rescue/linux/usb/README.usb +++ /dev/null @@ -1,124 +0,0 @@ - -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 ... - -Start by editing the "config" file. Be sure to get your USB_DEV -definition correct. The scripts you need to partition the key and -to write the boot image to it are all in this (usb) directory. - -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. - -==== -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 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 -sfdisk -s >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 < $scr/create-pv <> $scr/create-pv - done - - cat >> $scr/create-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 <> $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 <> $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 <>$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 <>$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 <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 <>start_network <$scr/mount_drives <${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 <${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." diff --git a/rescue/linux/usb/partition_usb_key b/rescue/linux/usb/partition_usb_key deleted file mode 100755 index 6ef9bb4..0000000 --- a/rescue/linux/usb/partition_usb_key +++ /dev/null @@ -1,70 +0,0 @@ -#!/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 - -fdisk $USB_DEV <md5sum.txt -tar cfz $CWD/kubuntu8.tar.gz . -cd $CWD -ls -l kubuntu8.tar.gz diff --git a/rescue/linux/usb/remaster/pack_initrd b/rescue/linux/usb/remaster/pack_initrd deleted file mode 100755 index bd5677f..0000000 --- a/rescue/linux/usb/remaster/pack_initrd +++ /dev/null @@ -1,16 +0,0 @@ -#!/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 diff --git a/rescue/linux/usb/remaster/pack_sqfs b/rescue/linux/usb/remaster/pack_sqfs deleted file mode 100755 index f498ada..0000000 --- a/rescue/linux/usb/remaster/pack_sqfs +++ /dev/null @@ -1,13 +0,0 @@ -#!/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 . diff --git a/rescue/linux/usb/remaster/unmount_iso b/rescue/linux/usb/remaster/unmount_iso deleted file mode 100755 index 18686f7..0000000 --- a/rescue/linux/usb/remaster/unmount_iso +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -# - -umount cdrom -if [ $? -eq 0 ] ; then - rmdir cdrom -fi diff --git a/rescue/linux/usb/remaster/unpack_initrd b/rescue/linux/usb/remaster/unpack_initrd deleted file mode 100755 index 4874fa3..0000000 --- a/rescue/linux/usb/remaster/unpack_initrd +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -# -rm -rf initrd -mkdir -p initrd -cd initrd -echo "Unpacking initrd.gz into initrd ..." -gzip -dc ../cdrom/casper/initrd.gz | cpio -i diff --git a/rescue/linux/usb/remaster/unpack_sqfs b/rescue/linux/usb/remaster/unpack_sqfs deleted file mode 100755 index 458f7f7..0000000 --- a/rescue/linux/usb/remaster/unpack_sqfs +++ /dev/null @@ -1,22 +0,0 @@ -#!/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 diff --git a/rescue/linux/usb/remaster/update_packages b/rescue/linux/usb/remaster/update_packages deleted file mode 100644 index b990001..0000000 --- a/rescue/linux/usb/remaster/update_packages +++ /dev/null @@ -1,61 +0,0 @@ -#!/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/apt/sources.list <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 diff --git a/rescue/linux/usb/remaster/write_sqfs_to_disk_image b/rescue/linux/usb/remaster/write_sqfs_to_disk_image deleted file mode 100755 index fe61751..0000000 --- a/rescue/linux/usb/remaster/write_sqfs_to_disk_image +++ /dev/null @@ -1,27 +0,0 @@ -#!/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 "Copying new squashfs" -cp filesystem.manifest ${DISK_IMAGE}/casper/ -cp filesystem.manifest ${DISK_IMAGE}/casper/filesystem.manifest-desktop -cp filesystem.squashfs ${DISK_IMAGE}/casper/ -sync diff --git a/rescue/linux/usb/write_usb_boot_partition b/rescue/linux/usb/write_usb_boot_partition deleted file mode 100755 index a716469..0000000 --- a/rescue/linux/usb/write_usb_boot_partition +++ /dev/null @@ -1,49 +0,0 @@ -#!/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 - -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} -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 -- 2.39.5