From 5fa1e7c63be2c5b2ec292956ea52fde0521fa242 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Sat, 3 Jan 2009 15:39:27 +0000 Subject: [PATCH] Update --- rescue/linux/usb/getdiskinfo | 142 +++++++++--------- rescue/linux/usb/loadsqfs | 21 --- rescue/linux/usb/new_sqfs | 22 +++ rescue/linux/usb/{packsqfs => pack_sqfs} | 0 .../{partitionusbkey => partition_usb_key} | 0 rescue/linux/usb/{unpacksqfs => unpack_sqfs} | 0 ...ad_disk_image => write_usb_boot_partition} | 12 +- 7 files changed, 102 insertions(+), 95 deletions(-) delete mode 100755 rescue/linux/usb/loadsqfs create mode 100755 rescue/linux/usb/new_sqfs rename rescue/linux/usb/{packsqfs => pack_sqfs} (100%) rename rescue/linux/usb/{partitionusbkey => partition_usb_key} (100%) rename rescue/linux/usb/{unpacksqfs => unpack_sqfs} (100%) rename rescue/linux/usb/{load_disk_image => write_usb_boot_partition} (64%) diff --git a/rescue/linux/usb/getdiskinfo b/rescue/linux/usb/getdiskinfo index 4e90cd1..75ec655 100755 --- a/rescue/linux/usb/getdiskinfo +++ b/rescue/linux/usb/getdiskinfo @@ -7,9 +7,10 @@ # This source distributed under the GPL # export LANG=C -di=diskinfo cwd=`pwd` host=`uname -s` +di=${cwd}/diskinfo +scr=${cwd}/scripts case $host in Linux) @@ -35,7 +36,7 @@ fi # # First collect information # -rm -rf format.* partition.* $di create-* +rm -rf format.* partition.* $di create-* $scr echo "Begin collecting system info ..." mkdir -p $di cd $di @@ -80,9 +81,10 @@ 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 >$cwd/partition.$j <$scr/partition.$j < $cwd/create-pv < $scr/create-pv <> $cwd/create-pv + echo "echo \" $pv\"" >> $scr/create-pv done - cat >> $cwd/create-pv <> $scr/create-pv <> $cwd/create-pv - echo "lvm pvcreate -ff -y -v $pv" >> $cwd/create-pv + echo "echo \"Creating PV on $pv\"" >> $scr/create-pv + echo "lvm pvcreate -ff -y -v $pv" >> $scr/create-pv done - echo "echo \"Done.\"" >> $cwd/create-pv - echo "echo \"If there were no errors, run create-vg to create the volume groups.\"" >> $cwd/create-pv - chmod +x $cwd/create-pv + 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 > $cwd/create-vg < $scr/create-vg <> $cwd/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" >> $cwd/create-vg + 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.\"" >> $cwd/create-vg - echo "echo \"If there were no errors, run create-lv to create the logical volumes.\"" >> $cwd/create-vg - chmod +x $cwd/create-vg + 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 # @@ -192,7 +194,7 @@ EOF # Using the extent count should allow this script to continue to work # even after the bug is fixed. - cat > $cwd/create-lv < $scr/create-lv <> $cwd/create-lv - echo "lvm lvcreate -L ${lvsize}k $vg -n $lv" >> $cwd/create-lv + # 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 $cwd/create-lv + chmod +x $scr/create-lv fi # @@ -218,7 +220,7 @@ fi echo "Begin making formatting script(s) ..." for i in `cat disks.bsi`; do j=`echo $i | cut -c6-` - cat >$cwd/format.$j <$scr/format.$j <>$cwd/format.$j - echo "mkswap $check $disk" >>$cwd/format.$j - echo "echo \"\"" >>$cwd/format.$j + 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\"" >>$cwd/format.$j + 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" >>$cwd/format.$j + echo "mke2fs -v \$check $disk" >>$scr/format.$j else - echo "mke2fs -v \$check -L $label $disk" >>$cwd/format.$j + echo "mke2fs -v \$check -L $label $disk" >>$scr/format.$j fi - echo "echo \"\"" >>$cwd/format.$j + 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\"" >>$cwd/format.$j + 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" >>$cwd/format.$j + echo "mke2fs -v -j \$check $disk" >>$scr/format.$j else - echo "mke2fs -v -j \$check -L $label $disk" >>$cwd/format.$j + echo "mke2fs -v -j \$check -L $label $disk" >>$scr/format.$j fi - echo "echo \"\"" >>$cwd/format.$j + 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\"" >>$cwd/format.$j + 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" >>$cwd/format.$j + echo "mkereiserfs -V \$check $disk" >>$scr/format.$j else - echo "mkereiserfs -V \$check -L $label $disk" >>$cwd/format.$j + echo "mkereiserfs -V \$check -L $label $disk" >>$scr/format.$j fi - echo "echo \"\"" >>$cwd/format.$j + echo "echo \"\"" >>$scr/format.$j done - chmod 755 $cwd/format.$j + chmod 755 $scr/format.$j done # @@ -298,7 +300,7 @@ done if [ $dolvm -eq 1 ] ; then echo "Begin making LVM formatting script(s) ..." for i in `cat lvm-vg.bsi | awk '{print $1}'`; do - cat >$cwd/format.$i <$scr/format.$i <>$cwd/format.$i - echo "mkswap $check $disk" >>$cwd/format.$i - echo "echo \"\"" >>$cwd/format.$i + 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\"" >>$cwd/format.$i + 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" >>$cwd/format.$i + echo "mke2fs -v \$check $disk" >>$scr/format.$i else - echo "mke2fs -v \$check -L $label $disk" >>$cwd/format.$i + echo "mke2fs -v \$check -L $label $disk" >>$scr/format.$i fi - echo "echo \"\"" >>$cwd/format.$i + 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\"" >>$cwd/format.$i + 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" >>$cwd/format.$i + echo "mke2fs -v -j \$check $disk" >>$scr/format.$i else - echo "mke2fs -v -j \$check -L $label $disk" >>$cwd/format.$i + echo "mke2fs -v -j \$check -L $label $disk" >>$scr/format.$i fi - echo "echo \"\"" >>$cwd/format.$i + 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\"" >>$cwd/format.$i + 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" >>$cwd/format.$i + echo "mkereiserfs -V \$check $disk" >>$scr/format.$i else - echo "mkereiserfs -V \$check -L $label $disk" >>$cwd/format.$i + echo "mkereiserfs -V \$check -L $label $disk" >>$scr/format.$i fi - echo "echo \"\"" >>$cwd/format.$i + echo "echo \"\"" >>$scr/format.$i done - chmod 755 $cwd/format.$i + chmod 755 $scr/format.$i done fi -cd $cwd +cd $scr # # Create network start script @@ -411,7 +413,7 @@ END_OF_DATA chmod 755 start_network -cat >mount_drives <$scr/mount_drives <>$ sort -k 2 <${TMP1} >${TMP2} # output mkdir followed by its mount sed -n 's/\(^.*\)\ \(.*$\)/mkdir -p \2\ -mount \1 \2/p' ${TMP2} >>mount_drives +mount \1 \2/p' ${TMP2} >>$scr/mount_drives # Now build unmount_drives -cat >umount_drives <$scr/umount_drives <${TMP2} -sed -n 's/\(^.*\)\ \(.*$\)/umount \2/p' ${TMP2} >>umount_drives -echo "umount /mnt/cdrom 2>/dev/null >/dev/null" >>umount_drives -echo "sync" >>umount_drives -echo "sync" >>umount_drives +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 mount_drives umount_drives +chmod 755 $scr/mount_drives $scr/umount_drives echo "Done building scripts." diff --git a/rescue/linux/usb/loadsqfs b/rescue/linux/usb/loadsqfs deleted file mode 100755 index 9eea9e6..0000000 --- a/rescue/linux/usb/loadsqfs +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh -# -# Load squashfs onto the USB key -# - -key=/media/kubuntu8 - -if [ ! -d $key/casper ] ; then - echo "Cannot find $key/casper directory -- possibly not mounted" - exit 1 -fi - -echo "Removing old squashfs" -rm -f $key/casper/filesystem.squashfs $key/casper/filesystem.manifest -rm -f $key/casper/filesystem.manifest-desktop - -echo "Copying new squashfs" -cp filesystem.manifest $key/casper/ -cp filesystem.manifest $key/casper/filesystem.manifest-desktop -cp filesystem.squashfs $key/casper/ -sync diff --git a/rescue/linux/usb/new_sqfs b/rescue/linux/usb/new_sqfs new file mode 100755 index 0000000..8cf2836 --- /dev/null +++ b/rescue/linux/usb/new_sqfs @@ -0,0 +1,22 @@ +#!/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 + +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/packsqfs b/rescue/linux/usb/pack_sqfs similarity index 100% rename from rescue/linux/usb/packsqfs rename to rescue/linux/usb/pack_sqfs diff --git a/rescue/linux/usb/partitionusbkey b/rescue/linux/usb/partition_usb_key similarity index 100% rename from rescue/linux/usb/partitionusbkey rename to rescue/linux/usb/partition_usb_key diff --git a/rescue/linux/usb/unpacksqfs b/rescue/linux/usb/unpack_sqfs similarity index 100% rename from rescue/linux/usb/unpacksqfs rename to rescue/linux/usb/unpack_sqfs diff --git a/rescue/linux/usb/load_disk_image b/rescue/linux/usb/write_usb_boot_partition similarity index 64% rename from rescue/linux/usb/load_disk_image rename to rescue/linux/usb/write_usb_boot_partition index e25019d..fe871b1 100755 --- a/rescue/linux/usb/load_disk_image +++ b/rescue/linux/usb/write_usb_boot_partition @@ -11,9 +11,10 @@ if [ ! `whoami` = "root" ] ; then exit 1 fi -umount ${USB_DEV}1 +umount ${USB_DEV}1 2>/dev/null 1>/dev/null +echo "Reformat USB boot partition" mkfs.vfat -F 16 -n kubuntu8 ${USB_DEV}1 -mount ${MOUNT_POINT}/kubuntu8 +mount ${USB_DEV}1 ${MOUNT_POINT}/kubuntu8 if [ $? -ne 0 ] ; then echo "Mount of USB boot partition failed." exit 1 @@ -23,7 +24,10 @@ if [ $? -ne 0 ] ; then echo "Could not cd to USB boot partition" exit 1 fi -tar xfz ${BOOT_IMAGE} . +echo "Detaring boot image ..." +tar xfz ${BOOT_IMAGE} +cd ${CWD} ls -l ${MOUNT_POINT}/kubuntu8 +echo "syncing ..." sync -unmount ${MOUNT_POINT}/kubuntu8 +umount ${MOUNT_POINT}/kubuntu8 -- 2.39.5