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:

menuentryin the grub.cfg? is there anything else in the menuentry? – Esther Mar 28 '22 at 17:54/efi/boot/bootx64.efi? Can you boot to the second partition directly from the BIOS? – Esther Mar 28 '22 at 18:06lsblkand add to your question. There might be some details there. Also did you try running boot-repair? https://askubuntu.com/questions/1104855/how-to-make-grub-menu-appear-instead-grub-minimal-bash-like-in-booting/1105737#1105737 – WinEunuuchs2Unix Mar 28 '22 at 22:22grub.cfgfile that I showed, which is that of theFAT32partition, does not contain the menu. Thegrub.cfgthat contains the menu, which is located in theNTFSpartition, I have not shown it, as it is the same as that of default contained within an iso image ofUbuntu 20.04 LTS Desktop 64-bit. – Mario Palumbo Mar 29 '22 at 16:28initrdon the Ubuntu system? – Esther Mar 29 '22 at 16:47debugat the beginning of your grub.cfg on the first grub and in the menuentry of the second grub to see Grub debug messages. – Esther Mar 29 '22 at 17:41lsblkin grub terminal buterror: can't find command 'lsblk'. – Mario Palumbo Mar 31 '22 at 09:06nosplash debug. If you want output from upstart too, add--verbose". I addednosplash debugand the output stays the same (ie it doesn't work) but i didn't understand where I can add--verbose, the answer didn't explain anything. What is anupstart? – Mario Palumbo Mar 31 '22 at 11:01linux /casper/vmlinuz file=/cdrom/preseed/ubuntu.seed nosplash debug ignore_loglevel ---but the output is the same, no rows added. – Mario Palumbo Apr 01 '22 at 08:43cat /path/to/40_customfile. – abu-ahmed al-khatiri Apr 01 '22 at 10:01grub.cfgfile present in theFAT32partition. i not have40_customfile. If you mean the content of grub.cfg, that is present in the question. – Mario Palumbo Apr 01 '22 at 10:05sudo update-gruband then boot it again – abu-ahmed al-khatiri Apr 01 '22 at 11:08boot=casper quiet persistent. – abu-ahmed al-khatiri Apr 01 '22 at 12:09boot=casper quiet persistentin your grub?. – abu-ahmed al-khatiri Apr 01 '22 at 13:08