#73 Issue closed: Problem in lib/compatibility-functions.sh because blkid shows no output when there are no partitions

Labels: cleanup

kpieth opened issue at 2012-04-24 20:11:

Theres a problem in lib/compatibility-functions.sh. blkid shows no output when there are no partitions. Therefore on Proliant servers with newly created RAID arrays i get this message when starting "rear -Dv recover":

Required udev program 'vol_id' or a suitable 'blkid' could not be found !
Activating a very primitive builtin replacement that supports
Ext2/3: LABEL and UUID
Reiserfs, xfs, swap...

WARNING ! This replacement has been tested on i386/x86_64 ONLY !!

looking at lib/compatibility-functions.sh line 47 this function expects that blkid has output:
elif has_binary blkid && blkid -o udev >&8 2>&1; then
Debug "Using 'blkid' for rear_vol_id"

System is SLES11SP2. When i create a disk label and partition then there is no error.

dagwieers commented at 2012-06-08 21:48:

Looking at the man-page of blkid, it seems as if return code 2 (which you get in this case) is not in fact an error in our case.

Can you check if on SLES11SP2 return code 2 is in fact what we'd expect if no disks have partitions ?

However, while fixing this case, I noticed that now that we have removed the old dr code, this function is no longer used. So you should not have had this problem in the first place on any recent Rear release, unless you disabled USE_LAYOUT (which we no longer recommend).

In case you want to backport my fix, you need to use the following patch:

--- a/usr/share/rear/lib/compatibility-functions.sh
+++ b/usr/share/rear/lib/compatibility-functions.sh
@@ -44,7 +44,8 @@ elif has_binary udev_volume_id; then
             -e "s/^U:\(.*\)/ID_FS_UUID='\1'/" | grep =
     }
 # NOTE: We use blkid ONLY if it is a newer one and reports information back in udev-style
-elif has_binary blkid && blkid -o udev >&8 2>&1; then
+#       But we need to accept both return code 0, and return code 2 (no partition)
+elif has_binary blkid && blkid -o udev >&8 2>&1 || (( $? == 2 )); then
     Debug "Using 'blkid' for rear_vol_id"
     # since udev 142 vol_id was removed and udev depends on blkid
     # blkid -o udev returns the same output as vol_id used to

In any case, I am going to close this issue, but feel free to reopen it if you have more feedback or anything else to report (the good, the bad or the ugly ;-)). Thanks for the report !


[Export of Github issue for rear/rear.]