Skip to main content
Topic: grub update is slow - several minutes (Read 826 times) previous topic - next topic
0 Members and 3 Guests are viewing this topic.

grub update is slow - several minutes

both the same
Code: [Select]
home:[root]:/etc/default# grub-mkconfig -o /boot/grub/grub.cfg
home:[root]:/etc/default# update-grub
why so slow?

Code: [Select]
# Probe for other installed operating systems
GRUB_DISABLE_OS_PROBER="false"
-=linux its buggy crap that have no antifool protection (c)=- :)
*linux is free software, and comes with ABSOLUTELY NO WARRANTY* :)
+ALL YOURS ACTIONS at Linux YOU DO at YOUR OWN RISK!+ :)

Re: grub update is slow - several minutes

Reply #1
Fifteen seconds:
Spoiler (click to show/hide)

Re: grub update is slow - several minutes

Reply #2
If you run something like
Code: [Select]
$ ps -ax |grep grub
and perhaps your preferred method to examine running processes if you know of something better while it's being slow, it might help determine what part of grub is causing the delay, because it runs sub-processess, if you could try that and post the output then it might at least help advance the understanding of the problem.

Re: grub update is slow - several minutes

Reply #3

RTFM:

https://wiki.archlinux.org/title/GRUB#GRUB_loads_slowly
https://wiki.archlinux.org/title/Mkinitcpio#Possibly_missing_firmware_for_module_XXXX
"Wer alles kann, macht nichts richtig"

Artix USE="runit openrc slim openbox lxde gtk2 qt4 qt5 qt6 conky
-gtk3 -gtk4 -adwaita{cursors,themes,icons} -gnome3 -kde -plasma -wayland "

Re: grub update is slow - several minutes

Reply #4
If you run something like
Code: [Select]
$ ps -ax |grep grub
and perhaps your preferred method to examine running processes if you know of something better while it's being slow, it might help determine what part of grub is causing the delay, because it runs sub-processess, if you could try that and post the output then it might at least help advance the understanding of the problem.
and what next? sdd1 its new drive, with Fedora
Code: [Select]
home:[root]:/home/freeartist-artix# ps -ax |grep grub
21698 pts/1    S+     0:00 /bin/sh /usr/bin/grub-mkconfig -o /boot/grub/grub.cfg
22050 pts/1    S+     0:00 /bin/sh /etc/grub.d/30_os-prober
22054 pts/1    S+     0:00 /bin/sh /etc/grub.d/30_os-prober
22768 ?        Rs     4:32 grub-mount /dev/sdd1 /var/lib/os-prober/mount
22958 pts/4    S+     0:00 grep --colour=auto grub
home:[root]:/home/freeartist-artix#
UPD
install lsb-rerease at Fedora, same, slow updating grub at Artix
/var/lib/os-prober/mount is empty while grub updating
-=linux its buggy crap that have no antifool protection (c)=- :)
*linux is free software, and comes with ABSOLUTELY NO WARRANTY* :)
+ALL YOURS ACTIONS at Linux YOU DO at YOUR OWN RISK!+ :)

 

Re: grub update is slow - several minutes

Reply #5
Then that's the same as I get on all my Dell laptops, ssd and nvme, with BTRFS on at least some of the partitions. I'm not sure what tintin is doing to avoid it, different hardware, file system? What I found as a workaround is if you mount any partitions that contain the other operating systems before running update-grub it completes at a normal speed, it used to work but has been slow for probably more than a year. If you don't need to boot other operating systems then disabling os-prober works too.

Re: grub update is slow - several minutes

Reply #6
I'm not sure what tintin is doing to avoid it, different hardware, file system?
On this PC (like on the others) I boot in UEFI and only have Linux systems on ext4 partitions:

Spoiler (click to show/hide)


Code: [Select]
$ neofetch --off
jp@jp-artix-Acer
----------------
OS: Artix Linux x86_64
Host: Aspire ES1-732 V1.18
Kernel: 6.6.30-2-lts
Uptime: 1 hour, 6 mins
Packages: 1275 (pacman)
Shell: bash 5.2.26
Resolution: 1600x900
DE: Xfce
WM: Xfwm4
WM Theme: Daloa
Theme: Adwaita [GTK2], Artix-dark [GTK3]
Icons: oxygen [GTK2], breeze [GTK3]
Terminal: xfce4-terminal
Terminal Font: Monospace 12
CPU: Intel Pentium N4200 (4) @ 2.500GHz
GPU: Intel Apollo Lake [HD Graphics 505]
Memory: 2089MiB / 3743MiB

Re: grub update is slow - several minutes

Reply #7
I've found this problem on a Dell M4400 and M4500, BIOS boot and SSD's and Dell E7470 with UEFI boot on an NVME drive. BTRFS could be a likely common link then.

Re: grub update is slow - several minutes

Reply #8
new hdd with ext4 and ntfs partitions,
also on others hdds installed win7, win10, devuan, fedora, any issues with updating grubs on others installed distros
-=linux its buggy crap that have no antifool protection (c)=- :)
*linux is free software, and comes with ABSOLUTELY NO WARRANTY* :)
+ALL YOURS ACTIONS at Linux YOU DO at YOUR OWN RISK!+ :)

Re: grub update is slow - several minutes

Reply #9
grub-mount is some kind of "fuse" thing, with different implementations for different fs types. It has very slow file access times, I did some slightly unscientific tests copying /etc, obviously that will differ for different installs but is likely to be in the same order of magnitude:
Code: [Select]
(DEVUAN DAEDALUS, EXT4)
$ sudo grub-mount /dev/nvme0n1p4 ~/1mnt/
(ARCH LINUX, BTRFS)
$ sudo grub-mount /dev/nvme0n1p5 ~/2mnt/
$ mkdir /tmp/1
$ mkdir /tmp/2
(DEVUAN DAEDALUS, EXT4)
$ time sudo cp -r 1mnt/etc /tmp/1
cp: cannot stat '1mnt/etc/systemd/system/bootlogd.service': No such file or directory
... and more, these are links ...
cp: cannot stat '1mnt/etc/pulse/client.conf.d/01-enable-autospawn.conf': No such file or directory
cp: cannot stat '1mnt/etc/mtab': No such file or directory

real 0m15.366s
user 0m0.015s
sys 0m0.017s

(ARCH LINUX, BTRFS)
$ time sudo cp -r 2mnt/etc /tmp/2
cp: cannot stat '2mnt/etc/mtab': No such file or directory

real 1m43.535s
user 0m0.041s
sys 0m0.026s


Unmounting from the grub-mount's and remounting normally with mount:
$ time sudo cp -r 1mnt/etc /tmp/1

real 0m0.315s
user 0m0.012s
sys 0m0.026s
$ time sudo cp -r mnthome/etc /tmp/2

real 0m0.385s
user 0m0.005s
sys 0m0.010s
That was on my E7470 with an nvme drive (faster than SSD), on my older M4500 with an SSD, times were:
Spoiler (click to show/hide)
On both laptops if I mount only the Arch partition, update-grub finishes quite fast. If I mount only Devuan it is very slow. So there seems to be 2 factors - firstly, grub-mount and it's FUSE implementation is very slow, and extremely slow for certain filesystems like BTRFS. And secondly, it seems to depend on what OS's you are multi-booting and whether grub is capable of quickly identifying it or not, and then has to trawl through lots of files at a snails pace, because the Devuan Beowulf / BTRFS partition had slow access but still doesn't delay os-prober much.

Re: grub update is slow - several minutes

Reply #10
No BTRFS. Tested at all my distrios. Artix update is very slow ~5min, Fedora and Devuan ~1-2min

Artix
Code: [Select]
home:[root]:/home/freeartist-artix# time grub-mkconfig -o /boot/grub/grub.cfg
Generating grub configuration file ...
Found theme: /usr/share/grub/themes/artix/theme.txt
Found linux image: /boot/vmlinuz-linux-lts
Found initrd image: /boot/intel-ucode.img /boot/amd-ucode.img /boot/initramfs-linux-lts.img
Found fallback initrd image(s) in /boot:  intel-ucode.img amd-ucode.img initramfs-linux-lts-fallback.img
Found linux image: /boot/vmlinuz-linux
Found initrd image: /boot/intel-ucode.img /boot/amd-ucode.img /boot/initramfs-linux.img
Found fallback initrd image(s) in /boot:  intel-ucode.img amd-ucode.img initramfs-linux-fallback.img
Warning: os-prober will be executed to detect other bootable partitions.
Its output will be used to detect bootable binaries on them and create new boot entries.
Found Windows 7 on /dev/sda1
Found MS-DOS 5.x/6.x/Win3.1 on /dev/sda6
Found Windows 7 on /dev/sda7
Found Devuan GNU/Linux 5 (daedalus) on /dev/sdb1
Found Windows 10 on /dev/sdc1
Found Windows 10 on /dev/sdc3
Found Fedora Linux 40 (Xfce) on /dev/sdd1
Adding boot menu entry for UEFI Firmware Settings ...
Found memtest86+ image: /boot/memtest86+/memtest.bin
done

real /),m/..355s
user 0m4.846s
sys 0m5.494s
home:[root]:/home/freeartist-artix#

Devuan 5 Daedalus
Code: [Select]
root@home:/home/freeartist-devuan# time update-grub
Generating grub configuration file ...
Found background image: splash.png
Found linux image: /boot/vmlinuz-6.1.0-20-amd64
Found initrd image: /boot/initrd.img-6.1.0-20-amd64
Found linux image: /boot/vmlinuz-6.1.0-18-amd64
Found initrd image: /boot/initrd.img-6.1.0-18-amd64
Found linux image: /boot/vmlinuz-6.1.0-17-amd64
Found initrd image: /boot/initrd.img-6.1.0-17-amd64
Warning: os-prober will be executed to detect other bootable partitions.
Its output will be used to detect bootable binaries on them and create new boot entries.
Found Windows 7 on /dev/sda1
Found MS-DOS 5.x/6.x/Win3.1 on /dev/sda6
Found Windows 7 on /dev/sda7
Found Artix Linux (rolling) on /dev/sdb3
Found Windows 10 on /dev/sdc1
Found Windows 10 on /dev/sdc3
Found Fedora Linux 40 (Xfce) on /dev/sdd1
done

real 1m55.223s
user 0m7.241s
sys 0m7.086s
root@home:/home/freeartist-devuan#

Fedora 40
Code: [Select]
root@fedora:/home/freeartist# sudo time grub2-mkconfig -o /etc/grub2.cfg
Generating grub configuration file ...
Found Windows 7 on /dev/sda1
Found MS-DOS 5.x/6.x/Win3.1 on /dev/sda6
Found Windows 7 on /dev/sda7
Found Devuan GNU/Linux 5 (daedalus) on /dev/sdb1
Found Artix Linux (rolling) on /dev/sdb3
Found Windows 10 on /dev/sdc1
Found Windows 10 on /dev/sdc3
Adding boot menu entry for UEFI Firmware Settings ...
done
9.89user 17.71system 1:07.51elapsed 40%CPU (0avgtext+0avgdata 16000maxresident)k
381131inputs+232outputs (8major+1888008minor)pagefaults 0swaps
root@fedora:/home/freeartist#
-=linux its buggy crap that have no antifool protection (c)=- :)
*linux is free software, and comes with ABSOLUTELY NO WARRANTY* :)
+ALL YOURS ACTIONS at Linux YOU DO at YOUR OWN RISK!+ :)

Re: grub update is slow - several minutes

Reply #11
Probably your Windows partitions using NTFS, they certainly won't be using EXT4 - support for that doesn't exist at all in Windows. I posted a Grub  bug message, it might get fixed eventually - I counted 19 commits on the Grub repo in 2024 so far, don't expect any fast solution unless it turned out to be something simple. For now just mount any problem partitions that cause a delay manually beforehand, or only run update-grub when you have plenty of time to let it complete I guess.

Re: grub update is slow - several minutes

Reply #12
if this grub issue, why its working fast at Devuan that use same grub(not grub2)?
-=linux its buggy crap that have no antifool protection (c)=- :)
*linux is free software, and comes with ABSOLUTELY NO WARRANTY* :)
+ALL YOURS ACTIONS at Linux YOU DO at YOUR OWN RISK!+ :)

Re: grub update is slow - several minutes

Reply #13
1 or 2 minutes isn't fast, it should complete in seconds, this shows Devuan Daedalus grub here:
Code: [Select]
$ time sudo update-grub
Generating grub configuration file ...
Found theme: /usr/share/desktop-base/grub-themes/desktop-grub-theme/theme.txt
Found linux image: /boot/vmlinuz-6.1.0-18-amd64
Found initrd image: /boot/initrd.img-6.1.0-18-amd64
Found linux image: /boot/vmlinuz-6.1.0-10-amd64
Found initrd image: /boot/initrd.img-6.1.0-10-amd64
Warning: os-prober will not be executed to detect other bootable partitions.
Systems on them will not be added to the GRUB boot configuration.
Check GRUB_DISABLE_OS_PROBER documentation entry.
Adding boot menu entry for UEFI Firmware Settings ...
done

real 0m5.513s
user 0m0.045s
sys 0m0.010s
$ sudo nano /etc/default/grub
(uncommented #GRUB_DISABLE_OS_PROBER=false and saved file)
$ time sudo update-grub
Generating grub configuration file ...
Found theme: /usr/share/desktop-base/grub-themes/desktop-grub-theme/theme.txt
Found linux image: /boot/vmlinuz-6.1.0-18-amd64
Found initrd image: /boot/initrd.img-6.1.0-18-amd64
Found linux image: /boot/vmlinuz-6.1.0-10-amd64
Found initrd image: /boot/initrd.img-6.1.0-10-amd64
Warning: os-prober will be executed to detect other bootable partitions.
Its output will be used to detect bootable binaries on them and create new boot entries.
Found Arch Linux on /dev/nvme0n1p5
Found Artix Linux on /dev/nvme0n1p6
Adding boot menu entry for UEFI Firmware Settings ...
done

real 1m35.286s
user 0m0.006s
sys 0m0.005s
$ mkdir 1 2
$ sudo mount /dev/nvme0n1p5 1
$ sudo mount /dev/nvme0n1p6 2
$ time sudo update-grub
Generating grub configuration file ...
Found theme: /usr/share/desktop-base/grub-themes/desktop-grub-theme/theme.txt
Found linux image: /boot/vmlinuz-6.1.0-18-amd64
Found initrd image: /boot/initrd.img-6.1.0-18-amd64
Found linux image: /boot/vmlinuz-6.1.0-10-amd64
Found initrd image: /boot/initrd.img-6.1.0-10-amd64
Warning: os-prober will be executed to detect other bootable partitions.
Its output will be used to detect bootable binaries on them and create new boot entries.
Found Arch Linux on /dev/nvme0n1p5
Found Artix Linux on /dev/nvme0n1p6
Adding boot menu entry for UEFI Firmware Settings ...
done

real 0m5.272s
user 0m0.000s
sys 0m0.012s

The grub-mount FUSE mount implementation results in very slow file access times as I explained before, how slow will vary according to the file system type being read and possibly it's version. Plus you might have different versions of Grub in different distros, some have patches that might alter things too, because the other element is how many files os-prober has to read to determine the info it needs before it quits on success.

Re: grub update is slow - several minutes

Reply #14
i am also have long shutdown stage time at Daedalus,
at log message sdd3(not system, ntfs data partition at new hdd) unmounting,
maybe its the same case?
-=linux its buggy crap that have no antifool protection (c)=- :)
*linux is free software, and comes with ABSOLUTELY NO WARRANTY* :)
+ALL YOURS ACTIONS at Linux YOU DO at YOUR OWN RISK!+ :)