#1931 Issue closed: /usr/share/rear/layout/save/GNU/Linux/200_partition_layout.sh: line 271: test: 62180556800: unary operator expected

Labels: fixed / solved / done, minor bug

mailinglists35 opened issue at 2018-10-15 19:11:

Relax-and-Recover (ReaR) Issue Template

Fill in the following items before submitting a new issue
(quick response is not guaranteed with free support):

  • ReaR version ("/usr/sbin/rear -V"):
    ALL TEMPLATE DATA identical to issue #1930

  • OS version ("cat /etc/rear/os.conf" or "lsb_release -a" or "cat /etc/os-release"):

  • ReaR configuration files ("cat /etc/rear/site.conf" and/or "cat /etc/rear/local.conf"):

  • Hardware (PC or PowerNV BareMetal or ARM) or virtual machine (KVM guest or PoverVM LPAR):

  • System architecture (x86 compatible or PPC64/PPC64LE or what exact ARM device):

  • Firmware (BIOS or UEFI or Open Firmware) and bootloader (GRUB or ELILO or Petitboot):

  • Storage (lokal disk or SSD) and/or SAN (FC or iSCSI or FCoE) and/or multipath (DM or NVMe):

  • Description of the issue (ideally so that others can reproduce it):
    I don't think this looks right: (see pasted log in issue #1930)

2018-10-15 22:06:57.537834589 Saving disk partitions.
/usr/share/rear/layout/save/GNU/Linux/200_partition_layout.sh: line 271: test: 62180556800: unary operator expected
/usr/share/rear/layout/save/GNU/Linux/200_partition_layout.sh: line 271: test: 1074790400: unary operator expected
2018-10-15 22:06:58.152171295 Replacing probably wrong extended partition size 1024 by what parted reports 536870871040
/usr/share/rear/layout/save/GNU/Linux/200_partition_layout.sh: line 271: test: 62180556800: unary operator expected
/usr/share/rear/layout/save/GNU/Linux/200_partition_layout.sh: line 271: test: 1074790400: unary operator expected
2018-10-15 22:06:59.061339815 Replacing probably wrong extended partition size 1024 by what parted reports 536870871040
/usr/share/rear/layout/save/GNU/Linux/200_partition_layout.sh: line 271: test: 62180556800: unary operator expected
/usr/share/rear/layout/save/GNU/Linux/200_partition_layout.sh: line 271: test: 1074790400: unary operator expected
2018-10-15 22:06:59.861265639 Replacing probably wrong extended partition size 1024 by what parted reports 536870871040
/usr/share/rear/layout/save/GNU/Linux/200_partition_layout.sh: line 271: test: 62180556800: unary operator expected
/usr/share/rear/layout/save/GNU/Linux/200_partition_layout.sh: line 271: test: 1074790400: unary operator expected
2018-10-15 22:07:00.670174681 Replacing probably wrong extended partition size 1024 by what parted reports 536870871040
  • Work-around, if any:

jsmeix commented at 2018-10-16 08:06:

That is my code in usr/share/rear/layout/save/GNU/Linux/200_partition_layout.sh

    ### Find an extended partition if there is one
    if [[ "$disk_label" = "msdos" ]] && [[ "$has_logical" ]] ; then
...
        while read partition_nr size start type flags junk ; do
            (( $partition_nr > 4 )) && continue
...
            # Replace currently possibly wrong extended partition size value
            # by the value that parted reports if those values differ, cf.
            # https://github.com/rear/rear/pull/1733#issuecomment-368051895
            # In SLE10 there is GNU Parted 1.6.25.1 which supports 'unit B'
            # that is documented in 'info parted' (but not yet in 'man parted').
            # Example of a parted_extended_partition_line:
            #   # parted -s /dev/sdb unit B print | grep -w '3' | grep -w 'extended'
            #    3      1266679808B  1790967807B  524288000B  extended                  lba, type=0f
            # where the size is 524288000B i.e. parted_extended_partition_line[3]
            parted_extended_partition_line=( $( parted -s $device unit B print | grep -w "$partition_nr" | grep -w 'extended' ) )
            parted_extended_partition_size="${parted_extended_partition_line[3]%%B*}"
            if test $size -ne $parted_extended_partition_size ; then
                 Log "Replacing probably wrong extended partition size $size by what parted reports $parted_extended_partition_size"
                 sed -i /^$partition_nr\ /s/\ $size\ /\ $parted_extended_partition_size\ / $TMP_DIR/partitions
            fi
...

I had misinterpreted the initial if that here only extended partitions happen
but actually all first four partitions on a 'msdos' labeled disk that has
a logical partition are examined here so that also primary partitions
happen here and for them $parted_extended_partition_size becomes empty
so that the subsequent test fails with 'unary operator expected'
but nevertheless (stinking self-praise for my fail-safe programming ;-)
the result is still right even in this case because nothing gets changed
when it is no extended partition.

I will make that behaviour more explicit in the code.

jsmeix commented at 2018-10-16 08:18:

Fixed via
https://github.com/rear/rear/commit/6b2b95955d41e3381440460d30782a6c6c8e3497

jsmeix commented at 2018-10-16 08:24:

@mailinglists35
check whether or not the partition size values are correct in your
disklayout.conf file (usually in var/lib/rear/layout/disklayout.conf),
for the disklayout.conf file syntax see the "Disk layout file syntax" in
https://raw.githubusercontent.com/rear/rear/master/doc/user-guide/06-layout-configuration.adoc


[Export of Github issue for rear/rear.]