#1331 Issue closed: "rear recover" recreates initramfs/initd after bootloader was installed

Labels: bug, cleanup, fixed / solved / done

jsmeix opened issue at 2017-04-24 14:56:

Since the latest changes in rebuild_initramfs scripts
in particular since latest renumbering of those scripts
related to PPC things by @schabrolles
"rear recover" recreates initramfs/initd
after bootloader was installed:

RESCUE e205:~ # rear -d -D recover
Relax-and-Recover 2.00 / Git
...
Restoring finished.
Restoring file capabilities (NETFS_RESTORE_CAPABILITIES)
Restore the Mountpoints (with permissions) from /var/lib/rear/recovery/mountpoint_permissions
Installing GRUB2 boot loader
Updating udev configuration (70-persistent-net.rules)
Running mkinitrd...
Recreated initrd (/sbin/mkinitrd).
Finished recovering your system. You can explore it under '/mnt/local'.
RESCUE e205:~ # 

It works at least for me this way by luck because modern
bootloaders like Grub/Grub2 can read filesystems
but for old bootloaders like LILO this may fail.

In general I think "rear recover" should
first recreate initramfs/initd and
then install the bootloader
(as it did usually before).

schabrolles commented at 2017-04-24 16:35:

@jsmeix @gdha,

I'm not against installing bootloader after initrd...
Right now we have scripts that migrate/re-configure the target system up to script number 430_create_multipath_config.sh (#1311 commit 198b4a3).

I think we can reserver up to 499 for system reconfiguration
500_ initrd and move bootloader to 550 or 600

What do you think ?

[...]
Source finalize/GNU/Linux/150_migrate_disk_devices_layout.sh
Source finalize/GNU/Linux/150_migrate_lun_wwid.sh
Source finalize/GNU/Linux/150_migrate_uuid_tags.sh
Source finalize/GNU/Linux/160_rename_diskbyid.sh
Source finalize/Linux-ppc64le/220_install_grub2.sh
Source finalize/Linux-ppc64le/230_install_PPC_bootlist.sh
Source finalize/GNU/Linux/300_create_mac_mapping.sh
Source finalize/GNU/Linux/410_migrate_udev_rules.sh
Source finalize/GNU/Linux/420_migrate_network_configuration_files.sh
Source finalize/GNU/Linux/430_create_multipath_config.sh
Source finalize/Fedora/ppc64le/500_rebuild_initramfs.sh
Source finalize/default/880_check_for_mount_by_id.sh
Source finalize/default/890_finish_checks.sh
Source finalize/default/900_remount_sync.sh
Source wrapup/default/500_post_recovery_script.sh
Source wrapup/default/980_good_bye.sh
Source wrapup/default/990_copy_logfile.sh

jsmeix commented at 2017-04-25 09:33:

@schabrolles
I think we should move bootloader to 600.

Because you are already working on the 'finalize' scripts
just go ahead and renumber them.

I would appreciate it if you could also add a
usr/share/rear/finalize/readme
file that describes what numbers are used for what kind
of task during the 'finalize' stage - cf. the existing
usr/share/rear/backup/readme and
usr/share/rear/restore/readme files.

Only FYI
how the 'finalize' stage was before

Source finalize/default/010_prepare_checks.sh
Source finalize/default/100_populate_dev.sh
Source finalize/GNU/Linux/150_migrate_disk_devices_layout.sh
Source finalize/GNU/Linux/150_migrate_lun_wwid.sh
Source finalize/GNU/Linux/150_migrate_uuid_tags.sh
Source finalize/GNU/Linux/160_rename_diskbyid.sh
Source finalize/SUSE_LINUX/i386/170_rebuild_initramfs.sh
Source finalize/Linux-i386/210_install_grub.sh
Source finalize/Linux-i386/220_install_elilo.sh
Source finalize/Linux-i386/220_install_grub2.sh
Source finalize/Linux-i386/230_run_efibootmgr.sh
Source finalize/GNU/Linux/300_create_mac_mapping.sh
Source finalize/GNU/Linux/410_migrate_udev_rules.sh
Source finalize/GNU/Linux/420_migrate_network_configuration_files.sh
Source finalize/default/880_check_for_mount_by_id.sh
Source finalize/default/890_finish_checks.sh
Source finalize/default/900_remount_sync.sh

versus how the 'finalize' stage is currently

Source finalize/default/010_prepare_checks.sh
Source finalize/default/100_populate_dev.sh
Source finalize/GNU/Linux/150_migrate_disk_devices_layout.sh
Source finalize/GNU/Linux/150_migrate_lun_wwid.sh
Source finalize/GNU/Linux/150_migrate_uuid_tags.sh
Source finalize/GNU/Linux/160_rename_diskbyid.sh
Source finalize/Linux-i386/210_install_grub.sh
Source finalize/Linux-i386/220_install_elilo.sh
Source finalize/Linux-i386/220_install_grub2.sh
Source finalize/Linux-i386/230_run_efibootmgr.sh
Source finalize/GNU/Linux/300_create_mac_mapping.sh
Source finalize/GNU/Linux/410_migrate_udev_rules.sh
Source finalize/GNU/Linux/420_migrate_network_configuration_files.sh
Source finalize/SUSE_LINUX/i386/500_rebuild_initramfs.sh
Source finalize/default/880_check_for_mount_by_id.sh
Source finalize/default/890_finish_checks.sh
Source finalize/default/900_remount_sync.sh

schabrolles commented at 2017-04-25 14:09:

@jsmeix I will then update bootlader to 600 or more... I won't be able to do it today, but will do very soon.
I'm gonna also try to provide a first draft of readme.

schabrolles commented at 2017-04-26 06:39:

@jsmeix Is there a reason for having "Network-scripts Migration" run after bootloader installation ?

Source finalize/Linux-i386/210_install_grub.sh
Source finalize/Linux-i386/220_install_elilo.sh
Source finalize/Linux-i386/220_install_grub2.sh
Source finalize/Linux-i386/230_run_efibootmgr.sh
Source finalize/GNU/Linux/300_create_mac_mapping.sh
Source finalize/GNU/Linux/410_migrate_udev_rules.sh
Source finalize/GNU/Linux/420_migrate_network_configuration_files.sh

jsmeix commented at 2017-04-26 08:30:

I am afraid - I don't know the reason behind the old numbering
(as usual nothing is commented so that one cannot know).

Offhanded I cannot imagine a reason why something must be
run after bootloader installation because this would mean that
bootloader installation could go wrong if that stuff was run
before bootloader installation i.e. that stuff could somehow
damage needed things for bootloader installation and
currently I cannot imagine what that could be.

In contrast I think that any adaptions in the target system
might also be needed before the initramfs/initrd is created
in the target system (to get an up to date initramfs/initrd)
and the initramfs/initrd should be up to date before the
bootloader is installed in the target system so that
from my current point of view the ordering should be:

last but two: do any adaptions in the target system
last but one: create initramfs/initrd in the target system
last: install bootloader in the target system

jsmeix commented at 2017-05-04 08:12:

With https://github.com/rear/rear/pull/1323 merged
this issue should be fixed.

@schabrolles
many thanks for your continuous valuable contributions to ReaR
and for your careful testing on PPC architecture.
It helps a lot to make ReaR better!

jsmeix commented at 2017-05-04 09:02:

With https://github.com/rear/rear/pull/1323 merged
it still works well for me on SLES12 x86_64.

FYI:
Now I have

# usr/sbin/rear -s recover | grep finalize/
Source finalize/default/010_prepare_checks.sh
Source finalize/default/100_populate_dev.sh
Source finalize/GNU/Linux/250_migrate_disk_devices_layout.sh
Source finalize/GNU/Linux/250_migrate_lun_wwid.sh
Source finalize/GNU/Linux/260_rename_diskbyid.sh
Source finalize/GNU/Linux/280_migrate_uuid_tags.sh
Source finalize/GNU/Linux/300_create_mac_mapping.sh
Source finalize/GNU/Linux/310_migrate_udev_rules.sh
Source finalize/GNU/Linux/320_migrate_network_configuration_files.sh
Source finalize/GNU/Linux/430_create_multipath_config.sh
Source finalize/SUSE_LINUX/i386/550_rebuild_initramfs.sh
Source finalize/Linux-i386/610_install_grub.sh
Source finalize/Linux-i386/620_install_elilo.sh
Source finalize/Linux-i386/620_install_grub2.sh
Source finalize/Linux-i386/630_run_efibootmgr.sh
Source finalize/default/880_check_for_mount_by_id.sh
Source finalize/default/890_finish_checks.sh
Source finalize/default/900_remount_sync.sh

and

RESCUE e205:~ # rear -d -D recover
...
Restored 2647 MiB in 39 seconds [avg. 69509 KiB/sec]
Restoring finished.
Restoring file capabilities (NETFS_RESTORE_CAPABILITIES)
Restore the Mountpoints (with permissions) from /var/lib/rear/recovery/mountpoint_permissions
Updating udev configuration (70-persistent-net.rules)
Running mkinitrd...
Recreated initrd (/sbin/mkinitrd).
Installing GRUB2 boot loader
Finished recovering your system. You can explore it under '/mnt/local'.

[Export of Github issue for rear/rear.]