#!/bin/sh # show name/size of all drives... showdrives() { for hd in hda hdb hdc hdd ; do test -r /proc/ide/$hd/model -a -r /proc/ide/$hd/capacity && { model=`cat /proc/ide/$hd/model` cap=`cat /proc/ide/$hd/capacity` capkb=`expr $cap / 2048` echo "Drive: $hd Model: $model Size: ${capkb}KBytes, $cap sectors" echo "Drive: $hd Model: $model Size: ${capkb}KBytes, $cap sectors" >> $logf echo " " nhd=`expr $nhd + 1` } done } logf=/tmp/msupg.log hdspec=hdc model=`cat /proc/ide/$hdspec/model` cap=`cat /proc/ide/$hdspec/capacity` capkb=`expr $cap / 2048` fwloc=`expr $cap - 32768` snloc=`expr $fwloc + 12288` snloc1=`expr $fwloc + 12289` pwloc=`expr $fwloc + 12290` fssize=`expr $fwloc / 2` #save to log echo "drive: $hdspec" >> $logf echo "sectors: $cap" >> $logf echo "kbytes: $capkb" >> $logf echo "fwloc: $fwloc" >> $logf echo "snloc: $snloc" >> $logf echo "snloc1: $snloc1" >> $logf echo "pwloc: $pwloc" >> $logf echo "fssize: $fssize" >> $logf echo 'Some version strings in this image:' gunzip < FW-IMG.GZ | strings | grep VERSION | dd bs=80 count=1 2>/dev/null eightmax=`expr 16383 '*' 63 '*' 16` test "1$cap" -gt "1$eightmax" && { echo 'Your new drive is larger than 8GB. If you have an older' echo 'DW unit, it may be able to use only 8GB maximum. Do you' echo -n 'want to limit the size to 8GB only? (yes/no) ' read ans test "1$ans" = "1yes" && { # max 8GB capacity for older DW echo -n "cap old: $cap" cap=`expr 16383 '*' 63 '*' 16` echo " new: $cap" echo -n "fw old: $fwloc" fwloc=`expr $cap - 32768` echo " new: $fwloc" echo -n "sn old: $snloc" snloc=`expr $fwloc + 12288` echo " new: $snloc" snloc1=`expr $snloc + 12289` pwloc=`expr $fwloc + 12290` echo -n "fssize old: $fssize" fssize=`expr $fwloc / 2` echo " new: $fssize" } } echo ' ' echo 'Restoring image to new drive...' gunzip < FW-IMG.GZ | dd of=/dev/$hdspec bs=512 seek=$fwloc echo "You should see 32768 records in/out." echo " " dd if=/dev/$hdspec bs=512 count=1 skip=12288 of=SN.BIN 2>&1 >/dev/null echo 'Apparent serial number in this image:' dd if=SN.BIN bs=1 count=1 skip=2 2>/dev/null dd if=SN.BIN bs=1 count=1 skip=4 2>/dev/null dd if=SN.BIN bs=1 count=1 skip=6 2>/dev/null dd if=SN.BIN bs=1 count=1 skip=8 2>/dev/null dd if=SN.BIN bs=1 count=1 skip=10 2>/dev/null dd if=SN.BIN bs=1 count=1 skip=12 2>/dev/null dd if=SN.BIN bs=1 count=1 skip=14 2>/dev/null dd if=SN.BIN bs=1 count=1 skip=16 2>/dev/null dd if=SN.BIN bs=1 count=1 skip=18 2>/dev/null dd if=SN.BIN bs=1 count=1 skip=20 2>/dev/null echo ' ' test -r /usr/sbin/mkdosfs && { echo "The fat32 filesystm may be installed now, or you" echo "can do it from your system via USB/Firewire interface." echo -n "Do you want to create the fat32 filesystem now (yes/no)?" ans="foo" read ans test "1$ans" = "1yes" && { echo "Creating the fat32 filesystem..." echo "mkdosfs -I -F 32 -v /dev/$hdspec $fssize ..." /usr/sbin/mkdosfs -I -F 32 -v /dev/$hdspec $fssize } test $fssize -gt 33554432 && { echo "NOTE: this fat32 filesystem is larger than 32GB." echo "Windows 2000/XP will not be able to (re)format it." echo "see http://support.microsoft.com/default.aspx?scid=kb;EN-US;q184006" } } test -r /usr/sbin/mkdosfs || { dd if=/dev/zero of=/dev/$hdspec bs=512 count=4 echo 'No filesystem was placed on your new disk. You must' echo 'reformat using USB/Firewire interface to use it.' } echo ' ' echo 'ALL DONE! Shutdown and power off before disconnecting the' echo 'drive to install back in your mindstor unit.' echo ' ' exit 0