2

The OS with Ubuntu 20.04.3 LTS Desktop 64-bit is located in the gpt2 partition with the filesystem NTFS.

This is the structure of the gpt1 partition with the filesystem FAT32:

.
├── boot
│   └── grub
│       └── grub.cfg
└── efi
    └── boot
        ├── bootx64.efi
        ├── grubx64.efi
        └── mmx64.efi

4 directories, 4 files

This is the grub menù of the NTFS partition (default grub.cfg):

if loadfont /boot/grub/font.pf2 ; then
    set gfxmode=auto
    insmod efi_gop
    insmod efi_uga
    insmod gfxterm
    terminal_output gfxterm
fi

set menu_color_normal=white/black set menu_color_highlight=black/light-gray

set timeout=5 menuentry "Ubuntu" { set gfxpayload=keep linux /casper/vmlinuz file=/cdrom/preseed/ubuntu.seed maybe-ubiquity quiet splash --- initrd /casper/initrd } menuentry "Ubuntu (safe graphics)" { set gfxpayload=keep linux /casper/vmlinuz file=/cdrom/preseed/ubuntu.seed maybe-ubiquity quiet splash nomodeset --- initrd /casper/initrd } menuentry "OEM install (for manufacturers)" { set gfxpayload=keep linux /casper/vmlinuz file=/cdrom/preseed/ubuntu.seed only-ubiquity quiet splash oem-config/enable=true --- initrd /casper/initrd } grub_platform if [ "$grub_platform" = "efi" ]; then menuentry 'Boot from next volume' { exit 1 } menuentry 'UEFI Firmware Settings' { fwsetup } fi

If the grub.cfg file (FAT32 partition) contains:

search --no-floppy --set=root --fs-uuid 2E92F36515DD4A5A
chainloader /EFI/BOOT/BOOTx64.EFI
boot

After making a choice from the grub selection menu, placed in the default grub.cfg file (NTFS partition) which is the same as the default contained within an iso image of Ubuntu 20.04.3 LTS Desktop 64-bit, the error message appears:

error: can't allocate initrd.
Press any key to continue...

I have to underline that the NTFS partition bootloader starts correctly with the chainloader command, otherwise I would not have seen the grub selection menu, it is the initrd command that gives an error.

If instead the grub.cfg file (FAT32 partition) contains:

search --no-floppy --set=root --fs-uuid 2E92F36515DD4A5A
configfile /boot/grub/grub.cfg

After the selection menu, everything works correctly, therefore the initrd command no longer gives an error.

What's wrong with running the NTFS partition bootloader to boot initrd using the default grub.cfg file inside it?
I have tested that if partition 2 has Windows, using chainloader everything works correctly.

UPDATE 1:
I tried to swap partitions, the error persists.

UPDATE 2:
I would like to get more detailed error output from the initrd command but I don't know how to do it.
I have tried

linux   /casper/vmlinuz file=/cdrom/preseed/ubuntu.seed nosplash debug ignore_loglevel ---
initrd  /casper/initrd

but the error output is still the same, no rows added.

UPDATE 3:
Summarizing and clarifying what I am going to do, I from the partition with FAT32 do the chainload of the bootloader located on the NTFS partition.
If I boot the NTFS partition directly from BIOS, everything works, if instead I chainload starting from the FAT32 partition, problems appear.
Everything works correctly even if I call the menu of the grub.cfg (NTFS partition) using the configfile command rather than the chainloader command inside the grub.cfg file of the FAT32 partition, of which I have already shown the lines it contains.

UPDATE 4:
I am going to use the chainloader command anyway for generalization reasons, even being able to use the configfile command that would solve the problem, because I would have the possibility to execute the same command both to start a partition with Windows and Ubuntu.

UPDATE 5:
The ntfs module is already built into the bootloader of both partitions. The lsmod command confirmed this. In any case I have tried to insert insmod ntfs in the grub.cfg files of both partitions and, as expected, the error does not change.

UPDATE 6:
I don't boot NTFS partition directly from BIOS, because UEFI on older computers cannot read NTFS directly.

UPDATE 7:
I HAVE DISCOVERED AN ERROR! Before I didn't notice it because it lasts a fraction of a second. But with a video from the phone, which I had to set to 60 fps to be able to catch the error, I recorded it, then took it to the PC, from the PC I took a screenshot of that video fragment, then rotated it and cropped with gimp.
The error is as follows:

error: can't find command `grub_platform`.

Here is the screenshot:

enter image description here

Mario Palumbo
  • 277
  • 2
  • 8
  • 36

2 Answers2

0

You're running Linux on NTFS, is that correct?

If so, GRUB probably can't read NTFS by default and so can't access the initrd file. According to the Grub2 documentation https://www.gnu.org/software/grub/manual/grub/html_node/Chain_002dloading.html I would try adding that insmod ntfs to the appropraite menuentry.

If that's not correct, you should clarify your question with the exact (relevant) configuration stanzas for the configuration files.

I also can't tell if the error is coming from GRUB or the Linux kernel. Does the kernel start to load at all?

It's also not clear to me why you want to chainload to another boot loader to load Linux instead of just loading the kernel from the NTFS partition directly, but given that you've installed Linux on NFTS I'll assume you have a reason for doing this.

  • I from the partition with FAT32 do the chainload of the bootloader located on the NTFS partition. If I boot the NTFS partition directly from BIOS, everything works, if instead I chainload starting from the FAT32 partition, problems appear. Everything works correctly even if I call the menu of the grub.cfg (configfile command) located on the NTFS partition, starting from the grub.cfg of the FAT32 partition, of which in my question I have shown the lines it contains. – Mario Palumbo Mar 28 '22 at 19:53
  • @MarioPalumbo did you try adding insmod ntfs before the rest of the lines you posted? – Esther Mar 28 '22 at 20:15
  • No, I will try. – Mario Palumbo Mar 28 '22 at 20:22
  • Yesterday I already made all the necessary edits to specify the question in depth. – Mario Palumbo Mar 29 '22 at 11:43
  • The ntfs module is already built into the bootloader of both partitions. The lsmod command confirmed this. In any case I have tried to insert insmod ntfs in the grub.cfg files of both partitions and, as expected, the error does not change. However, I have to underline that the NTFS partition bootloader starts correctly with the chainloader command, it is the initrd command that gives an error, and I would also like to know how to make the error message more detailed. – Mario Palumbo Mar 29 '22 at 15:48
  • I have edited and detailed the question as best I could, that's the best I can do. Now I need you to try to understand the question well, there is nothing else I can specify, I have already written all the writable in the question. – Mario Palumbo Mar 29 '22 at 16:07
  • Hi @MarioPalumbo, I'm not sure you've posted the necessary configuration blocks. I don't see any 'menuitem' entries, for instance. However, if I understand, you want to chainload from drive2/NTFS, but you're loading from drive1/FAT. I think you need to chainload the other drive, like chainloader (hd1,gpt1)/path/to/grub.efi.

    Does this help? https://unix.stackexchange.com/questions/343632/uefi-chainloading-grub-from-grub

    I think I'm doing 'answers' wrong so I'll fix my answer or delete this if I can, after you let me know.

    – rand'Chris Mar 29 '22 at 16:50
  • It's also not clear to me why you want to chainload to another boot loader to load Linux instead of just loading the kernel from the NTFS partition directly. Because UEFI on older computers cannot read NTFS directly. I am going to use the chainloader command anyway for generalization reasons. – Mario Palumbo Mar 29 '22 at 17:10
  • Did the link I provided help at all? – rand'Chris Mar 29 '22 at 17:12
  • I think you need to chainload the other drive. But the partition with the bootloader is on the same disk (PenDrive) as the partition doing the chainloading, it is only the partition that changes. – Mario Palumbo Mar 31 '22 at 11:17
  • I have tried to chainload (hd1,gpt1), the error is the same. – Mario Palumbo Mar 31 '22 at 14:09
  • @rand'Chris Did the link I provided help at all? No. – Mario Palumbo Mar 31 '22 at 15:59
  • is it time to report the bug to Ubuntu in your opinion? I see there is no solution through the chainloader command. The most obvious ways I have tried them all. – Mario Palumbo Mar 31 '22 at 16:01
  • Unfortunately I provide with a condition that executes the configfile command if the grub.cfg file exists and the chainloader command if it does not exist (as in the case of Windows). I consider this question as unsolved. – Mario Palumbo Mar 31 '22 at 16:04
  • 1
    @MarioPalumbo, rather than issue UPDATE messages, I would suggest you simplify your question and include the complete configuration sections. It is too difficult to understand what your configuration is. The chainloader is used to boot a different boot manager, but you said you're loading something on an NTFS partition and the configuration you show has you trying to chainload something from a FAT32 partition. This makes no sense to me. I think you need to ask about GRUB at the link I provided, as this is not a problem with Ubuntu. – rand'Chris Apr 01 '22 at 01:13
  • https://unix.stackexchange.com/questions/697608/grub2-error-cant-allocate-initrd-chainload-an-ntfs-partition-from-fat32-wit – Mario Palumbo Apr 01 '22 at 08:35
0

For those of you searching for why grub is saying it "can't allocate initrd" after you installed another OS, I found that that the boot order in BIOS was set to load the new OS. Once I unplugged the external drive, it gave me a grub recovery. I had to learn that to get inch grub and it was all for naught.

After painful hours of tearing my hair out, I found the solution thanks to the people over on Hiveon. I hope this saves you hours of searching and pain.