Grub-mkconfig failed when I install 21.3

I install manjaro 21.3 today. I need a fs that support compression and encrypt, so I use F2FS for my rootfs. Because grub cannot correctly read its boot files from an F2FS partition that was created with the extra_attr flag enabled, I created a EXT4 partition with mount point /boot.
Calamares wouldn’t enable compression and encrypt for me, so I created a shell script to do this.

cat /usr/sbin/mkfs.f2fs                                                                                                                                      #!/bin/bash

/usr/sbin/mkfs.f2fs.real -O extra_attr,inode_checksum,sb_checksum,compression,encrypt $@

After partition, my disk look like:

sudo fdisk -l /dev/nvme0n1
Disk /dev/nvme0n1: 476.94 GiB, 512110190592 bytes, 1000215216 sectors
Disk model: Micron MTFDKBA512TFH                    
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: B16FB978-14F7-FB47-947C-628D2BFC4FE3

Device             Start        End   Sectors   Size Type
/dev/nvme0n1p1      4096     413695    409600   200M EFI System
/dev/nvme0n1p2    413696    1462271   1048576   512M Linux filesystem
/dev/nvme0n1p3   1462272  964780518 963318247 459.3G Linux filesystem
/dev/nvme0n1p4 964780519 1000215182  35434664  16.9G Linux swap

But grub-mkconfig failed. From calamares’ log, I saw

    Starting job "bootloader" ( 36 / 38 ) 
00:54:52 [6]: virtual Calamares::JobResult Calamares::PythonJob::exec()
    Job file "/usr/lib/calamares/modules/bootloader/main.py" 
    .. Job description from pretty_name "bootloader" = "Install bootloader." 
[PYTHON JOB]: "Bootloader: grub (efi)" 
    .. Running ("grub-install", "--target=x86_64-efi", "--efi-directory=/boot/efi", "--bootloader-id=Manjaro", "--force") 
[PYTHON JOB]: "UEFI Fallback: True" 
[PYTHON JOB]: "  .. installing 'bootx64.efi' fallback firmware" 
    .. Running ("grub-mkconfig", "-o", "/boot/grub/grub.cfg") 
    .. Target cmd: ("grub-mkconfig", "-o", "/boot/grub/grub.cfg") Exit code: 1 output:
 Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.15-x86_64
Found initrd image: /boot/intel-ucode.img /boot/amd-ucode.img /boot/initramfs-5.15-x86_64.img
Found initrd fallback image: /boot/initramfs-5.15-x86_64-fallback.img
Warning: os-prober will be executed to detect other bootable partitions.
Its output will be used to detect bootable binaries on them and create new boot entries.
grub-probe: error: cannot find a GRUB drive for /dev/sda1.  Check your device.map.
grub-probe: error: cannot find a GRUB drive for /dev/sda1.  Check your device.map.
Adding boot menu entry for UEFI Firmware Settings ...
WARNING: [PYTHON JOB]: "Command 'grub-mkconfig -o /boot/grub/grub.cfg' returned non-zero exit status 1." 
[PYTHON JOB]: "stdout:Generating grub configuration file ...\nFound linux image: /boot/vmlinuz-5.15-x86_64\nFound initrd image: /boot/intel-ucode.img /boot/amd-ucode.img /boot/initramfs-5.15-x86_64.img\nFound initrd fallback image: /boot/initramfs-5.15-x86_64-fallback.img\nWarning: os-prober will be executed to detect other bootable partitions.\nIts output will be used to detect bootable binaries on them and create new boot entries.\ngrub-probe: error: cannot find a GRUB drive for /dev/sda1.  Check your device.map.\ngrub-probe: error: cannot find a GRUB drive for /dev/sda1.  Check your device.map.\nAdding boot menu entry for UEFI Firmware Settings ..." 
[PYTHON JOB]: "stderr:None" 
00:54:55 [6]: virtual void Calamares::JobThread::run()
    Skipping non-emergency job "postcfg" 
    ..  Skipping non-emergency job "Unmount file systems." 
00:54:55 [1]: void Calamares::ViewManager::onInstallationFailed(const QString&, const QString&)
    ERROR: Installation failed: "Bootloader installation error" 
    .. - message: "Bootloader installation error" 
    .. - details: The bootloader could not be installed. The installation command <pre>grub-mkconfig -o /boot/grub/grub.cfg</pre> returned error code 1。
00:54:55 [6]: void Calamares::ViewManager::onInstallationFailed(const QString&, const QString&)
    Calamares will quit when the dialog closes. 
00:54:55 [6]: void Config::doNotify(bool, bool)
    Notification not sent; completion: failed 

But I can run grub-mkconfig successful when I chroot to the target.

sudo chroot /tmp/calamares-root-__v5jvf9
[root@manjaro /]# grub-mkconfig -o /boot/grub/grub.cfg
Generating grub configuration file ...
Found theme: /usr/share/grub/themes/manjaro/theme.txt
Found linux image: /boot/vmlinuz-5.15-x86_64
Found initrd image: /boot/intel-ucode.img /boot/amd-ucode.img /boot/initramfs-5.15-x86_64.img
Found initrd fallback image: /boot/initramfs-5.15-x86_64-fallback.img
Warning: os-prober will be executed to detect other bootable partitions.
Its output will be used to detect bootable binaries on them and create new boot entries.
grub-probe: error: cannot find a GRUB drive for /dev/sda1.  Check your device.map.
grub-probe: error: cannot find a GRUB drive for /dev/sda1.  Check your device.map.
Adding boot menu entry for UEFI Firmware Settings ...
Found memtest86+ image: /boot/memtest86+/memtest.bin
/usr/bin/grub-probe: warning: unknown device type nvme0n1.
done
[root@manjaro /]# echo $?
0

So, what’s wrong with my installation? How to fixed it?

Can you post /etc/default/grub ?

sure

cat /etc/default/grub
GRUB_DEFAULT=saved
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="Manjaro"
GRUB_CMDLINE_LINUX_DEFAULT=""
GRUB_CMDLINE_LINUX=""

# If you want to enable the save default function, uncomment the following
# line, and set GRUB_DEFAULT to saved.
GRUB_SAVEDEFAULT=true

# Preload both GPT and MBR modules so that they are not missed
GRUB_PRELOAD_MODULES="part_gpt part_msdos"

# Uncomment to enable Hidden Menu, and optionally hide the timeout count
#GRUB_HIDDEN_TIMEOUT=5
#GRUB_HIDDEN_TIMEOUT_QUIET=true

# Uncomment to use basic console
GRUB_TERMINAL_INPUT=console

# Uncomment to disable graphical terminal
#GRUB_TERMINAL_OUTPUT=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
GRUB_GFXMODE=auto

# Uncomment to allow the kernel use the same resolution used by grub
GRUB_GFXPAYLOAD_LINUX=keep

# Uncomment if you want GRUB to pass to the Linux kernel the old parameter 
# format "root=/dev/xxx" instead of "root=/dev/disk/by-uuid/xxx" 
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
GRUB_DISABLE_RECOVERY=true

# Uncomment and set to the desired menu colors.  Used by normal and wallpaper 
# modes only.  Entries specified as foreground/background.
GRUB_COLOR_NORMAL="light-gray/black"
GRUB_COLOR_HIGHLIGHT="green/black"

# Uncomment one of them for the gfx desired, a image background or a gfxtheme
#GRUB_BACKGROUND="/usr/share/grub/background.png"
#GRUB_THEME="/path/to/gfxtheme"

# Uncomment to get a beep at GRUB start
#GRUB_INIT_TUNE="480 440 1"

cat /tmp/calamares-root-nxgionwh/etc/default/grub
GRUB_DEFAULT=saved
GRUB_TIMEOUT=5
GRUB_TIMEOUT_STYLE=hidden
GRUB_DISTRIBUTOR="Manjaro"
GRUB_CMDLINE_LINUX_DEFAULT="quiet udev.log_priority=3"
GRUB_CMDLINE_LINUX=""

# If you want to enable the save default function, uncomment the following
# line, and set GRUB_DEFAULT to saved.
#GRUB_SAVEDEFAULT="true"

# Uncomment to disable submenus in boot menu
#GRUB_DISABLE_SUBMENU=y

# Preload both GPT and MBR modules so that they are not missed
GRUB_PRELOAD_MODULES="part_gpt part_msdos"

# Uncomment to enable booting from LUKS encrypted devices
#GRUB_ENABLE_CRYPTODISK=y

# Uncomment to use basic console
GRUB_TERMINAL_INPUT=console

# Uncomment to disable graphical terminal
#GRUB_TERMINAL_OUTPUT=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command 'videoinfo'
GRUB_GFXMODE=auto

# Uncomment to allow the kernel use the same resolution used by grub
GRUB_GFXPAYLOAD_LINUX=keep

# Uncomment if you want GRUB to pass to the Linux kernel the old parameter
# format "root=/dev/xxx" instead of "root=/dev/disk/by-uuid/xxx"
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
GRUB_DISABLE_RECOVERY=true

# Uncomment this option to enable os-prober execution in the grub-mkconfig command
GRUB_DISABLE_OS_PROBER=false

# Uncomment and set to the desired menu colors.  Used by normal and wallpaper
# modes only.  Entries specified as foreground/background.
GRUB_COLOR_NORMAL="light-gray/black"
GRUB_COLOR_HIGHLIGHT="green/black"

# Uncomment one of them for the gfx desired, a image background or a gfxtheme
#GRUB_BACKGROUND="/usr/share/grub/background.png"
GRUB_THEME="/usr/share/grub/themes/manjaro/theme.txt"

# Uncomment to get a beep at GRUB start
#GRUB_INIT_TUNE="480 440 1"

# Uncomment to ensure that the root filesystem is mounted read-only so that
# systemd-fsck can run the check automatically. We use 'fsck' by default, which
# needs 'rw' as boot parameter, to avoid delay in boot-time. 'fsck' needs to be
# removed from 'mkinitcpio.conf' to make 'systemd-fsck' work.
# See also Arch-Wiki: https://wiki.archlinux.org/index.php/Fsck#Boot_time_checking
#GRUB_ROOT_FS_RO=true

The system tries to access the grub background theme before the kernel and the initrd is loaded.
This file is located on the root partition.
GRUB_THEME="/usr/share/grub/themes/manjaro/theme.txt" must be set to
#GRUB_THEME="/usr/share/grub/themes/manjaro/theme.txt".
Then try again.
Can you show /boot/grub/grub.cfg ?

Wow, I uncomment GRUB_THEME="/usr/share/grub/themes/manjaro/theme.txt" in TARGET_ROOTFS/etc/default/grub, my installation is successful!

This is strange, because I check the boot/grub/grub.cfg.new file in target rootfs when grub-mkconfig failed, the failing script is etc/grub.d/41_snapshots-btrfs:

sudo tail /tmp/calamares-root-nxgionwh/boot/grub/grub.cfg.new

### BEGIN /etc/grub.d/41_custom ###
if [ -f  ${config_directory}/custom.cfg ]; then
  source ${config_directory}/custom.cfg
elif [ -z "${config_directory}" -a -f  $prefix/custom.cfg ]; then
  source $prefix/custom.cfg
fi
### END /etc/grub.d/41_custom ###

### BEGIN /etc/grub.d/41_snapshots-btrfs ###

All though grub-mkconfig is successful, update-grub is failed:

13:44:00 [6]: virtual void Calamares::JobThread::run()
    Starting job "postcfg" ( 37 / 38 ) 
13:44:00 [6]: virtual Calamares::JobResult Calamares::PythonJob::exec()
    Job file "/usr/lib/calamares/modules/postcfg/main.py" 
    .. Job description from __doc__ "postcfg" = "Misc postinstall configurations" 
    .. Running ("pacman-key", "--init") 
    .. Running ("pacman-key", "--populate", "archlinux", "manjaro") 
    .. Running ("pacman-mirrors", "-f3") 
    .. Running ("pacman", "-Syy") 
    .. Running ("pacman", "-R", "--noconfirm", "amd-ucode") 
    .. Running ("killall", "-9", "gpg-agent") 
    .. Running ("update-grub") 
    .. Target cmd: ("update-grub") Exit code: 1 output:
 Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.15-x86_64
Found initrd image: /boot/intel-ucode.img /boot/initramfs-5.15-x86_64.img
Found initrd fallback image: /boot/initramfs-5.15-x86_64-fallback.img
Warning: os-prober will be executed to detect other bootable partitions.
Its output will be used to detect bootable binaries on them and create new boot entries.
grub-probe: error: cannot find a GRUB drive for /dev/sda1.  Check your device.map.
grub-probe: error: cannot find a GRUB drive for /dev/sda1.  Check your device.map.
Adding boot menu entry for UEFI Firmware Settings ...
    .. Running ("grub-editenv", "-", "set", "menu_auto_hide=1", "boot_success=1") 
13:45:12 [2]: boost::python::api::object CalamaresPython::GlobalStoragePythonWrapper::value(const std::string&) const
    WARNING: Unknown GS key packagechooser_packagechooser 
WARNING: [PYTHON JOB]: "no office suite selected, None"

postcfg remove amd-ucode, so I can’t boot to the system when update-grub was failed.

So I manjaro-chroot to the new system, and run update-grub manually. Update-grub successful.

manjaro-chroot /tmp/calamares-root-ew65yuis
sh-5.1# update-grub 
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.15-x86_64
Found initrd image: /boot/intel-ucode.img /boot/initramfs-5.15-x86_64.img
Found initrd fallback image: /boot/initramfs-5.15-x86_64-fallback.img
Warning: os-prober will be executed to detect other bootable partitions.
Its output will be used to detect bootable binaries on them and create new boot entries.
grub-probe: error: cannot find a GRUB drive for /dev/sda1.  Check your device.map.
grub-probe: error: cannot find a GRUB drive for /dev/sda1.  Check your device.map.
Adding boot menu entry for UEFI Firmware Settings ...
Found memtest86+ image: /boot/memtest86+/memtest.bin
/usr/bin/grub-probe: warning: unknown device type nvme0n1.
done
sh-5.1# grep ucode /boot/grub/grub.cfg 
        initrd  /intel-ucode.img /initramfs-5.15-x86_64.img
                initrd  /intel-ucode.img /initramfs-5.15-x86_64.img

I can run grub-mkconfig and update-grub in chroot environment successful, but calamares run them failed. I think the manjaro installation need to improve.
BTW, when I partition manually, calamares pass the -l option to mkfs.f2fs, but with no label argument! It’s a bug.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.