Occasionally os-prober fails to detect other operating systems installed on other disks or partitions. While this might be due to complex issues with the installation or boot, there’s a workaround that usually remedies the issue. In this article, however, I’d like to provide information that actually solves os-prober issues once and for all and provide fundamental understanding of how this extremely popular package functions.
We will look at different approaches based on detecting other UNIX installations (including Linux and MacOS) and other Windows installations (which uses NTFS file system) when os-prober fails.
Let’s consider how os-prober functions first.
How does os-prober work?
os-prober is an impressive solution that detects operating systems and adds them to the GRUB’s boot list. But how does os-prober actually work? Often this package will be confused with things it doesn’t do and it gets a lot of bad reputation for not finding OS installations sometimes. Understanding the way os-prober works will give you more confidence in troubleshooting booting issues with Linux or Windows.
I remember when I first used os-prober and when it detected a bunch of operating systems on my disk I was so amazed. It felt like magic because for some reason I thought it did so without mounting any disks or partitions.
The reality is it’s not magic. os-prober will attempt to mount each disk/partition as read only in order to scan them for operating systems and if Linux, Windows or MacOS installations are found, it will create an additional record in the boot configuration. In doing so, os-prober will exclusively use grub-mount
(this part is critical knowledge) to mount partitions/disks.
Let’s look at os-prober‘s workflow. First of all in a Linux system a disk can’t be read before it is mounted. Unless mounted, a disk (or its partitions) is just a piece of board attached to the computer. No matter how advanced the software is, it needs to be mounted before it can be read.
- So first, os-prober temporarily mounts all the available disks to /var/lib/os-prober
- Then it checks OS directories on them strategically such as /etc
That’s what happens when you run the following command:
grub-mkconfig -o /boot/grub/grub.cfg
And the operating systems which are found will be listed in the Grub boot menu.
To have os-prober activated along with grub-mkconfig command you will need to have the following command line uncommented in the /etc/default/grub file:
#GRUB_DISABLE_OS_PROBER=false
This assumes it is disabled by default.
Introducing grub-mount
os-prober utilizes grub-mount to ensure disks (especially NTFS disks) are mounted only as read-only and never written on. This prevents potential corruption in file system and the disk tables which can be fragile in some cases.
Here is the grub-mount command and its detailed options as a list:
grub-mount [OPTION...] IMAGE1 [IMAGE2 ...] MOUNTPOINT
- -C, –crypto: Mount crypto devices.
- -d, –debug=STRING: Set a debug environment variable.
- -K, –zfs-key=FILE|prompt: Load a ZFS crypto key.
- -r, –root=DEVICE_NAME: Set the root device.
- -v, –verbose: Print verbose messages.
- -?, –help: Display the help list.
- –-usage: Display a short usage message.
- -V, –version: Print the program version.
Usually you don’t have to worry about how partitions or disks are mounted as it all takes place in the background while os-prober detects and adds operating systems. But as you probably know, it often fails to do so as well.
It’s crucial to find out if grub-mount is actually functioning properly to ensure os-prober can mount and detect operating systems under the hood.
Quick Workaround 1: Forcing os-prober to detect other Linux Operating Systems
There is a quick workaround which often succeeds to help os-prober detect other Linux installations which is mounting root partitions of other Linux systems manually before running os-prober or grub-mkconfig (also sometimes used as grub-update).
Typically you would do something like this:
(Replace “dev/nvme0n1p5” with the partition or disk where other Operating System’s root is)
!! Important : Don’t casually mount Windows installations to Linux systems as this can corrupt fragile NTFS file system and your Windows installation.
mount /dev/nvme0n1p5 /mnt
grub-mkconfig -o /boot/grub/grub.cfg
Quick Workaround 2: Forcing os-prober to detect Windows on NTFS file system
Windows typically runs on NTFS file system which is quite outdated in my opinion but that’s another discussion.
You can run the following command, remember to replace your exact partition with the example below such as /dev/nvme0n1XY or dev/sdaX
Note: You will need the ntfs-3g library.
"Carefully" Mounting Windows Partitions or Disks in Linux File Systems
Below you can find the exact commands needed to safely mount a Windows partition from inside a Linux operating system with specific options that are necessary to ensure protecting the Windows OS’ integrity.
Here is what those ntfs-3g and mount options mean: (They basically ensure a secure read-only Windows partition mounting but its quite intriguing to see each option’s function.)
- -t ntfs-3g: This option specifies the file system type to be mounted, which is ntfs-3g in this case. ntfs-3g is a third-party NTFS driver that provides read and write support for NTFS partitions on Linux systems.
- -o ro,noexec,nodev,nosuid: These options specify various mount options for the NTFS file system:
- ro: Mounts the file system in read-only mode, ensuring that no modifications can be made to the files on the NTFS partition.
- noexec: Prevents the execution of binaries or programs from the mounted NTFS partition, enhancing security by disallowing the execution of potentially malicious code.
- nodev: Disables the interpretation of special device files on the NTFS partition, ensuring that no special device files can be created or accessed.
- nosuid: Prevents the execution of setuid programs from the mounted NTFS partition, ensuring that no programs can be executed with elevated privileges.
/dev/sdX#: This is the device file representing the specific NTFS partition you want to mount. You should replace sdX# with the actual device identifier and partition number of the NTFS partition you wish to mount. For example, /dev/sda1 represents the first partition on the first hard disk.
/mnt: This is the mount point directory where you want to mount the NTFS partition. In this example, it is set to /mnt. You can choose a different directory if desired.
sudo mount -t ntfs-3g -o ro,noexec,nodev,nosuid /dev/nvme0n1pX /mnt
grub-mkconfig -o /boot/grub/grub.cfg
Fixing os-prober Problems' Root Causes
In most cases os-prober fails to detect other OS installations because one of its dependencies isn’t functioning properly.
In majority of the cases, fixing os-prober means fixing grub-mount which is one of the major background actors os-prober relies on.
Try to isolate the issue by manually using grub-mount to mount a partition.
sudo grub-mount /dev/nvme0n1p2 /mnt
You might get an error like:
Error: grub-mount: error while loading shared libraries: libfuse3.so.3: cannot open shared object file: No such file or directory
Missing libfuse3.so.3 means this particular library is missing. To confirm you can run a find command on the root directory.
sudo find / -name libfuse3.so.3 2> /dev/null
Last part silences the irrelevent errors such as accessing proc. Most likely nothing will be found because libfuse3 doesn’t exist on your system and that’s most likely because fuse3 isn’t installed.
If we look at the dependencies of grub:
Name : grub
Version : 2:2.06.r591.g6425c12cd-1
Description : GNU GRand Unified Bootloader (2)
Architecture : x86_64
URL : https://www.gnu.org/software/grub/
Licenses : GPL3
Groups : None
Provides : grub-common grub-bios grub-emu grub-efi-x86_64
Depends On : sh xz gettext device-mapper
Optional Deps : freetype2: For grub-mkfont usage [installed]
fuse3: For grub-mount usage
dosfstools: For grub-mkrescue FAT FS and EFI support [installed]
lzop: For grub-mkrescue LZO support
efibootmgr: For grub-install EFI support [installed]
libisoburn: Provides xorriso for generating grub rescue iso using grub-mkrescue
os-prober: To detect other OSes when generating grub.cfg in BIOS systems [installed]
mtools: For grub-mkrescue FAT FS support
You can see that fuse3 is listed as an optional dependency for grub-mount. Even if you have fuse or fuse2 you will want to install this fuse3 grub optional dependency so that grub-mount
can work so that os-prober
can work.
Depending on your Linux distribution you can use one of the following commands:
sudo pacman -S fuse3
sudo apt-get install fuse3
sudo yum install fuse3
sudo zypper install fuse3
sudo dnf install fuse3
You can also compile fuse3 yourself. See Installing AUR Packages.
Once you clear the grub-mount-related issues you will see that it functions properly and you can navigate to your mount point with sudo cd
to confirm, it might not appear in lsblk
output due to permissions. You will also see that os-prober
now works as it should.
sudo grub-mount /dev/nvme0n1p2 /mnt
In my experience, most os-prober fails boil down to issues with executing grub-mount command or dependencies and/or libraries involved such as fuse or libfuse3.
Hopefully, methods above can provide a sensible alternative to manually mounting those partitions so that os-prober can pick them up and add them to GRUB.
18 Comments
I never knew os-prober was mounting disks one by one to scan for operating systems. Very interesting read, well done..
If all else fails manually adding an entry to GRUB is not that hard tbh.
sudo blkid
Identify the UUIDs of the partitions containing other operating systems. Edit your GRUB configuration file, typically located at /etc/grub.d/40_custom, using a text editor:
sudo nano /etc/grub.d/40_custom
Add custom entries for the detected operating systems:
menuentry “Windows 10” {
insmod ntfs
set root=’hd0,msdos1′ # Replace with the appropriate disk and partition (e.g., hd0,msdos2)
chainloader +1
}
then update grub
That’s another way to do it! Unknown results in anxiety so I your method is great also. One can always arch-chroot in case something regarding boot entries breaks, that’s how we learn!
Greetings Sir. I love and hate Linux equally at the same time. My dream is to become a proficient Operating system engineer at Apple HQ @Cupertino. I think MACOSX solutions are a lot more elegant. Thank you for your time to create os-prober explanation tutorial.
You got this!
My problem was solved once I ran sudo mount /dev/sdX /mnt before grub update and it was sufficient but I can see how fixing grub-mount is a more permanent solution and how it can be annoyingly complicated for Windows on NT filesystem!
Saved me some trouble.
Pretty useful info, I’m sincerely thankful.
You’re welcome!
I once mistyped a command, and suddenly, my computer started speaking Klingon.
lol
I was about to give up on fixing my os-prober issue on Deepin, but your post came to the rescue. It’s great to know that the solution is often related to dependencies like fuse3. Your instructions worked like a charm!
Awesome!
Amazing, it finally found my other distro.
thank you
Happy to hear Timo, great news!
this helped me find monjaro in grub opensuse. thank you.
Fantastic Niko! You’re most welcome.
I came here looking for answers, but I have even more questions now. I need to study more.