I noticed that ROOTBACKUP stopped working when I converted the /altroot fstab
entry to a disklabel UID. The attached patch seems to work for me but I'm sure
there's a better way.
Index: src/etc/daily
===================================================================
RCS file: /a8v/pub/cvsroot/OpenBSD/src/etc/daily,v
retrieving revision 1.71
diff -u -p -u -p -r1.71 daily
--- src/etc/daily 23 Apr 2011 19:35:53 -0000 1.71
+++ src/etc/daily 8 May 2011 14:39:23 -0000
@@ -94,16 +94,33 @@ fi
# use it as a backup root filesystem to be updated daily.
next_part "Backing up root filesystem:"
while [ "X$ROOTBACKUP" = X1 ]; do
- rootbak=`awk '$2 == "/altroot" && $1 ~ /^\/dev\// && $3 == "ffs" && \
- $4 ~ /xx/ \
- { print substr($1, 6) }' < /etc/fstab`
- if [ -z "$rootbak" ]; then
- echo "No xx ffs /altroot device found in the fstab(5)."
- break
+ altroot=`awk '$2 == "/altroot" && $3 == "ffs" && $4 ~ /xx/ \
+ { print }' < /etc/fstab`
+ HAS_DUID=$(echo $altroot | grep -v '^/dev/')
+ if [ "X$HAS_DUID" = "X" ]; then
+ rootbak=`echo $altroot | awk '$2 == "/altroot" && \
+ $1 ~ /^\/dev\// && $3 == "ffs" && \
+ $4 ~ /xx/ \
+ { print substr($1, 6) }'`
+ if [ -z "$rootbak" ]; then
+ echo "No xx ffs /altroot device found in the fstab(5)."
+ break
+ fi
+ bakdisk=${rootbak%[a-p]}
+ sysctl -n hw.disknames | grep -Fqw $bakdisk || break
+ bakpart=${rootbak#$bakdisk}
+ else
+ duidbak=$(echo ${altroot} | cut -d\. -f1)
+ bakpart=$(echo ${altroot} | awk '{print $1}' | cut -d\. -f2)
+ bakdisk=$(sysctl -n hw.disknames | tr "," "\n" \
+ | grep -Fw $duidbak | cut -d: -f1)
+ if [ -z "$bakdisk" ]; then
+ echo "No xx ffs /altroot duid found in the fstab(5)."
+ break
+ fi
+ rootbak="$bakdisk$bakpart"
+ sysctl -n hw.disknames | grep -Fqw $bakdisk || break
fi
- bakdisk=${rootbak%[a-p]}
- sysctl -n hw.disknames | grep -Fqw $bakdisk || break
- bakpart=${rootbak#$bakdisk}
baksize=`disklabel $bakdisk 2>/dev/null | \
awk -v "part=$bakpart:" '$1 == part { print $2 }'`
rootdev=`mount | awk '$3 == "/" && $1 ~ /^\/dev\// && $5 == "ffs" \