Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] grub-install gives error: unknown filesystem
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
Goverp
Advocate
Advocate


Joined: 07 Mar 2007
Posts: 2014

PostPosted: Sun Oct 23, 2022 7:05 pm    Post subject: [SOLVED] grub-install gives error: unknown filesystem Reply with quote

Actually, this was me upgrading GRUB 2.02 to release 2.06-r3, having ignored it for ages. But the problem would be at least as confusing to someone hitting it during an installation. ...
This was on my x86_64 system using GPT partitions and an EFI partition. It probably doesn't affect BIOS or MBR setups.

All should have been OK, as the existing configuration was fine and had worked for ages. All I wanted to do was update the GRUB boot manager itself, in my case:
Code:
/boot/efi/EFI/gentoo/grubx64.efi

However,
Code:
ryzen ~ # grub-install
error: unknown filesystem

Oh, and it broke my installation. I had to install and configure rEFInd as a bypass.

It should have worked, my grub partition is setup as per Gentoo handbook. The "info grub" section for "Installation" "using grub-install" says:
Code:
On EFI systems for fixed disk install you have to mount EFI System Partition. If you mount it at '/boot/efi' then you don't need any special arguments:
      # grub-install

It still failed, even if I mounted the EFI partition R/W before starting the command, and specified "--target=x86_64-efi"
I eventually tracked it down to grub-install trying to work out what partitions were in use, and barfing over one. I didn't work out which.

The solutions was to mount the EFI partition r/w and then specify where to install GRUB
Code:
mount /boot/efi -o rw
grub-install --efi-directory=/boot/efi

IIUC this should be what happens by default, but it doesn't work in my case.

As an aside, running "grub-install -v" gives a load of very silly output.
It scans hd0 (in my case) for partitions. Each scan searches for signs of RAID, LVM and stuff. This search is repeated 5 times for each partition. At the end of this process, it decides it knows the partitions start and end (actually, it knew before the first scan, but I guess it wanted to know more about the partition contents). Then it repeats the exact same process twice more. This occurs for each partition. So in total, it scans the partitions 15 times. Perhaps GRUB is just sceptical!
Typical output - the bit that repeats 15 times:
Code:
grub-install: info: Scanning for DISKFILTER devices on disk hd0.
grub-install: info: Scanning for mdraid1x devices on disk hd0.
grub-install: info: Scanning for mdraid09_be devices on disk hd0.
grub-install: info: Scanning for mdraid09 devices on disk hd0.
grub-install: info: Scanning for dmraid_nv devices on disk hd0.
grub-install: info: Scanning for ldm devices on disk hd0.
grub-install: info: scanning hd0 for LDM.
grub-install: info: no LDM signature found.

The output also reveals something going wrong with the installation that might explain why my attempts to use the "starfield" theme failed. I emerged GRUB with "USE=nls", which IIUC should install locale-dependent files. The grub-install log attempts to copy loads of files for a vast range of locales (anybody read Shavian English? I guess it's just iterating over all possible locales), and fails in every case 'cos the GRUB ebuild doesn't create any. Typical example:
Code:
grub-install: info: copying `/usr/share/locale/en_GB/LC_MESSAGES/grub.mo' -> `/boot/grub/locale/en_GB.mo'.
grub-install: info: cannot open `/usr/share/locale/en_GB/LC_MESSAGES/grub.mo': No such file or directory.

It's possible that's because GRUB only ships a weird selection of locale-specific files and just assumes en_US is good enough for en_GB speakers. For comparison, the filelist for the Arch Linux GRUB package includes a selection of locale such as:
Code:
usr/share/locale/de_CH/LC_MESSAGES/grub.mo
usr/share/locale/en@arabic/LC_MESSAGES/grub.mo

but not en_GB or en_US.
_________________
Greybeard
Back to top
View user's profile Send private message
GDH-gentoo
Veteran
Veteran


Joined: 20 Jul 2019
Posts: 1548
Location: South America

PostPosted: Sat Oct 29, 2022 3:15 pm    Post subject: Re: [SOLVED] grub-install gives error: unknown filesystem Reply with quote

I know that this is solved, but the failure mode and apparent solution intrigued me.

Goverp wrote:
The solutions was to mount the EFI partition r/w and then specify where to install GRUB
Code:
mount /boot/efi -o rw
grub-install --efi-directory=/boot/efi

IIUC this should be what happens by default, but it doesn't work in my case.
It should indeed:

grub-2.06/util/grub-install.c
Code:
static char *efidir = NULL;
// ...
int
main (int argc, char *argv[])
{
  int is_efi = 0;
  // ...
  /* Find the EFI System Partition.  */

  if (is_efi)
    {
      grub_fs_t fs;
      // ...
      if (!efidir)
        {
          char *d = grub_util_path_concat (2, bootdir, "efi");
          char *dr = NULL;
          if (!grub_util_is_directory (d))
            {
              free (d);
              d = grub_util_path_concat (2, bootdir, "EFI");
            }
          /*
            The EFI System Partition may have been given directly using
            --root-directory.
          */
          // ...
          if (grub_util_is_directory (d))
            dr = grub_make_system_path_relative_to_its_root (d);
          /* Is it a mount point? */
          if (dr && dr[0] == '\0')
            efidir = d;
          else
            free (d);
          free (dr);
        }
      if (!efidir)
        grub_util_error ("%s", _("cannot find EFI directory"));

Goverp wrote:
Code:
ryzen ~ # grub-install
error: unknown filesystem
This error appears to happen later, in the call to grub_fs_probe():

grub-2.06/util/grub-install.c
Code:
  if (is_efi)
    {
      grub_fs_t fs;
      free (install_device);
      install_device = NULL;
      if (!efidir)
        {
          //...
        }
      if (!efidir)
        grub_util_error ("%s", _("cannot find EFI directory"));
      efidir_device_names = grub_guess_root_devices (efidir);
      if (!efidir_device_names || !efidir_device_names[0])
        grub_util_error (_("cannot find a device for %s (is /dev mounted?)"),
                             efidir);
      install_device = efidir_device_names[0];

      for (curdev = efidir_device_names; *curdev; curdev++)
          grub_util_pull_device (*curdev);
     
      efidir_grub_devname = grub_util_get_grub_dev (efidir_device_names[0]);
      if (!efidir_grub_devname)
        grub_util_error (_("cannot find a GRUB drive for %s.  Check your device.map"),
                         efidir_device_names[0]);

      efidir_grub_dev = grub_device_open (efidir_grub_devname);
      if (! efidir_grub_dev)
        grub_util_error ("%s", grub_errmsg);

      fs = grub_fs_probe (efidir_grub_dev);
      if (! fs)
        grub_util_error ("%s", grub_errmsg);
      // ...
    }
grub-2.06/grub-core/kern/fs.c
Code:
grub_fs_t
grub_fs_probe (grub_device_t device)
{
  grub_fs_t p;

  if (device->disk)
    {
      // ...
    }
  else if (device->net && device->net->fs)
    return device->net->fs;

  grub_error (GRUB_ERR_UNKNOWN_FS, N_("unknown filesystem"));
  return 0;
}
Which would mean that efidir was not a null pointer, and that the calls to grub_guess_root_devices(), grub_util_get_grub_dev() and grub_device_open() succeeded.

There's an utility that follows a very similar code path, but does not install anything: grub-probe.

Code:
# mount /boot/efi -o rw
# grub-probe --target=drive /boot/efi
This should do the grub_guess_root_devices() - grub_util_pull_device() - grub_util_get_grub_dev() sequence, succeed, and print something like (hostdisk//dev/something,gptn), and:

Code:
# grub-probe --target=fs /boot/efi
should do the grub_guess_root_devices() - grub_util_pull_device() - grub_util_get_grub_dev() - grub_device_open() - grub_fs_probe() sequence, and either succeed and print "fat", or fail and print the "unknown filesystem" error that grub-install prints.
_________________
NeddySeagoon wrote:
I'm not a witch, I'm a retired electronics engineer :)
Ionen wrote:
As a packager I just don't want things to get messier with weird build systems and multiple toolchains requirements though :)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum