#! /bin/sh # # Replicate boot files in separate file system e.g. a flash memory drive. # # Use: Assume a system where 2 disks form a gmirror RAID that lacks BIOS # boot support, and a device daN is a flash memory device that is to # hold the /boot files (and get us the BIOS booting). # # Run this script as command "sh.make_boot_FlashMemoryFS" to copy # the boot files over. Before the copy, the root file system device # is set as vfs.root.mountfrom="ufs:/dev/mirror/XXXXs1a" in the file # loader.conf in the /boot directory in both the current root file # system and the removable disk's s1a. # # # Note: You also need to specify which disk and slice to boot from via a # command such as # boot0cfg -s 1 -v -B -o noupdate da0 # specify slice 1 of boot disk # # extract the last removable device listed in dmesg x=`dmesg|egrep "^da" | grep "Direct Access" | grep -v "Fixed Direct Access" | tail -1 | cut -d':' -f1` if [ -n "$x" ] ; then echo "OK to use this device?" dmesg|grep "Direct Access" | egrep "^$x" echo echo "Press Enter for this device or enter spec such as da0" read TheDevice if [ x"$TheDevice" = x ] ; then TheDevice=$x fi else echo "Enter target device spec such as da0" read TheDevice echo fi WORKDIR=`pwd` TheFS=${TheDevice}s1a if [ -e /dev/$TheFS ] ; then echo "Target file system will be $TheFS" else echo '?'" didn't see ${TheFS} (e.g. da2s1a, or da0s1a etc.)" exit 1 fi # #1 ensure the file /boot/loader.conf contains vfs.root.mountfrom setting # cd /boot ( echo '# set vfs.root.mountfrom to switch to gmirror after load' ; echo 'vfs.root.mountfrom="ufs:'$(set `df /|egrep "^/dev"`;echo $1)'"' ; cp -p loader.conf loader.conf.orig ; cat loader.conf.orig | grep -v "vfs.root.mountfrom" ) > loader.conf__new__ mv loader.conf__new__ loader.conf pwd ; ls -al loader.conf* cd $WORKDIR # # 2 copy boot files into flash memory # mkdir -p /mnt2 fsck /dev/${TheFS} mount /dev/${TheFS} /mnt2 df /mnt2 mkdir -p /mnt2/dev ; mkdir -p /mnt2/boot (cd /boot ; tar -c --exclude kernel.old -f - *)|(cd /mnt2/boot; tar xvpf -) df /mnt2 umount /mnt2