>Number: 145961
>Category: misc
>Synopsis: [nanobsd] improved flash update script
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Fri Apr 23 00:30:03 UTC 2010
>Closed-Date:
>Last-Modified:
>Originator: Aragon Gouveia
>Release: FreeBSD 8.0-STABLE amd64
>Organization:
>Environment:
System: FreeBSD igor.geek.sh 8.0-STABLE FreeBSD 8.0-STABLE #0: Mon Mar 8
01:27:41 SAST 2010 [email protected]:/usr/obj/usr/src/sys/IGOR amd64
>Description:
NanoBSD has some utility shell scripts called updatep1 and updatep2
which help upgrade system flash with a new image file and make it bootable.
These scripts still use fdisk and boot0cfg which seems to be error prone on
FreeBSD 8.0, causing vfs errors after an update.
I've attached a single update script which auto detects which partition
is active and upgrades the inactive partition. It also uses gpart for making
the new partition bootable.
>How-To-Repeat:
>Fix:
--- update begins here ---
#!/bin/sh
# usage:
# ssh somewhere cat image.s1 | sh update
#
set -e
. /etc/nanobsd.conf
ACTIVE=0
if mount |grep -q ^/dev/${NANO_DRIVE}s1; then
ACTIVE=1
fi
if mount |grep -q ^/dev/${NANO_DRIVE}s2; then
ACTIVE=$(( ${ACTIVE} + 2 ))
fi
case ${ACTIVE} in
1)
UPDATE=2
;;
2)
UPDATE=1
;;
*)
echo "Unknown system state. Aborting upgrade..." 1>&2
exit 1
;;
esac
echo "Partition ${ACTIVE} active, updating partition ${UPDATE}..."
# Blow away old system.
dd if=/dev/zero of=/dev/${NANO_DRIVE}s${UPDATE} bs=1m count=1 > /dev/null 2>&1
# Copy in new system
dd of=/dev/${NANO_DRIVE}s${UPDATE} obs=128k
# Check that it worked
fsck_ffs -n /dev/${NANO_DRIVE}s${UPDATE}a
echo
echo "Image data written successfully. Activating..."
if [ ${UPDATE} -eq 2 ]; then
# Update the /etc/fstab
trap "umount /mnt" 1 2 3 15 EXIT
mount /dev/${NANO_DRIVE}s2a /mnt
sed -i "" "s/${NANO_DRIVE}s1/${NANO_DRIVE}s2/" /mnt/conf/base/etc/fstab
sed -i "" "s/${NANO_DRIVE}s1/${NANO_DRIVE}s2/" /mnt/etc/fstab
umount /mnt
trap - 1 2 3 15 EXIT
fi
gpart set -a active -i ${UPDATE} ${NANO_DRIVE}
--- update ends here ---
>Release-Note:
>Audit-Trail:
>Unformatted:
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "[email protected]"