]> git.sur5r.net Git - bacula/rescue/blob - rescue/linux/oldusb/write_usb_boot_partition
7c64a5fd82189104c381f91e2fb184e574be66ba
[bacula/rescue] / rescue / linux / oldusb / write_usb_boot_partition
1 #!/bin/sh
2 #
3 # tar the disk image
4 #
5 . ./config
6
7 if [ ! `whoami` = "root" ] ; then
8   echo ""
9   echo "You need to be root to run this shell script"
10   echo ""
11   exit 1
12 fi
13 if [ ! -f ${BOOT_IMAGE} ] ; then
14   echo "Could not find boot image: ${BOOT_IMAGE}"
15   exit 1
16 fi
17 if [ "`which syslinux`x" = "x" ] ; then
18   echo ""
19   echo "Could not find syslinux. Try \"apt-get install syslinux\""
20   echo ""
21   exit 1
22 fi
23 if [ "`which install-mbr`x" = "x" ] ; then
24   echo ""
25   echo "Could not find install-mbr. Try \"apt-get install mbr\""
26   echo ""
27   exit 1
28 fi
29
30 umount ${USB_DEV}1 2>/dev/null 1>/dev/null
31
32 echo "Reformat USB boot partition"
33 mkfs.vfat -F 16 -n kubuntu8 ${USB_DEV}1
34 if [ ! -d ${MOUNT_POINT}/kubuntu8 ] ; then
35    mkdir -p ${MOUNT_POINT}/kubuntu8
36    created="yes"
37 fi
38 mount ${USB_DEV}1 ${MOUNT_POINT}/kubuntu8
39 if [ $? -ne 0 ] ; then
40   echo "Mount of USB boot partition failed."
41   exit 1
42 fi
43 cd ${MOUNT_POINT}/kubuntu8
44 if [ $? -ne 0 ] ; then
45   echo "Could not cd to USB boot partition"
46   exit 1
47 fi
48
49 echo "Detaring boot image ..."
50 tar xfz ${BOOT_IMAGE}
51 # original-partioning.txt was created by partition_usb_key
52 if [ -e ${CWD}/original-partitioning.txt ] ; then
53   cp -f ${CWD}/original-partitioning.txt .
54   rm -f ${CWD}/original-partitioning.txt
55 fi
56 cd ${CWD}
57
58 syslinux -sf ${USB_DEV}1
59 install-mbr -p1 ${USB_DEV}
60 echo "syncing ..."
61 sync
62 sync
63 umount ${MOUNT_POINT}/kubuntu8
64 if [ "x$created" = "xyes" ] ; then
65    rmdir ${MOUNT_POINT}/kubuntu8
66 fi