#!/bin/sh # # ======== prep-hdd ======== # # This shell script performs initial partitioning, formating, and populating # of the hard disk drive (HDD) for the DaVinci EVM. # # Usage: prep-hdd [URL prefix or path of install files] # # # URL prefix is where the files needed for the install are located # (ftp or http). If there is not a http:// or ftp:// prefix, then the # prefix is assumed to be a directory path and a local cp will be used. # if test $# != 1 then echo "Usage: $0 " echo "Example: $0 ftp://128.247.27.36/sanb-davinci/1_00_00_25/restore" echo "Example: $0 /opt/newstuff" exit 2 fi urlprefix=$1 if test $urlprefix = "." then urlprefix=`pwd` fi # device name for the HDD disk=/dev/hda # temporary mount point for the restore HDD partition restore=/mnt/restore # number of cylinders on the HDD cylinders=$(fdisk -l /dev/hda 2> /dev/null | grep heads, | cut -d " " -f 5) # number of cylinders for primary partition (arbitrarily set at 70%) let pri=$cylinders*70/100 echo "Using $pri cylinders for primary partition" # # This function copies depending on the presence of a URL prefix on the # source file. If a URL prefix is found (http:// or ftp://), then wget is # used to copy the file. If not, cp is used to do a filesystem copy. # copy() { f=${1#*://} if test $f = $1 then cp $1 . else wget $1 fi } # # Make sure user really wants to do this ... # echo -n "Are you sure you want to partition and format $disk? (yes/NO): " read answer if test "$answer" != "yes" then echo "$0: exiting because answer was not yes" exit 2 fi # # Make sure disks are not mounted # (umount on MVL 4.0 does not work with devices, so need to find mount point) # for i in 1 2 do dir=$(mount | grep ${disk}$i | cut -d " " -f 3) if test "$dir" != "" then echo "$dir" umount $dir > /dev/null 2>&1 fi done # # Partition the disk using fdisk. The following script deletes any # existing partitions and then makes 2 partitions of size $pri and # ($cylinders - $pri) (ie, the remaining amount) cylinders respectively. # echo "Partitioning $disk ... " fdisk $disk < /dev/null 2>&1 fi done # # Format the new restore (second) partition using ext3 format. The # main (primary) partition will be done as part of installing the SW below. # echo "Formating ${disk}2 ... " if ! mkfs.ext3 ${disk}2 then echo "$0: failed to format ${disk}2" exit 2 fi # # Make a mount point and then mount the new partition # echo "Mounting the new partition ... " rm -f $restore && mkdir $restore mount -t ext3 ${disk}2 $restore # # Copy the target filesystem and overlay tar-files into the restore area # cd $restore echo "Copying tar.gz files ... " for i in data_dm6467.tar.gz arago-demo-image-dm6467t-evm.tar.gz overlay_dm6467.tar.gz restore-hdd do echo $i copy $urlprefix/$i chmod -w $i done chmod +x restore-hdd # # Run the restore script to setup the primary area # echo "Un-tar'ing target filesystem, modules, and demos ... " ./restore-hdd y