9 MB=MB part=`echo $disk|cut -d"/" -f3`
10 fdisk -l /dev/$part |grep bytes|grep -v Units|awk '{print $5}'>samesize
11 cat working/diskinfo/fdisk.$part |grep bytes|grep -v Units|awk '{print $5}'>samesize2
12 diff samesize samesize2 >/dev/null 2>&1
14 nowdisk=`cat samesize`
15 oldisk=`cat samesize2`
16 $DIALOG --title "different disk" --msgbox "The size of the disk you are trying to restore \n and the one we have backed up differ for /dev/$part \n \n The old disk size was $oldisk \n And the actual disk size is $nowdisk \n \n We'll have to do things manually" 600 600
17 oldiskparted=`cat working/diskinfo/parted.$part`
18 howmanyparts=`cat working/diskinfo/parted.$part|wc -l`
19 howmanyparts=$(( $howmanyparts - 7 ))
20 $DIALOG --title "different disk" --yesno "Do you want to do it manually \n ( we will launch gparted) (yes) \n Or only adjust the LAST partition size to fit the disk ? \n (We only shrink the las partition, it will not claim empty space on the drive) (no)" 600 600
22 if [ $DIALOG = Xdialog ];then
24 $DIALOG --title "different disk" --msgbox "the old partition sizes for this disk was \n \n $oldiskparted \n \n We will now launch gparted so you can adjust you disk partitions " 600 600
27 $DIALOG --title "different disk" --msgbox "the old partition sizes for this disk was \n \n $oldiskparted \n \n please use fdisk or cfdisk to repartition your drive \n \n and the re-run this script pointing to the partitions of the new disks \n (like /dev/sda1 ) instead of the whole disk (/dev/sda)" 600 600
32 a=` sfdisk -n /dev/$part < working/diskinfo/sfdisk.make.$part.bsi 2>&1`
34 grep exceed tmp >/dev/null 2>&1
36 tr ' ' '\n' < tmp >tmp2
37 cat tmp2|awk /given/,/sfdisk/ >tmp3
38 currentsize=`cat tmp3|grep -m1 "("|cut -d"(" -f2 |cut -d")" -f1`
39 maxsize=`cat tmp3|grep -m2 "("|cut -d"(" -f2 |cut -d")" -f1|tail -n1`
40 sed -i "s/$currentsize/$maxsize/g" working/diskinfo/sfdisk.make.$part.bsi
42 while [ $nowarn = 1 ];do
43 a=` sfdisk -n /dev/$part < working/diskinfo/sfdisk.make.$part.bsi 2>&1`
45 grep exceed tmp >/dev/null 2>&1
47 tr ' ' '\n' < tmp >tmp2
48 cat tmp2|awk /given/,/sfdisk/ >tmp3
49 currentsize=`cat tmp3|grep -m1 "("|cut -d"(" -f2 |cut -d")" -f1`
50 maxsize=`cat tmp3|grep -m2 "("|cut -d"(" -f2 |cut -d")" -f1|tail -n1`
51 sed -i "s/$currentsize/$maxsize/g" working/diskinfo/sfdisk.make.$part.bsi
56 partprobe /dev/$part >/dev/null 2>&1
58 sfdisk /dev/$part < working/diskinfo/sfdisk.make.$part.bsi
65 echo ". ./unmount-all">>partitionscript
66 #cat working/scripts/partition.$part>>fullrestorescript
67 #echo "partprobe >/dev/null 2>&1">>fullrestorescript
68 #echo "umount /dev/"$part"* >/dev/null 2>&1">>fullrestorescript
69 echo "dd if=working/diskinfo/mbr."$part" of=/dev/"$part>>partitionscript
70 echo "partprobe /dev/"$part" >/dev/null 2>&1">>partitionscript
71 echo ". ./unmount-all">>partitionscript
74 if [ -f formatscript ]; then
77 cat >formatscript <<END_OF_DATA
80 # Format all partitions on disk $disk -- created by getdiskinfo
83 echo "This script will format all partitions on disk $disk."
85 echo "IT WILL DESTROY ALL DATA ON DISK $disk !!!!"
87 if [ ! -f noprompt ];then
88 echo -n "Are you sure you want to continue? yes/no: "
90 if [ x\$a != xyes ] ; then
94 if [ ! -f badblocksnoprompt ];then
95 echo "Do you want to do a disk check for bad blocks?"
96 echo -n "It is recommended, but takes time. yes/no: "
98 if [ x\$a = xyes ] ; then
106 formatscripto=`ls working/scripts |grep $disk|grep format`
107 cat working/scripts/$formatscripto |grep $disk|while read line;do
108 echo $line >>formatscript
111 cat formatscript>>formatallscript