Is there a way to safely chroot into a Fedora system and perform package management?
I would like to chroot into my Fedora 27 system and perform some package management tasks namely installing the grub2-efi package with DNF so I can re-installed my GRUB2 bootloader for F27. The reason I need to do that is that I installed a second Fedora 27 system on the same hard disk and its bootloader overwrote my previous installation's. Unfortunately as my Fedora root partition is formatted as Btrfs for some reason the GRUB bootloader of my other distributions I have installed, including my second Fedora 27 installation, do not make boot entries for this old F27 installation and yes os-prober is installed on them and I have run grub-mkconfig -o /boot/grub/grub.cfg
(or their equivalent e.g. grub2-mkconfig -o /boot/grub2/grub.cfg
I know is what is done on Fedora) on them since I made this old Fedora installation. Now the reason for this question is not that I do not know how to chroot into a Linux system in general, but because whenever I do so with Fedora and then do package management within the chroot I end up with several systemd services failing on me on boot and the system refusing to finish booting. To be clear I would like to avoid this unpleasant result.
Here is my chroot procedure so you can scrutinize it (after I've mounted the required partitions, say the root partition is mounted at /mnt for the sake of the commands shown below):
mount -t proc /proc /mnt/proc
mount --rbind /dev /mnt/dev
mount --make-rslave /mnt/dev
mount --rbind /sys /mnt/sys
mount --make-rslave /mnt/sys
cp -L /etc/resolv.conf /mnt/etc
chroot /mnt /bin/bash
Your system is running with UEFI firmware, right? Then, your
grub-mkconfig
command is supposed to begrub-mkconfig -o boot/efi/EFI/fedora/grub.cfg
.Might be a bad habit I picked up from Arch as
/boot/efi/EFI/arch
only has grubx64.efi in it. Thanks, makes no difference though in this case. The bootloaders on other systems all do not even mention Fedora in their grub-mkconfig output, so hence an entry isn't even being created, regardless of the file it's stored in. The second Fedora installation does mention the other Fedora install in its GRUB output but as it was installed AFTER the first it should have written the first install's entry to its config to begin with. Anyway updating its GRUB config this way doesn't fix this problem.