GRUB4DOS (EFI) is slower than GRUB4DOS
Closed this issue · 10 comments
Hi,
I noticed, that GRUB4DOS (EFI) is much slower than GRUB4DOS.
I did some tests with 2 different USB sticks and 3 different computers. I booted the following ISOs using GRUB4DOS and GRUB4DOS (EFI):
- Acronis True Image 2021
- ESET SysRescue 1.0.23
- Kaspersky Rescue Disk 2018
- Knoppix 9.1
- Memtest86 7.5
With each computer and each USB stick GRUB4DOS (EFI) was much slower than GRUB4DOS. So I think there is an issue in GRUB4DOS (EFI). I noticed differences in speed with these commands: map, font, configfile, kernel.
Additionally the map command like this
GRUB4DOS (EFI):
map %iso% (0xff)
or in GRUB4DOS:
map %iso% (0xff) || map --mem %iso% (0xff)
map --hook
is very slow for some ISO, but only in GRUB4DOS (EFI). The map command in GRUB4DOS is always fast. Strangely the map command takes longer for smaller ISOs to complete than for larger ISOs:
670 MB took about 20 minutes for the map command:
title Acronis True Image 2021
# https://download.acronis.com/AcronisTrueImage2021.iso
set iso=/Acronis-True-Image-2021.iso
find --set-root %iso%
map %iso% (0xff)
root (0xff)
kernel /dat10.dat quiet force_modules=usbhid lang=de_DE.UTF-8
initrd /dat11.dat /dat12.dat
4.4 GB took less than a minute for the map command:
title Knoppix 9.1
# https://www.knopper.net/knoppix-mirrors/
set isoFile=Knoppix-9.1.iso
set iso=/%isoFile%
find --set-root %iso%
map %iso% (0xff)
root (0xff)
kernel /boot/isolinux/linux64 bootfrom=%isoFile% lang=de apm=power-off nomce hpsa.hpsa_allow_any=1 loglevel=1
initrd /boot/isolinux/minirt.gz
Finally there is something strange with Win10XPE:
title Win10XPE (Windows 11, 22H2) (efi, working)
# https://github.com/ChrisRfr/Win10XPE
set iso=/Win10XPE-Windows-11-22H2.iso
find --set-root %iso%
map %iso% (0xff)
chainloader (0xff)
After the chainloader the ISOs read data from ??? (no idea from where). These loading is slower, if you are using GRUB4DOS (EFI).
It would be great to see GRUB4DOS (EFI) with the same speed as GRUB4DOS. Thanks.
Please provide Acronis-True-Image-2021.iso, as the online sizes are different.
Sorry, the size was a typo error, the correct size is 690 MB. But there was also an update from True Image 2021, build 39216 to True Image 2021, build 39287. They fixed some bugs, but the loading times are unaffected.
MD5 of build 39287:
462cf0c7691bbb990a934adc62b2bb6b Acronis-True-Image-2021.iso
The second slowest part in GRUB4DOS (EFI) is the loading of the font file
font /EFI/grub/unifont_all-15.0.04.hex.gz
# http://unifoundry.com/unifont/
1.5 MB takes several minutes to load. Since a nice font is optional, I just don't use this feature and commented it out.
I was able to test GRUB4DOS (EFI) with another USB stick, a SanDisk Cruzer Blade 64GB. This stick supports only USB 2.0, while my other tested sticks are USB 3.0 or USB 3.1.
The USB 3.x sticks are faster then the USB 2.0 stick if used in Windows or Linux, that was expected. But in GRUB4DOS (EFI) it is reversed: The USB 2.0 stick is much faster then my USB 3.x sticks.
Same partition layout (GPT, ISOs on NTFS) and same configuration for GRUB4DOS (EFI).
I also tested Ventoy. It is also slow when using EFI. That was the reason I tried GRUB4DOS (EFI) and adapted my old configuration for it.
Any idea how to find the cause of these speed differences?
USB 3 drives have two sets of connectors inside them. One is for USB 3 and the other is USB 2. You can thus simply connect a USB 3 drive to a USB 2 port and it will appear as a USB 2 drive to software hardware OR you can connect the USB 3 drive to a USB 3 port but using a USB 2 extension cable - so this will also appear as a USB 2 drive.
Measure times using the same USB 3 drive:
Time taken to boot xxx.iso using grub4efi on USB 3 drive = ???
Time taken to boot xxx.iso using grub4efi on USB 3 drive connected to a USB 2 port = ???
Note that NTFS is generally half the speed of FAT.
Also note that access from grub will be transferring a small number of sectors at a time - it does not do fast, synchronous bulk transfers as used by Windows. So a USB 3 flash drive may well be slower than a USB 2 drive - it just depends on their internal controller chip and thus their 4K I/O rd/wr benchmark score.
Some 'superfast' USB 3 drives I have tested in Crystal DiskMark have had very bad 4K I/O speeds (even though their sequential rd/wr scores were very high). So you cannot compare USB 2 drives with USB 3 drives because it is dependant on what controller has been used inside each device and how they perform for small block transfers.
Thanks. I made more tests.
Attached is the result from Crystal DiskMark using a USB 2.0 port and using a USB 3.0 port.
We can see that the stick is faster using USB 3.0.
I think we have several problems in GRUB4DOS (UEFI):
-
While the overall speed in GRUB4DOS (UEFI) is slower than using GRUB4DOS (no UEFI) some ISOs are extreme slow. For example Acronis-True-Image-2021.iso
MD5: 462cf0c7691bbb990a934adc62b2bb6b
Download: https://download.acronis.com/AcronisTrueImage2021.iso
It seems to first slowly scan the complete file until it detects the file system ("Filesystem type is ..., using whole disk" is printed). For other ISOs like Knoppix or Kaspersky Rescue it detects the file system almost instantly. So there is probably an issue with this ISO. Here are the times to load the ISO:
10 minutes, 34 seconds using the USB 3.0 port
11 minutes, 26 seconds using the USB 2.0 port -
The slow loading of font files. I used this file
http://unifoundry.com/pub/unifont/unifont-15.0.06/font-builds/unifont_all-15.0.06.hex.gz
and extracted and renamed it and used this configuration to load it:
color white/blue white/cyan
timeout 5
default 3
graphicsmode -1
font /EFI/grub/unifont.hex
The font file is only 7.7 MB, but it takes very long to load:
11 minutes, 45 seconds using the USB 3.0 port
12 minutes, 10 seconds using the USB 2.0 port
I started the measurement when GRUB4DOS displays the text about loading the menu.lst and stopped once the menu was shown. Comment out the font line and the menu is shown instantly.
unifont.hex can be compressed using LZMA which grub4efi/grub4dos can decompress. It makes for much faster loading.
unifont.hex.gz
576KB !!!!
I already tried using the compressed font file. The speed is almost the same. I thought there could be a bug in the decompression so I decompressed the file first.
File sizes:
unifont.hex (8122052 bytes)
unifont.hex.gz (1553230 bytes)
Times using USB 3.0:
unifont.hex = 11 minutes, 45 seconds = 11.25 KB/s
unifont.hex.gz = 2 minutes, 34 seconds = 9.84 KB/s
You need a better usb drive.
Mine loads in a second or two.
I recommend SanDisk Extreme pro usb 3.1 drives
Thanks.
As the USB stick (Kingston DataTraveler Max) and my pc at the office (some powerful PC from Lenovo) are brand new, I will contact their support to answer these questions:
- Kingston: Why is the Kingston DataTraveler Max, the fastest USB stick from Kingston so slow, when used with GRUB4DOS (EFI)?
- Lenovo: Why are my 2 USB 3.x sticks from Kingston so much slower than this old USB 2.0 stick from SanDisk (which actually was a promotional gift!) when booting GRUB4DOS (EFI)?
I think the problem is the UEFI in my laptop and the pc, because both USB sticks are really fast in Linux, Windows and the normal GRUB4DOS (no EFI). I also can't imagine that you added some kind of "speed reducer" in GRUB4DOS (EFI).
Answer from Lenovo:
Thank you for contacting Lenovo Premier Support.
Be advised that Secure Boot may cause some lags in the speed at which bootable USB sticks load. Although this security feature is useful for guarding against malicious software, it also takes time to verify the integrity of the boot process when using external devices like USB sticks.
It is advised to momentarily turn off Secure Boot if you suffer long wait times and require a speedier USB stick booting experience. Turning off Secure Boot may trigger the Bitlocker encryption.
Answer from Kingston:
Thank you for query with Kingston Technology.
Please note that following the right instructions, a standard USB drive can theoretically be converted into bootable drive.
This may work for some USB drives, for others it may not, as there are a number of dependencies need to be taken into account.A standard USB drive is designed for sequential read and writes, rather than random read and write speeds which apply in case the USB stick is being used as a bootable device.
Kingston designs and tests its USB flash drives for their suitability to be used as a standard USB product for sequential workloads.Therefore, we cannot guarantee the longevity and reliability nor the functionality of a product which has been converted into a bootable drive.
Because both answers were not satisfying, I did more tests.
I copied the same ISO files and the same boot files e.g. BOOTX64.EFI (version = grub4dos-for_UEFI-2023-10-13) to 3 different USB drives:
- Kingston HyperX Savage USB 3.1 (512 GB)
- Kingston DataTraveler Max USB 3.2 (1 TB)
- SanDisk Cruzer Blade (64 GB)
GRUB4DOS (EFI) is as fast as GRUB4DOS using the USB drives (1) and (3). GRUB4DOS (EFI) is extreme slow using the USB drive (2). The USB drive (2) is fast too (proven by Crystal DiskMark) but not in GRUB4DOS (EFI).
Conclusion: GRUB4DOS (EFI) is fine. It is as fast as GRUB4DOS. But some USB drives do not work very well with GRUB4DOS (EFI).