]> git.sur5r.net Git - bacula/rescue/blob - rescue/linux/usb/partitionusbkey
Update USB rescue code
[bacula/rescue] / rescue / linux / usb / partitionusbkey
1 #!/bin/sh
2 #
3 # Partition the USB stick -- the stick is assumed to be at least 3GB in size
4 #
5 # First delete all existing partitions
6 #
7
8 if [ ! `whoami` = "root" ] ; then
9   echo ""
10   echo "You need to be root to run this shell script"
11   echo ""
12   exit 1
13 fi
14 if [ "x$USB_DEVICE" = "x" ] ; then
15   if [ "x$1" = "x" ] ; then
16      echo "You must supply the USB device name on the command line or in USB_DEVICE"
17      exit 1
18   else
19      dev=$1
20   fi
21 else
22   dev=$USB_DEVICE
23 fi
24 echo "This script will distroy everything on $dev"
25 fdisk -l $dev
26 echo " "
27 echo "Answer yes to continue "
28 read a
29 if [ "$a" != "yes" ] ; then
30   echo "Device $dev unchanged"
31   exit 1
32 fi
33
34 fdisk $dev <<EOF
35 d
36 4
37 d
38 3
39 d
40 2
41 d
42 1
43 n
44 p
45 1
46
47 +900M
48 t
49 1
50 6
51 a
52 1
53 n
54 p
55 2
56
57 +1000M
58 n
59 p
60 3
61
62
63 p
64 w
65 EOF
66 umount ${dev}1
67 mkfs.vfat -F 16 -n kubuntu8 ${dev}1
68 umount ${dev}2
69 mkfs.ext2 -j -b 4096 -L casper-rw ${dev}2
70 umount ${dev}3
71 mkfs.ext2 -j -b 4096 -L home-rw ${dev}3
72 syslinux -sf ${dev}1
73 install-mbr -p1 ${dev}
74 sync