3 # Partition the USB stick -- the stick is assumed to be at least 3GB in size
5 # First delete all existing partitions
10 # Check for tools needed
11 for i in fdisk gunzip blkid install-mbr sfdisk partprobe syslinux ; do
12 if [ ! -e `which $i` ] ; then
14 echo "$i does not seem to be installed; cannot continue."
20 if [ ! `whoami` = "root" ] ; then
22 echo "You need to be root to run this shell script"
26 if [ "x$USB_DEV" = "x" ] ; then
27 if [ "x$1" = "x" ] ; then
28 echo "You must supply the USB device name on the command line or in USB_DEV"
34 echo "This script will distroy everything on $USB_DEV"
37 echo "Answer yes to continue "
39 if [ "$a" != "yes" ] ; then
40 echo "Device $USB_DEV unchanged"
43 sfdisk -l $USB_DEV >original-partitioning.txt
44 install-mbr ${USB_DEV}
77 partprobe >/dev/null 2>&1
78 partprobe ${USB_DEV}1 >/dev/null 2>&1
79 umount ${USB_DEV}1 >/dev/null 2>&1
80 mkfs.vfat -F 32 -n xubuntu9 ${USB_DEV}1
81 partprobe >/dev/null 2>&1
82 umount ${USB_DEV}2 >/dev/null 2>&1
83 mkfs.ext3 -j -b 4096 -L casper-rw ${USB_DEV}2
84 # Do fs checking every 100 mounts or 360 days
85 tune2fs -c 100 -i 360 ${USB_DEV}2
86 partprobe >/dev/null 2>&1
88 mkfs.ext3 -j -b 4096 -L bs-rescue ${USB_DEV}3
89 tune2fs -c 100 -i 360 ${USB_DEV}3
92 echo "New partitioning is:"
96 partprobe >/dev/null 2>&1
98 echo "We're done, now it's a good time to unplug and replug your usb key"
99 echo "Then make sure that /media/bs-rescue is mounted before"
100 echo "running the copy_bacula_to_usb_key script"