Discussion:
Virtualbox EFI won't find grub64.efi
Add Reply
Marco Moock
2025-03-07 19:54:21 UTC
Reply
Permalink
Hello!

I want to install Slackware 15 64 in VBox in EFI mode.
Installation was possible, but the VBox EFI won't boot the installed
grub, but the grub from the install image. From that I can use "Detect
installed OS" to start the installed GRUB and then boot the installed
OS.

After installation, I chrooted to /mnt and ran

grub-install
grub-mkconfig -o /boot/grub/grub.cfg

Number Start (sector) End (sector) Size Code Name
1 2048 104447 50.0 MiB EF00 EFI system partition
2 104448 514047 200.0 MiB 8300 Linux filesystem
3 514048 82399390 39.0 GiB 8300 Linux filesystem

Command (? for help): i 1
Partition number (1-3): 1
Partition GUID code: C12A7328-F81F-11D2-BA4B-00A0C93EC93B (EFI system partition)
Partition unique GUID: 695D28D3-05E4-49D9-97A1-04DC6423B7E4
First sector: 2048 (at 1024.0 KiB)
Last sector: 104447 (at 51.0 MiB)
Partition size: 102400 sectors (50.0 MiB)
Attribute flags: 0000000000000000
Partition name: 'EFI system partition'


***@test:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 39.3G 0 disk
├─sda1 8:1 0 50M 0 part /boot/efi
├─sda2 8:2 0 200M 0 part /boot
└─sda3 8:3 0 39G 0 part /
sr0 11:0 1 3.5G 0 rom
***@test:~#

***@test:~# efibootmgr
BootCurrent: 0001
Timeout: 0 seconds
BootOrder: 0004,0000,0001,0002,0003
Boot0000* UiApp FvVol(7cb8bdc9-f8eb-4f34-aaea-3ee4af6516a1)/FvFile(462caa21-7614-4503-836e-8ab6f4662331)
Boot0001* UEFI VBOX CD-ROM VB2-01700376 PciRoot(0x0)/Pci(0x1,0x1)/Ata(1,0,0){auto_created_boot_option}
Boot0002* UEFI VBOX HARDDISK VB09d072f0-0e6959c6 PciRoot(0x0)/Pci(0xd,0x0)/Sata(0,65535,0){auto_created_boot_option}
Boot0003 EFI Internal Shell FvVol(7cb8bdc9-f8eb-4f34-aaea-3ee4af6516a1)/FvFile(7c04a583-9e3e-4f1c-ad65-e05268d0b4d1)
Boot0004* slackware-15.0 HD(1,GPT,695d28d3-05e4-49d9-97a1-04dc6423b7e4,0x800,0x19000)/File(\EFI\slackware-15.0\grubx64.efi)

***@test:~# ls -la /boot/efi/EFI/slackware-15.0/grubx64.efi
-rwxr-xr-x 1 root root 139264 Mar 7 20:25 /boot/efi/EFI/slackware-15.0/grubx64.efi*
***@test:~#

The grub executable exists, although VirtualBox complains it can't find it.
If I want to select "boot from file", it shows an empty page, so I assume it doesn't even detect the EFI partition. It is usable when the ISO is inserted and shows the content of its EFI folder.

Does anybody have an idea what is going wrong and if that is an issue in VirtualBox or in Slackware/GRUB?
--
kind regards
Marco

Send spam to ***@stinkedores.dorfdsl.de
Henrik Carlqvist
2025-03-08 11:54:37 UTC
Reply
Permalink
Post by Marco Moock
Does anybody have an idea what is going wrong and if that is an issue in
VirtualBox or in Slackware/GRUB?
No, I have never booted Slackware 15.0 with GRUB and I have never used
VirtualBox.

However, if it would be to any use for you I have successfully booted
Slackware 15.0 in EFI mode both on pysical hardware and on virtual
machines run in qemu. Instead of GRUB I use syslinux/extlinux but I do
not use syslinux 4.07 which is shipped with Slackware, instead I use
Syslinux version 6.03. I have used the same method also on earlier
version 14.2 of Slackware.

Unfortunately my Slackware installation is heavily customized, I have
modified the installation initrd startup and installation scripts to
automagically create all partitions needed before starting an
installation with a minimal number of questions.

On the first version of Slackware where I applied this boot method I did
not have the automated custimization of the partitioning, then I simply
manually created a GPT partition table with all the partitions I wanted
including an EFI partition which I mounted below /boot/efi. I then had a
package containing an installation script and the needed syslinux files:

drwxr-xr-x root/root 0 2021-01-14 12:45 ./
drwxr-xr-x root/root 0 2020-09-30 22:45 boot/
drwxr-xr-x root/root 0 1970-01-01 01:00 boot/efi/
drwxr-xr-x root/root 0 2021-01-14 12:35 boot/efi/EFI/
drwxr-xr-x root/root 0 2023-03-29 12:23 boot/efi/EFI/Boot/
-rwxr-xr-x root/root 199952 2020-09-30 21:31 boot/efi/EFI/Boot/
bootx64.efi
-rwxr-xr-x root/root 139968 2020-09-30 21:31 boot/efi/EFI/Boot/
ldlinux.e64
-rwxr-xr-x root/root 256 2023-03-29 12:23 boot/efi/EFI/Boot/
syslinux.cfg
drwxr-xr-x root/root 0 2023-03-29 12:22 install/
-rw-r--r-- root/root 494 2023-03-29 12:21 install/doinst.sh

The files bootx64.efi and ldlinux.e64 are from Syslinux 6.03.

The installation script doinst.sh contains the following:

-8<----------------------------------------------------------
#!/bin/sh

if [ -f /var/log/setup/tmp/SeTrootdev ]; then
rootpart=`cat /var/log/setup/tmp/SeTrootdev`
else
rootpart=`grep "/ " etc/fstab | awk '{print $1}'`
fi
bootdev=`grep boot etc/lilo.conf | grep dev | awk '{print $NF}'`
echo " APPEND root=$rootpart rdinit=ro intel_pstate=disable" >> boot/
efi/EFI/Boot/syslinux.cfg
./usr/sbin/efibootmgr -c -d $bootdev -p 3 -l \\EFI\\Boot\\bootx64.efi -L
"Syslinux"
# Make sure that kernel is up-to-date
cp -p boot/vmlinuz boot/efi/EFI/Boot/vmlinuz
-8<----------------------------------------------------------

The above script assumes that my custom installation has made an attempt
to configure a lilo.conf which will not be used. This is to find the boot
disk which typically is called something like /dev/sda or /dev/nvme0n1.
The script adds a line pointing to the right root partition to
syslinux.cfg before calling efibootmgr to point the UEFI BIOS to the boot
disk and syslinux bootx64.efi file.

Before being modified the syslinux.cfg file looks like this:

-8<----------------------------------------------------------
PROMPT 0
TIMEOut 100
DEFAULT Slackware 15.0

LABEL Slackware 15.0
MENU LABEL Slackware 15.0
LINUX vmlinuz
# example of what needs to get added to this file:
# APPEND root=/dev/nvme0n1p2 rdinit=ro pci=nommconf
# Such a line will be added by doinst.sh
-8<----------------------------------------------------------

So this did not answer your question upon how to install GRUB which I
have avoided myself. I am aware that syslinux is considered abandonware,
but it still works for me and I find the synax of syslinux rather
familiar. I have during the years used configuration files with such
syntax not only to boot UEFI systems but also to boot optical media and
PXE network booting.

regards Henrik
root
2025-03-08 16:52:59 UTC
Reply
Permalink
Post by Henrik Carlqvist
However, if it would be to any use for you I have successfully booted
Slackware 15.0 in EFI mode both on pysical hardware and on virtual
I spent a lot of time trying to get Slackware 15.0 installed on
the only UEFI system I have. I tried so many things that when
I finally got something to work I couldn't remember the exact
steps I followed. Over the course of my efforts I tried to
install both Debian and Ubuntu each of which succeded. I
then I noticed that the EFI partition had both Debian and
Ubuntu stuff in it.

Henrik, do you format the EFI partition as vfat before starting
the install? As far as I can remember I never did that.
That would explain all my problems if the Slackware install
expected that the efi partition was formatted, and later
while booting the system could not find a vfat partition to
read.

Thanks.
jayjwa
2025-03-08 18:20:31 UTC
Reply
Permalink
Post by root
Henrik, do you format the EFI partition as vfat before starting
the install? As far as I can remember I never did that.
Many machines will have an EFI service partition on them when you get
them. I don't recall having to make one because this system had Windows
on it previously. If there is not one, or it gets erased, you can
recreate it. It needs be a FAT32 system. To my memory, the partition
type has to be "EF" and the partition table should be type GPT.

fdisk -l /dev/sda

Disk /dev/sda: 931.51 GiB, 1000204886016 bytes, 1953525168 sectors
Disk model: WDC WD10EZEX-08W
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 5ADB41A7-7604-419D-A43A-4F9135D120E8

Device Start End Sectors Size Type
/dev/sda1 2048 534527 532480 260M EFI System
/dev/sda2 534528 1049110527 1048576000 500G Linux filesystem
/dev/sda3 1049110528 1468540927 419430400 200G Linux filesystem
/dev/sda4 1468540928 1887971327 419430400 200G Linux filesystem
/dev/sda5 1887971328 1953525134 65553807 31.3G Linux swap

lsblk -f
NAME FSTYPE FSVER LABEL UUID FSAVAIL FSUSE% MOUNTPOINTS
sda
├─sda1 vfat FAT32 SYSTEM 608B-0B83 238.6M 7% /boot/efi
├─sda2 ext4 1.0 2b909491-fbe9-4301-b583-913820597d92 265G 41% /
├─sda3 xfs 60c59f42-a1f1-46c2-bf8e-d9af83c303ce 67.5G 66% /home
├─sda4 xfs 7aa264bd-a6fa-450b-a21d-c255c8c14964 193.7G 3% /srv
└─sda5 swap 1 6f331c1c-da54-4c02-93fb-dad38ee610d2 [SWAP]
sr0
zram0
[SWAP]

I'm using Current with Grub. Previously I used Elilo, but it stopped
booting kernels about version 6.1.x or so. Elilo needs the kernel with
it in the ESP, Grub can "see" into the Linux partitions to grab the
kernel so it doesn't require the kernel with the bootloader.

ls -l /boot/efi/EFI/slackware-15.0+/
total 136
-rwxr-xr-x 1 root root 139264 Jun 24 2024 grubx64.efi*

I haven't booted Linux in a virtual machine, but I've used other
EFI-booting systems from QEMU. If you have everything setup correctly
and Virtual Box isn't working, try QEMU.
--
PGP Key ID: 781C A3E2 C6ED 70A6 B356 7AF5 B510 542E D460 5CAE
"The Internet should always be the Wild West!"
root
2025-03-09 03:48:35 UTC
Reply
Permalink
jayjwa <***@atr2.ath.cx.invalid> wrote:

Thanks for responding, in all my efforts I have been trying
to install 15.0 on something that had no prior OS: bare metal.
Henrik Carlqvist
2025-03-09 15:04:13 UTC
Reply
Permalink
Henrik, do you format the EFI partition as vfat before starting the
install?
The formatting is done during the install in my heavily customized
isolinux/initrd.img I have changed /bin/startup.sh to:

-8<-----------------------------
#!/bin/sh
#/bin/network
/bin/partition
-8<-----------------------------

Where /bin/partition is my own custom script containing:
-8<-----------------------------
#!/bin/sh

export MBR_DEVICE=/dev/`cat /proc/partitions | grep " 0 " | grep -v -E
"ram0|fd0|sr0" | head -1 | awk '{print $4}'`
if [ -d /sys/firmware/efi ]; then
PART_TYPE=GPT
else
PART_TYPE=MBR
fi
dialog --title "Partitions" \
--yesno "Do you want to use standard partition sizes (${PART_TYPE}
)?" \
5 55
if [ $? = 0 ]; then
export PART_DEVICE=$MBR_DEVICE
if [ -d /sys/firmware/efi ]; then
/usr/sbin/parted -s $PART_DEVICE mklabel gpt
/usr/sbin/parted -s $PART_DEVICE mkpart root ext4 65536s 3600MB
/usr/sbin/parted -s $PART_DEVICE mkpart swap linux-swap 3600MB 41400MB
/usr/sbin/parted -s $PART_DEVICE mkpart efi fat32 41400MB 44GB
/usr/sbin/parted -s $PART_DEVICE set 3 esp on
/usr/sbin/parted -s $PART_DEVICE mkpart dummy fat32 44GB 44GB
/usr/sbin/parted -s $PART_DEVICE mkpart usr ext4 44GB 106GB
/usr/sbin/parted -s $PART_DEVICE mkpart opt ext4 106GB 118GB
/usr/sbin/parted -s $PART_DEVICE mkpart var ext4 118GB 138GB
/usr/sbin/parted -s $PART_DEVICE mkpart tmp ext4 138GB 148GB
else
(echo o; \
echo n; \
echo p; \
echo 1; \
echo; \
echo +3600M; \
echo a; \
echo n; \
echo p; \
echo 2; \
echo; \
echo +37800M; \
echo t; \
echo 2; \
echo 82; \
echo n; \
echo e; \
echo 3; \
echo; \
echo; \
echo n; \
echo; \
echo +62000M; \
echo n; \
echo; \
echo +12000M; \
echo n; \
echo; \
echo +20000M; \
echo n; \
echo; \
echo +10000M; \
echo w) | fdisk $PART_DEVICE
fi
/usr/lib/setup/setup
else
echo Create your partitions manually, then run setup!
echo First do \". /etc/profile\", then run \"fdisk\" and finally \"setup
\"
/bin/sh -
fi
-8<-----------------------------

The above custom script was written for me a few years ago, intended for
Slackware 15.0. I was then in the belief that lilo would be unable to
boot from a GPT partition table, but by coincidence I have found that
lilo at least on some systems are able to boot also from GPT partitions.

My customezed usr/lib/setup/setup continues with a minimum of questions
and calls a customized SeTEFI:

-8<------------------------------
#!/bin/sh
TMP=/var/log/setup/tmp
T_PX="`cat $TMP/SeTT_PX`"
if [ ! -d $TMP ]; then
mkdir -p $TMP
fi

# If the kernel does not support EFI, then we shouldn't be trying to
mount an
# EFI partition. If we do, probably the only device found with an EFI
structure
# will be the installer, which we don't want added to /etc/fstab.
if [ ! -d /sys/firmware/efi ]; then
exit
fi

rm -f $TMP/SeTefipartitions
touch $TMP/SeTefipartitions

# Scan for EFI partitions:
# The UEFI specification states that an EFI System partition should have
# a GUID of C12A7328-F81F-11D2-BA4B-00A0C93EC93B for a GPT disk layout.
# In case of a MBR disk layout instead, an ESP should have an OS type of
# 0xEF. lsblk writes these values in the same field: PARTTYPE.
ESPGUID=C12A7328-F81F-11D2-BA4B-00A0C93EC93B
OSTYPE=0xEF
lsblk -l -o parttype,name | \
grep -i -F -e "$ESPGUID" -e "$OSTYPE" | \
sed "s,[^ ]*[ ]*,/dev/," > $TMP/SeTefipartitions

if [ ! -s $TMP/SeTefipartitions ]; then # No EFI partitions
rm -f $TMP/SeTefipartitions
exit
fi

# Initially, we will just take the first EFI partition found, which
# will probably be on /dev/sda:
PREFERRED_EFI_PARTITION="$(cat $TMP/SeTefipartitions | head -n 1)"

# But we will also test to see if there is an EFI partition on the same
# device as the root partition, and if so, prefer that:
if [ -r $TMP/SeTrootdev ]; then
if grep -q "$(cat $TMP/SeTrootdev | cut -b 1-8)" $TMP/
SeTefipartitions ; then
PREFERRED_EFI_PARTITION="$(grep "$(cat $TMP/SeTrootdev | cut -b 1-8)"
$TMP/SeTefipartitions | head -n 1)"
fi
fi

# This file is no longer needed:
rm -f $TMP/SeTefipartitions

# See if EFI partition is formatted. If not, offer to format it:
EFITMPMOUNT=$(mktemp -d)
if ! mount $PREFERRED_EFI_PARTITION $EFITMPMOUNT 1> /dev/null 2> /dev/
null ; then
# It didn't mount, so it must not be formatted:
# dialog --title "FORMAT EFI PARTITION ${PREFERRED_EFI_PARTITION}?" \
# --yesno "An EFI System Partition was found on
${PREFERRED_EFI_PARTITION}, \
#but it has not yet been formatted. Would you like to format this
partition?" \
#7 56
# if [ ! $? = 0 ]; then
# exit
# fi
# Format the partition with FAT32, 2 sectors per cluster (needed for the
# minimum supported EFI partition size of 100MB):
# dialog --title "FORMATTING EFI PARTITION ${PREFERRED_EFI_PARTITION}" --
infobox \
# "Formatting EFI System Partition ${PREFERRED_EFI_PARTITION} as FAT32."
3 60
mkfs.vfat -F 32 -s 2 ${PREFERRED_EFI_PARTITION} 1> /dev/null 2> /dev/
null
sleep 1
mount ${PREFERRED_EFI_PARTITION} $EFITMPMOUNT 1> /dev/null 2> /dev/null
fi
if [ ! -d $EFITMPMOUNT/EFI -a ! -d $EFITMPMOUNT/efi ]; then
mkdir $EFITMPMOUNT/EFI 1> /dev/null 2> /dev/null
fi
umount $PREFERRED_EFI_PARTITION 1> /dev/null 2> /dev/null
rmdir $EFITMPMOUNT

# Mount the partition on ${T_PX}/boot/efi:
if [ ! -d ${T_PX}/boot/efi ]; then
mkdir -p ${T_PX}/boot/efi
fi
mount ${PREFERRED_EFI_PARTITION} ${T_PX}/boot/efi 1> /dev/null 2> /dev/
null

# Add the EFI System Partition to /etc/fstab:
printf "%-16s %-16s %-11s %-16s %-3s %s\n" "$PREFERRED_EFI_PARTITION" "/
boot/efi" "vfat" "defaults" "1" "0" > $TMP/SeTEFI
cat << EOF > $TMP/tempmsg

Adding this information to your /etc/fstab:

EOF
cat $TMP/SeTEFI >> $TMP/tempmsg
#dialog --backtitle "Finished setting up EFI System Partition." \
#--title "EFI SYSTEM PARTITION RECOGNIZED" \
#--exit-label OK \
#--textbox $TMP/tempmsg 10 72

# Piggyback this fstab addition on the other native partitions in
SeTnative:
cat $TMP/SeTEFI >> $TMP/SeTnative
rm -f $TMP/SeTEFI $TMP/tempmsg

# Done.
-8<------------------------------

This customized SeTEFI calls mkfs.vfat -F 32 -s 2 on the EFI partition.

My customezed installation is intended for non dual boot systems, so I
allow my script to allways reformat the EFI partition without any
questions asked.

regards Henrik
root
2025-03-09 16:16:05 UTC
Reply
Permalink
Post by Henrik Carlqvist
My customezed installation is intended for non dual boot systems, so I
allow my script to allways reformat the EFI partition without any
questions asked.
regards Henrik
Thanks Henrik.
Marco Moock
2025-03-09 18:26:00 UTC
Reply
Permalink
Post by Henrik Carlqvist
However, if it would be to any use for you I have successfully booted
Slackware 15.0 in EFI mode both on pysical hardware and on virtual
machines run in qemu. Instead of GRUB I use syslinux/extlinux but I
do not use syslinux 4.07 which is shipped with Slackware, instead I
use Syslinux version 6.03. I have used the same method also on
earlier version 14.2 of Slackware.
Was there a special reason to go this way?
--
kind regards
Marco

Send spam to ***@stinkedores.dorfdsl.de
Henrik Carlqvist
2025-03-10 05:40:17 UTC
Reply
Permalink
Post by Marco Moock
Post by Henrik Carlqvist
However, if it would be to any use for you I have successfully booted
Slackware 15.0 in EFI mode both on pysical hardware and on virtual
machines run in qemu. Instead of GRUB I use syslinux/extlinux but I do
not use syslinux 4.07 which is shipped with Slackware, instead I use
Syslinux version 6.03. I have used the same method also on earlier
version 14.2 of Slackware.
Was there a special reason to go this way?
My main reason for choosing syslinux back then was that I was familiar
with the bootloader since previosly having used it to create bootable
optical media and pxe network booting. I also prefer the syntax of
syslinux configuration files where disks and partitions are named the
same way as the Linux kernel sees them (e g /dev/sda and /dev/sda1)
instead of something like hd0. Another reason for me to avoid GRUB during
the years of MBR booting is that it has required a partition of its own
to boot such systems, LILO has been doing fine without any special
partition.

Today syslinux is considered abandonware, but it still seems to be
working fine booting UEFI systems for me and I have kept using this
method. The day it stops working I will need to replace it. Maybe I will
reluctantly replace it with grub, maybe I will replace it with something
else like limine.

regards Henrik

Loading...