#1657 Issue closed
: With btrfs 'rear checklayout' always detects a changed layout¶
Labels: enhancement
, fixed / solved / done
, minor bug
jsmeix opened issue at 2017-12-21 13:35:¶
With btrfs 'rear checklayout' always detects a changed layout
Reason:
A changed layout is detected in
layout/compare/default/500_compare_layout.sh
via
diff -u <(grep -v '^#' $ORIG_LAYOUT) <(grep -v '^#' $TEMP_LAYOUT) >/dev/null
In case of btrfs the ordering of the btrfsmountedsubvol
entries is random so that plain 'diff' detects changes
in var/lib/rear/layout/disklayout.conf
versus /tmp/rear.XXX/tmp/checklayout.conf
The fix is to additionally sort the entries in the layout files:
diff -u <( grep -v '^#' $ORIG_LAYOUT | sort ) <( grep -v '^#' $TEMP_LAYOUT | sort ) >/dev/null
jsmeix commented at 2017-12-21 13:42:¶
I see no reason why 'diff -u' is used
when its output is nowhere consumed.
To plain compare files 'cmp -s' is the right tool,
cf. the various 550_rebuild_initramfs.sh scripts
and 260_recovery_storage_drivers.sh
jsmeix commented at 2017-12-21 14:22:¶
This usr/share/rear/layout/compare/default/500_compare_layout.sh
makes it work for me:
# Test if ORIG_LAYOUT and TEMP_LAYOUT are the same. # In case of btrfs the ordering of the btrfsmountedsubvol entries is random # so that plain 'cmp' would detect changes unless the entries were sorted: if cmp -s <( grep -v '^#' $ORIG_LAYOUT | sort ) <( grep -v '^#' $TEMP_LAYOUT | sort ) ; then LogPrint "Disk layout is identical" else # The 'cmp' exit status is 0 if inputs are the same, 1 if different, 2 if trouble. # In case of 'trouble' do the same as when the layout has changed to be on the safe side: LogPrint "Disk layout has changed" # In the log file show the changes in the right ordering in the layout files: diff -U0 <( grep -v '^#' $ORIG_LAYOUT ) <( grep -v '^#' $TEMP_LAYOUT ) >&2 EXIT_CODE=1 fi
[Export of Github issue for rear/rear.]