On Thu, Feb 09, 2012 at 10:25:45AM -0500, Dave Anderson wrote:
> On Wed, 8 Feb 2012, Dave Anderson wrote:
> 
> >On Tue, 7 Feb 2012, Kenneth R Westerback wrote:
> >
> >>On Tue, Feb 07, 2012 at 09:42:07AM -0500, Dave Anderson wrote:
> >>> I've got a system running amd64/mp -current (latest source update on
> >>> February 1st) and have noticed (for quite a while, actually) that the
> >>> nightly backup of / to /altroot wasn't working.  I finally got around to
> >>> looking into this and discovered that the /etc/daily script was
> >>> explicitly checking for /dev/whatever in the /altroot fstab entry -- but
> >>> I've been using DUIDs (as set up by the installer).
> >>>
> >>> Shouldn't the daily script be updated to handle DUIDs as well as
> >>> explicit devices in /etc/fstab?
> >>>
> >>>   Dave
> >>
> >>Does this diff work for you? Test with duid and without would be
> >>nice. :-)
> >>
> >>And don't be bashful. Anybody can test!
> >>
> >>.... Ken
> >
> >That works for me, both ways.
> >
> >Thanks,
> >
> >     Dave
> 
> Aaargh!  Not quite, it turns out.  This superficially appears to work,
> and does seem to work in the non-DUID case, but I evidently didn't look
> at the results carefully enough.  In the DUID case, rather than copying
> / to the altroot partition it copies it to /dev/r<duid>.<partition>!
> 
> My bad.  Apologies to all.
> 
> I remember seeing a commit which sounds like it might tweak some
> low-level functions to translate DUIDs into devices; I'll upgrade to a
> current -current and see if this problem goes away.
> 
>       Dave

Third (fourth?) time lucky.

This one I actually tested with/without duids. And threw in for free
the ability to ignore commented out lines in the search for altroot. Which
made testing much easier. Not to mention less confusing.

.... Ken

Index: daily
===================================================================
RCS file: /cvs/src/etc/daily,v
retrieving revision 1.73
diff -u -p -r1.73 daily
--- daily       8 Feb 2012 18:22:43 -0000       1.73
+++ daily       10 Feb 2012 20:08:04 -0000
@@ -94,8 +94,8 @@ 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" && $3 == "ffs" && $4 ~ /xx/ \
-               { print $1 }' < /etc/fstab`
+       rootbak=`awk '$1 !~ /^#/ && $2 == "/altroot" && $3 == "ffs" && \
+               $4 ~ /xx/ { print $1 }' < /etc/fstab`
        if [ -z "$rootbak" ]; then
                echo "No xx ffs /altroot device found in the fstab(5)."
                break
@@ -104,6 +104,16 @@ while [ "X$ROOTBACKUP" = X1 ]; do
        bakdisk=${rootbak%%?(.)[a-p]}
        sysctl -n hw.disknames | grep -Fqw $bakdisk || break
        bakpart=${rootbak##$bakdisk?(.)}
+       OLDIFS=$IFS
+       IFS=,
+       for d in `sysctl -n hw.disknames`; do
+               # If the provided disk name is a duid, substitute the device.
+               if [ X$bakdisk = X${d#*:} ]; then 
+                       bakdisk=${d%:*}
+                       rootbak=$bakdisk$bakpart
+               fi
+       done
+       IFS=$OLDIFS
        baksize=`disklabel $bakdisk 2>/dev/null | \
                awk -v "part=$bakpart:" '$1 == part { print $2 }'`
        rootdev=`mount | awk '$3 == "/" && $1 ~ /^\/dev\// && $5 == "ffs" \

Reply via email to