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:
