Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
grub error: symbol 'grub_calloc' not found.
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
Massimo B.
Veteran
Veteran


Joined: 09 Feb 2005
Posts: 1771
Location: PB, Germany

PostPosted: Tue Nov 28, 2023 2:12 pm    Post subject: grub error: symbol 'grub_calloc' not found. Reply with quote

Hi,

the story: I have a portable USB drive with 3 partitions: EFI, boot and btrfs. On btrfs there are backup snapshots and also a bootable OpenSuse used as rescue system. The EFI partition is FAT32, the boot partition is ext4 and holds the initrd and kernel for the OpenSuse. Now I migrated that USB drive to a new USB drive, created EFI, boot and btrfs there as well and migrated data. EFI and boot I migrated via rsync, btrfs I migrated via btrfs replace...). At the end I tried to reinstall grub on that new drive like that, while having the EFI mounted:
Code:
grub-install --target=x86_64-efi --efi-directory=/mnt/newefi --removable


Now what happend: The grub on my internal harddrive is broken now and after trying to load grub on boot it shows:
Code:
 error: symbol 'grub_calloc' not found.


Then I tried to boot the rescue system from the new USB drive and was surprised, that is booting into my internal harddrive.

My internal setup is like this:
All the root fs is a btrfs-on-luks on an NVMe. Because this machine can't boot from PCIe-NVMe I have the booting stuff on my backup SATA hdd with /dev/sdb1 with FAT32 as EFI and /dev/sdb2 with ext4 as boot.

How can I repair my grub on the internal? I followed https://wiki.gentoo.org/wiki/Handbook:AMD64/Installation/Bootloader#EFI_systems:
Boot partition with kernels and initrd is mounted at /boot, EFI partition is mounted at /boot/efi:
Code:
# mount |grep boot
/dev/sdb2 on /boot type ext4 (rw,relatime,stripe=4)
/dev/sdb1 on /boot/efi type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)


But grub-install fails:
Code:
# grub-install --efi-directory=/boot/efi --target=x86_64-efi
Installing for x86_64-efi platform.
EFI variables are not supported on this system.
EFI variables are not supported on this system.
grub-install: error: efibootmgr failed to register the boot entry: No such file or directory.

_________________
HP ZBook Power 15.6" G8 i7-11800H|HP EliteDesk 800G1 i7-4790|HP Compaq Pro 6300 i7-3770


Last edited by Massimo B. on Tue Nov 28, 2023 7:54 pm; edited 1 time in total
Back to top
View user's profile Send private message
pietinger
Moderator
Moderator


Joined: 17 Oct 2006
Posts: 4167
Location: Bavaria

PostPosted: Tue Nov 28, 2023 2:34 pm    Post subject: Re: grub error: symbol 'grub_calloc' not found. Reply with quote

Massimo B. wrote:
the story: I have a portable USB drive with 3 partitions: EFI, boot and btrfs. On btrfs there are backup snapshots and also a bootable OpenSuse used as rescue system. The EFI partition is FAT32, the boot partition is ext4 and holds the initrd and kernel for the OpenSuse. Now I migrated that USB drive to a new USB drive, created EFI, boot and btrfs there as well and migrated data. EFI and boot I migrated via rsync, btrfs I migrated via btrfs replace...). At the end I tried to reinstall grub on that new drive like that, while having the EFI mounted:
Code:
grub-install --target=x86_64-efi --efi-directory=/mnt/newefi --removable

What happens if you use:
Code:
grub-install --target=x86_64-efi --efi-directory=/mnt/newefi --removable --root-directory=/mnt/newroot

?
(assuming you have mounted the root partition of your stick to /mnt/newroot AND the boot partition of your stick to /mnt/newroot/boot)
_________________
https://wiki.gentoo.org/wiki/User:Pietinger
Back to top
View user's profile Send private message
Massimo B.
Veteran
Veteran


Joined: 09 Feb 2005
Posts: 1771
Location: PB, Germany

PostPosted: Tue Nov 28, 2023 7:57 pm    Post subject: Reply with quote

First of all I need to repair grub on my internal disk. Why does https://wiki.gentoo.org/wiki/Handbook:AMD64/Installation/Bootloader#EFI_systems say to do
Code:
grub-install --target=x86_64-efi --efi-directory=/efi

? Where should the boot partition be mounted and where should the EFI partition be mounted?

Right now I'm booted into my gentoo on the internal disk. On my paste above you see how /boot and /boot/efi are mounted. How can I install grub now?
What does the error mean:
Code:
EFI variables are not supported on this system.

_________________
HP ZBook Power 15.6" G8 i7-11800H|HP EliteDesk 800G1 i7-4790|HP Compaq Pro 6300 i7-3770
Back to top
View user's profile Send private message
Massimo B.
Veteran
Veteran


Joined: 09 Feb 2005
Posts: 1771
Location: PB, Germany

PostPosted: Tue Nov 28, 2023 8:06 pm    Post subject: Re: grub error: symbol 'grub_calloc' not found. Reply with quote

pietinger wrote:
Code:
grub-install --target=x86_64-efi --efi-directory=/mnt/newefi --removable --root-directory=/mnt/newroot
Are you serious? My grub-install man-page or --help doesn't mention any --root-directory option.
Code:
# grub-install -V
grub-install (GRUB) 2.06

_________________
HP ZBook Power 15.6" G8 i7-11800H|HP EliteDesk 800G1 i7-4790|HP Compaq Pro 6300 i7-3770
Back to top
View user's profile Send private message
pietinger
Moderator
Moderator


Joined: 17 Oct 2006
Posts: 4167
Location: Bavaria

PostPosted: Wed Nov 29, 2023 1:34 am    Post subject: Re: grub error: symbol 'grub_calloc' not found. Reply with quote

Massimo B. wrote:
First of all I need to repair grub on my internal disk. Why does https://wiki.gentoo.org/wiki/Handbook:AMD64/Installation/Bootloader#EFI_systems say to do
Code:
grub-install --target=x86_64-efi --efi-directory=/efi

? Where should the boot partition be mounted and where should the EFI partition be mounted?

We had some confusion about the mountpoint of the ESP. Please read:
https://forums.gentoo.org/viewtopic-t-1165115.html
or in german:
https://forums.gentoo.org/viewtopic-p-8801625.html#8801625

Massimo B. wrote:
Right now I'm booted into my gentoo on the internal disk. On my paste above you see how /boot and /boot/efi are mounted. How can I install grub now?
What does the error mean:
Code:
EFI variables are not supported on this system.

You will need the correct kernel configuration AND the efivarfs must be mounted. See both here:
https://wiki.gentoo.org/wiki/UEFI
https://wiki.gentoo.org/wiki/Efibootmgr
OR:
https://wiki.gentoo.org/wiki/User:Pietinger/Tutorials/Boot_kernel_via_UEFI#Prerequisites_for_an_UEFI_boot

Massimo B. wrote:
pietinger wrote:
Code:
grub-install --target=x86_64-efi --efi-directory=/mnt/newefi --removable --root-directory=/mnt/newroot
Are you serious? My grub-install man-page or --help doesn't mention any --root-directory option.

TBH ... I have not tried it ... but logically there must be a possibility to specify a different root directory, otherwise you could only install the grub to /boot/grub (of your current root partitin) and never to a USB stick. So I just searched for the name of the parameter and found it in the Manpage of grub-install (I also have version 2.06):
Code:
      --root-directory=VERZEICHNIS
              installiert GRUB-Abbilder im angegebenen VERZEICHNIS anstelle des Wurzelverzeichnisses.

Please dont forget a grub-mkconfig ... ;-)
_________________
https://wiki.gentoo.org/wiki/User:Pietinger
Back to top
View user's profile Send private message
GDH-gentoo
Veteran
Veteran


Joined: 20 Jul 2019
Posts: 1541
Location: South America

PostPosted: Wed Nov 29, 2023 12:42 pm    Post subject: Reply with quote

pietinger wrote:
Massimo B. wrote:
pietinger wrote:
Code:
grub-install --target=x86_64-efi --efi-directory=/mnt/newefi --removable --root-directory=/mnt/newroot
Are you serious? My grub-install man-page or --help doesn't mention any --root-directory option.

TBH ... I have not tried it ... but logically there must be a possibility to specify a different root directory, otherwise you could only install the grub to /boot/grub (of your current root partitin) and never to a USB stick. So I just searched for the name of the parameter and found it in the Manpage of grub-install (I also have version 2.06):
Code:
      --root-directory=VERZEICHNIS
              installiert GRUB-Abbilder im angegebenen VERZEICHNIS anstelle des Wurzelverzeichnisses.

The option does exist, it's just hidden (presumably because it is considered "advanced"):
util/grub-install.c
Code:
static struct argp_option options[] = {
  GRUB_INSTALL_OPTIONS,
  /* ... */
  {"root-directory", OPTION_ROOT_DIRECTORY, N_("DIR"),
   OPTION_HIDDEN, 0, 2},
  /* ... */
  {0, 0, 0, 0, 0, 0}
};

_________________
NeddySeagoon wrote:
I'm not a witch, I'm a retired electronics engineer :)
Ionen wrote:
As a packager I just don't want things to get messier with weird build systems and multiple toolchains requirements though :)
Back to top
View user's profile Send private message
Massimo B.
Veteran
Veteran


Joined: 09 Feb 2005
Posts: 1771
Location: PB, Germany

PostPosted: Thu Nov 30, 2023 6:55 am    Post subject: Re: grub error: symbol 'grub_calloc' not found. Reply with quote

pietinger wrote:
You will need the correct kernel configuration AND the efivarfs must be mounted.
Right, that's it. I actually never ran grub-install from my own Linux and the kernel wasn't ready. All the live systems for rescue have a ready kernel. So I adapted my kernel config and it seems to install grub now:
Code:
# zgrep EFIVAR_FS /proc/config.gz
CONFIG_EFIVAR_FS=m

# find /sys/firmware/efi/efivars |wc -l
181

# grub-install --efi-directory=/boot/efi --target=x86_64-efi
Installing for x86_64-efi platform.
Installation finished. No error reported.

_________________
HP ZBook Power 15.6" G8 i7-11800H|HP EliteDesk 800G1 i7-4790|HP Compaq Pro 6300 i7-3770
Back to top
View user's profile Send private message
Massimo B.
Veteran
Veteran


Joined: 09 Feb 2005
Posts: 1771
Location: PB, Germany

PostPosted: Thu Nov 30, 2023 12:36 pm    Post subject: Reply with quote

Ok, my internal grub is working again. So one of the 2 issues are fixed now.

Back to my original task that I migrated from one USB drive to a new USB drive. How can I restore grub on that new USB drive? Right now when opening the mchines's EFI menu I see 2 EFI entries to boot. One is my internal disk that now works again. The other is that USB drive that now just boots the same internal disk and not the USB device itself.
Booting that USB-Drive on a different machine (laptop), grub fails with the error "No such device... <UUID>" while that UUID is that of my boot partition on the internal desktop drive. Where is that UUID stored?
On the USB drive there is the 2nd partition the ext4 boot partition, and in ./grub2/grub.cfg I already replaced all UUIDs from the old USB boot partition to the new USB boot partition. That boot UUID of my internal drive is not mentioned there, that one is in the error message when trying to boot.
_________________
HP ZBook Power 15.6" G8 i7-11800H|HP EliteDesk 800G1 i7-4790|HP Compaq Pro 6300 i7-3770


Last edited by Massimo B. on Thu Nov 30, 2023 1:46 pm; edited 1 time in total
Back to top
View user's profile Send private message
pietinger
Moderator
Moderator


Joined: 17 Oct 2006
Posts: 4167
Location: Bavaria

PostPosted: Thu Nov 30, 2023 1:31 pm    Post subject: Reply with quote

Before many years we had an "old" grub and later a new "grub2". After a few years, they buried the old grub and renamed the grub2 to grub. So, today we have only one grub (which is a grub2). Today, this grub will be installed to /boot/grub and has its configuration file (and all other files grub needs) in /boot/grub/grub.cfg. If you have a ./grub2/grub.cfg this must be a very old installation.

I have never created a bootable USB stick with a grub as first booted application (I only made a bootable stick which immediately boots a manually configured kernel: https://forums.gentoo.org/viewtopic-t-1122548.html )

What I suspect, however, is that you need a stick that has at least two partitions: An ESP and a root partition. There must be a \efi\boot\bootx64.efi on the ESP. This is a hard-coded name that every UEFI BIOS recognizes - without an explicit entry in the UEFI table. In your case, this would be the 1st part of grub (this is exactly why there is the parameter "removable" during grub-install). Then you have to create a grub.cfg THERE (= /boot/grub/grub.cfg OF the USB stick) and in this you have to point to the kernel that is in /boot of the root partition of the USB stick. Be careful with a "grub-mkconfig" because of course it wants to edit the grub.cfg of the ACTIVE root partition (= your root partition with which you started the system).
_________________
https://wiki.gentoo.org/wiki/User:Pietinger
Back to top
View user's profile Send private message
Massimo B.
Veteran
Veteran


Joined: 09 Feb 2005
Posts: 1771
Location: PB, Germany

PostPosted: Thu Nov 30, 2023 1:56 pm    Post subject: Reply with quote

I guess ./grub2/grub.cf was created by the OpenSuse installer which is not that old, installation is maybe 2 years old now.
I don't think grub.cfg is the culprit for now because the missing device UUID is not mentioned there. I just replaced the old UUID with the new USB boot UUID in that grub.cfg...

I try to re-install grub with --removable:
Code:
# grub-install --efi-directory=/mnt/newefi --target=x86_64-efi --removable
Installing for x86_64-efi platform.
grub-install: error: attempt to install to encrypted disk without cryptodisk enabled. Set `GRUB_ENABLE_CRYPTODISK=y' in file `/etc/default/grub'.

What is encrypted here? The encrypted part is sdh3, which is a btrfs on LUKS:
Code:
# fdisk -l /dev/sdh
Disk /dev/sdh: 3,64 TiB, 4000787030016 bytes, 7814037168 sectors
Disk model:  SN850X 4000GB 
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 33553920 bytes
Disklabel type: gpt
Disk identifier: 75F5DD74-8BB4-2947-A891-5EECF3037E5F

Device      Start        End    Sectors  Size Type
/dev/sdh1    2048      73727      71680   35M EFI System
/dev/sdh2   73728     598015     524288  256M Linux filesystem
/dev/sdh3  598016 7814035455 7813437440  3,6T Linux filesystem

_________________
HP ZBook Power 15.6" G8 i7-11800H|HP EliteDesk 800G1 i7-4790|HP Compaq Pro 6300 i7-3770
Back to top
View user's profile Send private message
pietinger
Moderator
Moderator


Joined: 17 Oct 2006
Posts: 4167
Location: Bavaria

PostPosted: Thu Nov 30, 2023 1:58 pm    Post subject: Reply with quote

Massimo B. wrote:
I try to re-install grub with --removable:
[code]grub-install --efi-directory=/mnt/newefi --target=x86_64-efi --removable

With this you will install grub TO /boot/grub OF YOUR root partition. Why you dont use "--root-directory=/mnt/newroot" ?
_________________
https://wiki.gentoo.org/wiki/User:Pietinger
Back to top
View user's profile Send private message
Massimo B.
Veteran
Veteran


Joined: 09 Feb 2005
Posts: 1771
Location: PB, Germany

PostPosted: Thu Nov 30, 2023 2:00 pm    Post subject: Reply with quote

Because this command is not documented anywhere. And if, what should newroot be? The new mounted boot partition? Or the encrypted partition with the root fs?
_________________
HP ZBook Power 15.6" G8 i7-11800H|HP EliteDesk 800G1 i7-4790|HP Compaq Pro 6300 i7-3770
Back to top
View user's profile Send private message
pietinger
Moderator
Moderator


Joined: 17 Oct 2006
Posts: 4167
Location: Bavaria

PostPosted: Thu Nov 30, 2023 2:02 pm    Post subject: Reply with quote

Massimo B. wrote:
Because this command is not documented anywhere. And if, what should newroot be? The new mounted boot partition? Or the encrypted partition with the root fs?

You have ON YOUR STICK a root partition (where is your kernel in /boot you want boot with grub of stick). Mount this root partition to /mnt/newroot (as you have mounted the ESP OF THE STICK to /mnt/newefi). So both partitions of your sitck are mounted.
_________________
https://wiki.gentoo.org/wiki/User:Pietinger
Back to top
View user's profile Send private message
Massimo B.
Veteran
Veteran


Joined: 09 Feb 2005
Posts: 1771
Location: PB, Germany

PostPosted: Thu Nov 30, 2023 2:11 pm    Post subject: Reply with quote

I see. What you called root partition, I called boot partition because it will usually be mounted in /boot, is ext4, holds the initrd, kernel and grub.cfg...
I got something installed now like this:
Code:
# mount |grep sdh
/dev/sdh1 on /mnt/newefi type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)
/dev/sdh2 on /mnt/newboot type ext4 (rw,relatime)

# grub-install --efi-directory=/mnt/newefi --boot-directory=/mnt/newboot --target=x86_64-efi --removable
Installing for x86_64-efi platform.
Installation finished. No error reported.

That however created a /mnt/newboot/grub beside the existing /mnt/newboot/grub2.
Now booting that USB device on a laptop, it just boots into a grub CLI, no menu, no kernels...
_________________
HP ZBook Power 15.6" G8 i7-11800H|HP EliteDesk 800G1 i7-4790|HP Compaq Pro 6300 i7-3770
Back to top
View user's profile Send private message
pietinger
Moderator
Moderator


Joined: 17 Oct 2006
Posts: 4167
Location: Bavaria

PostPosted: Thu Nov 30, 2023 2:13 pm    Post subject: Reply with quote

Massimo B. wrote:
Now booting that USB device on a laptop, it just boots into a grub CLI, no menu, no kernels...

That means grub is missing its configuration ... :lol:
_________________
https://wiki.gentoo.org/wiki/User:Pietinger
Back to top
View user's profile Send private message
Massimo B.
Veteran
Veteran


Joined: 09 Feb 2005
Posts: 1771
Location: PB, Germany

PostPosted: Thu Nov 30, 2023 2:20 pm    Post subject: Reply with quote

Ok, I just moved grub to grub.new and grub2 to grub. So it now finds the old grub.cfg in ./grub... The grub menu starts now and I'm able to boot ...
Just the backgrounds and coloring is missing... OpenSuse somehow still uses ./grub2 while Gentoo-installed grub uses ./grub. How can I change that?

After booting the kernel I have other issues that inside the initrd there are some UUIDs wrong, but that's another story..
_________________
HP ZBook Power 15.6" G8 i7-11800H|HP EliteDesk 800G1 i7-4790|HP Compaq Pro 6300 i7-3770
Back to top
View user's profile Send private message
pietinger
Moderator
Moderator


Joined: 17 Oct 2006
Posts: 4167
Location: Bavaria

PostPosted: Thu Nov 30, 2023 2:34 pm    Post subject: Reply with quote

Massimo B. wrote:
[...] OpenSuse somehow still uses ./grub2 while Gentoo-installed grub uses ./grub. How can I change that?

Sorry, I dont know how to change it. Maybe ... it is not changeable (because hardcoded into grub?)

Grub consists of two parts (to put it simply): The first part is the bootable "grubx64.efi" (or bootx64.efi if renamed). This part must find the second part of grub which resides in /boot/grub (or /grub2 if old installation). So maybe you have a chance to change this at compile time of grub ?
_________________
https://wiki.gentoo.org/wiki/User:Pietinger
Back to top
View user's profile Send private message
GDH-gentoo
Veteran
Veteran


Joined: 20 Jul 2019
Posts: 1541
Location: South America

PostPosted: Thu Nov 30, 2023 5:13 pm    Post subject: Reply with quote

Massimo B. wrote:
OpenSuse somehow still uses ./grub2 while Gentoo-installed grub uses ./grub. How can I change that?

Once the package is built, as far as I know, it can't be changed. Likely, openSUSE just builds GRUB with compile-time options different from Gentoo's. I think that they are using a --program-transform-name configure script option.
_________________
NeddySeagoon wrote:
I'm not a witch, I'm a retired electronics engineer :)
Ionen wrote:
As a packager I just don't want things to get messier with weird build systems and multiple toolchains requirements though :)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum