#2288 Issue closed: swap partition type changed after rear restore

Labels: minor bug, no-issue-activity

musyl opened issue at 2019-11-27 15:02:

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"):
    Relax-and-Recover 2.5

  • OS version ("cat /etc/rear/os.conf" or "lsb_release -a" or "cat /etc/os-release"):
    SUSE Linux Enterprise Server 12 SP4

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

 BACKUP=NETFS
BACKUP_URL=nfs://naspnmksysb/mksysb/linux_lpars
ISO_MKISOFS_BIN="$( type -p mkisofs || type -p genisoimage )"
BACKUP_PROG_EXCLUDE=( "${BACKUP_PROG_EXCLUDE[@]}" '/tmp/*' '/var/lib/rear/output/*' '/media/*' '/hana/*' '/opt/coop/*' '/var/coop/*' '/home/*' '/var/mksysb/*' '/var/old_mksysb/*' '/dev/*' '/proc/*' '/run/*' '/syslink/*' '/var/instsoftw/*' '/usr/sap/*' '/opt/uniq/*' '/var/cisp/*' '/opt/ibm/cisp/*' '/opt/ixos/*' '/var/sapdaten*/*' '/var/DTA/*' '/var/svr*/*' '/var/universv/*' '/sapmnt/*' '/hana/data/STA/mnt00001/*' '/hana/shared/STA/*' '/hana/log/STA/mnt00001/*' )
BACKUP_PROG_INCLUDE=( '/*' '/var/lib/mysql/*' '/var/opt/*' '/home/' '/var/tmp/*' '/var/lib/pgsql/*' '/var/lib/machines/*' '/var/lib/libvirt/images/*' '/var/lib/mariadb/*' '/var/lib/named/*' '/var/patrol/*' '/usr/local/*' '/opt/*' '/etc/salt/*' '/tmp/*' '/root/*' '/var/log/*' '/boot/grub2/powerpc-ieee1275/*' '/var/lib/mailman/*' '/var/spool/*' '/srv/*' '/opt/ctm/*' '/opt/patrol/*' '/opt/teamquest/*')
BACKUP_ONLY_INCLUDE="yes"
COPY_AS_IS=( "${COPY_AS_IS[@]}" /etc/multipath/* )
COPY_AS_IS_EXCLUDE=( "${COPY_AS_IS_EXCLUDE[@]}" /dev/sd* /dev/mapper/mpath* /dev/mapper/*vg* /dev/mpath/\* /dev/dm-* /dev/sg* /dev/*_vg /dev/disk/\* /dev/block/\*  )
AUTOEXCLUDE_MULTIPATH=n
EXCLUDE_DEVICE_MAPPING=( "loop*" "ram*"  "dm-*" )
REAR_INITRD_COMPRESSION="lzma"
BOOT_OVER_SAN=y
ONLY_INCLUDE_VG=(sys_vg)

TIMESYNC=NTP
REQUIRED_PROGS=( "${REQUIRED_PROGS[@]}" snapper chattr lsattr )
COPY_AS_IS=( "${COPY_AS_IS[@]}" /usr/lib/snapper/installation-helper /etc/snapper/config-templates/default )
POST_RECOVERY_SCRIPT=( 'if snapper --no-dbus -r $TARGET_FS_ROOT get-config | grep -q "^QGROUP.*[0-9]/[0-9]" ; then snapper --no-dbus -r $TARGET_FS_ROOT set-config QGROUP= ; snapper --no-dbus -r $TARGET_FS_ROOT setup-quota && echo snapper setup-quota done || echo snapper setup-quota failed ; else echo snapper setup-quota not used ; fi' )
  • Hardware (PC or PowerNV BareMetal or ARM) or virtual machine (KVM guest or PoverVM LPAR):
    PowerVM LPAR

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

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

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

  • Description of the issue (ideally so that others can reproduce it):
    After a rear recover the swap partition was recreated with type 0x83 while at installation the type was 0x82.

  • Workaround, if any:
    I modified script 140_include_swap_code.sh , see below. I tested the modification in my test environment and it seems to work. Do you think it is reliable enough to be deployed in a production environment?

  • Attachments, as applicable ("rear -D mkrescue/mkbackup/recover" debug log files):

To paste verbatim text like command output or file content,
include it between a leading and a closing line of three backticks like

```
create_swap() {
    local swap device uuid label junk pdev nrpart
    read swap device uuid label junk < <(grep "^swap ${1#swap:} " "$LAYOUT_FILE")

    if [[ "$FEATURE_MKSWAP_UUID" && -n "${uuid#uuid=}" ]] ; then
        uuid="-U ${uuid#uuid=} "
    else
        uuid=""
    fi

    if [[ -n "${label#label=}" ]] ; then
        label="-L ${label#label=} "
    else
        label=""
    fi
    nrpart="${device: -1}"
    pdev=$(awk '$1==PART { print $NF}'  PART=$device $LAYOUT_DEPS)
    (
    echo "LogPrint \"Change swap partition type on $device\""
    echo "parted -s $pdev set $nrpart type 0x82"
    echo "LogPrint \"Creating swap on $device\""
    echo "mkswap ${uuid}${label}${device} >&2"
    ) >> "$LAYOUT_CODE"
}

```

jsmeix commented at 2019-11-29 15:07:

@musyl
thank you for the issue report and your fix!
I will have a look - as time permits - hopefully next week.

In general:
The ReaR scripts are meant to be adapted
and enhanced as needed by the user, cf.
"Disaster recovery with Relax-and-Recover (ReaR)" in
https://en.opensuse.org/SDB:Disaster_Recovery

Some remarks by plain looking at your code:

In your code

nrpart="${device: -1}"

looks unreliable because

# device=/dev/sdX12
# nrpart="${device: -1}"
# echo $nrpart
2

so better use the ReaR function get_partition_number()
https://github.com/rear/rear/blob/master/usr/share/rear/lib/layout-functions.sh#L362
that works as

# device=/dev/sdX12
# echo "$device" | grep -o -E '[0-9]+$'
12

In your code

parted -s $pdev set $nrpart type 0x82

looks "suspicious" because I at a glance cannot find in "man parted" or in
https://www.gnu.org/software/parted/manual/parted.html
that the parted command set supports type
but I may misunderstand the parted documentation.

Furthermore the German
https://de.wikipedia.org/wiki/GUID_Partition_Table
reads (excerpts)

Partitionstyp
GPT (GUID, hexadezimal) | MBR (hex) | ... | englische Bezeichnung
...
0657FD6D-A4AB-43C4-84E5-0933C84B4F4F | 0x82 | ... | Linux swap

which is in English

Partition type
GPT (GUID, hexadecimal) | MBR (hex) | ... | English name
...
0657FD6D-A4AB-43C4-84E5-0933C84B4F4F | 0x82 | ... | Linux swap

which indicates that the partition type 0x82 is only valid
in case of MBR partitioning but not in case of GPT.

musyl commented at 2019-12-02 08:15:

Thank you for your help and advice.

github-actions commented at 2020-06-29 01:37:

Stale issue message


[Export of Github issue for rear/rear.]