Just want to know for understanding purpose. What is the relevance of chroot, when you can anyways do --root-directory or --boot-directory or --efi-directory with grub-install at the time of executing grub-install from a recovery CD? Or you can use either or?
2 Answers
I could be wrong but I don't think older versions of grub-install allowed for the specification of the boot directory and hence the need for chroot. I've never used chroot with the newer versions

- 1,432
Yes, it is necessary.
The update of grub needs to update both the boot time loaded modules in /boot/grub
as the running modules for the grub program itself (to the same version) in /usr/lib/grub/
.
Only the boot loaded modules could also be updated via the specification of the boot directory in grub-install
, but not the modules in /usr/lib/grub/
.
To update /usr/lib/grub/
the correct filesystem needs to be mounted and the chroot allows the correct access to it. Then execute grub-update
.
EDIT
Please understand that when a pen-drive system is used (as the system is unbootable), it comes with its own version of grub and modules in /usr/lib/grub/
, /etc/grub.d
and /etc/default/grub
. Those modules are the ones that will be copied to /boot/grub
if no chroot is performed. The version of such modules may be out of sync with the grub booting from the MBR (or UEFI).
The only safe way to have all grub parts in sync is to chroot to the system to be booted.
-
interesting. thought grub-mkconfig and grub-install touched only the /boot folder. Do you know, when is it required to update /usr/lib/grub too? If you just want to restore the grub menu during start up, then is it enough to run grub-install with --boot-directory option only? – infoclogged Jan 06 '18 at 09:17
-
chroot
step, your 'live' media (cd/usb-thumb-drive) would be treated as the bootable device with theupdate-grub
(ie. you'd only be able to boot with the live media installed). Yep I think it qualifies as necessary (esp. if CD is read-only!) – guiverc Jan 05 '18 at 10:28