Grub install error cannot open directory

Hello,

#1 2016-04-08 14:59:02

mxfm
Member
Registered: 2015-10-23
Posts: 163

[SOLVED] Bootable USB UEFI

Hello,

My problem is that I cannot boot from usb UEFI from computers which do not support option to choose EFI loader upon startup. Since I want to boot from machines without pre-installtion, efibootmgr is not helpful. So far all adivice boil down to copy grub loader to other locations, but it does not help.

Currently, I have following structure in EFI partition (all are grubx64.efi copies):
shell.efi
shellx64.efi
shellx64_v1.efi
shellx64_v2.efi
EFI/Boot/bootx64.efi
EFI/Boot/loader.efi
EFI/Boot/Microsoft/Boot/bootmgfw.efi
EFI/Boot/Microsoft/Boot/bootmgr.efi
EFI/Boot/Microsoft/Boot/bootx64.efi
EFI/Boot/grub/grubx64.efi
EFI/Microsoft/Boot/bootmgfw.efi
EFI/Microsoft/Boot/bootmgr.efi
EFI/Microsoft/Boot/bootx64.efi

Partition layout:

Model: StoreJet Transcend (scsi)
Disk /dev/sdb: 500GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name  Flags
1      1049kB  281MB   280MB   fat16        boot  boot, esp
2      281MB   11.6GB  11.3GB  ext4         root
3      11.6GB  16.9GB  5369MB  ext4         home
4      16.9GB  500GB   483GB   ntfs         ntfs  msftdata

Thanks in advance.

Last edited by mxfm (2016-04-11 06:50:16)

#2 2016-04-08 20:30:21

TheSaint
Member
From: my computer
Registered: 2007-08-19
Posts: 1,517

Re: [SOLVED] Bootable USB UEFI

You should follow the idea of Arch Iso. In all of the cases MBR (legacy mode) and UEFI can live side by side.

Last edited by TheSaint (2016-04-09 12:33:49)


do it good first, it will be faster than do it twice the saint wink

#3 2016-04-09 08:17:40

mxfm
Member
Registered: 2015-10-23
Posts: 163

Re: [SOLVED] Bootable USB UEFI

TheSaint wrote:

You should follow the idea of Arch Iso. In all of the cases MBR (llegacy mode) and UEFI can live side by side.

Can you be more specific? AFAIK MBR and UEFI cannot coexist. In any way, UEFI should work, so it should be fixed instead of fallbaking to MBR.

#4 2016-04-09 08:56:40

Head_on_a_Stick
Member
From: London
Registered: 2014-02-20
Posts: 6,876
Website

Re: [SOLVED] Bootable USB UEFI

mxfm wrote:

AFAIK MBR and UEFI cannot coexist. In any way

You are mistaken.

To use GRUB on a USB stick installation in both UEFI & non-UEFI modes:

# grub-install --target=i386-pc --recheck /dev/sdX
# grub-install --target=x86_64-efi --efi-directory=/boot --removable

This presumes that the ESP is mounted to /boot, replace X with the letter assigned to your USB stick drive.

Last edited by Head_on_a_Stick (2016-04-09 09:07:45)

#5 2016-04-09 12:49:18

TheSaint
Member
From: my computer
Registered: 2007-08-19
Posts: 1,517

Re: [SOLVED] Bootable USB UEFI

I haven’t proposed grub in specific. Better to get to know more details
About grub, it can share the same files (I think) as long as the ESP is mounted on /boot, for the MBR mode. The only difference is the way the BIOS start to read, either from the sector zero or from a recognized file in ESP.


do it good first, it will be faster than do it twice the saint wink

#6 2016-04-09 13:00:16

mxfm
Member
Registered: 2015-10-23
Posts: 163

Re: [SOLVED] Bootable USB UEFI

Head_on_a_Stick wrote:

mxfm wrote:

AFAIK MBR and UEFI cannot coexist. In any way

You are mistaken.

Let’s see.

Head_on_a_Stick wrote:

To use GRUB on a USB stick installation in both UEFI & non-UEFI modes:

# grub-install --target=i386-pc --recheck /dev/sdb

Installing for i386-pc platform.
grub-install: error: cannot open directory `/boot/grub/i386-pc’: No such file or directory.

And if I switch grub package to i686 version, it will complain about missing libraries (32 bit versions I guess).

Head_on_a_Stick wrote:

# grub-install --target=x86_64-efi --efi-directory=/boot --removable

This presumes that the ESP is mounted to /boot, replace X with the letter assigned to your USB stick drive.

grub-install: warning: disk does not exist, so falling back to partition device /dev/sdb1.
grub-install: warning: disk does not exist, so falling back to partition device /dev/sdb1.
grub-install: warning: disk does not exist, so falling back to partition device /dev/sdb1.
grub-install: error: disk `hostdisk//dev/sdb1′ not found.

#7 2016-04-09 13:08:49

Head_on_a_Stick
Member
From: London
Registered: 2014-02-20
Posts: 6,876
Website

Re: [SOLVED] Bootable USB UEFI

Please provide a detailed explanation of all the steps you have taken before running my posted commands.

Start with how you brned the ISO image to the installation media and provide the *exact* steps taken and commands used.

Those commands work just fine on my system:

empty@Arch ~ % sudo grub-install --recheck --target=i386-pc /dev/sda
Installing for i386-pc platform.
Installation finished. No error reported.
empty@Arch ~ % sudo grub-install --target=x86_64-efi --efi-directory=/boot --removable
Installing for x86_64-efi platform.
Installation finished. No error reported.

#8 2016-04-09 13:11:47

Head_on_a_Stick
Member
From: London
Registered: 2014-02-20
Posts: 6,876
Website

Re: [SOLVED] Bootable USB UEFI

mxfm wrote:

And if I switch grub package to i686 version, it will complain about missing libraries (32 bit versions I guess).

What does this mean?

The «target=i386-pc» bit specifies the non-UEFI version of GRUB, it has nothing to do with the system architecture.

#9 2016-04-09 13:27:40

mxfm
Member
Registered: 2015-10-23
Posts: 163

Re: [SOLVED] Bootable USB UEFI

Head_on_a_Stick wrote:

Please provide a detailed explanation of all the steps you have taken before running my posted commands.

Start with how you brned the ISO image to the installation media and provide the *exact* steps taken and commands used.

Those commands work just fine on my system:

empty@Arch ~ % sudo grub-install --recheck --target=i386-pc /dev/sda
Installing for i386-pc platform.
Installation finished. No error reported.
empty@Arch ~ % sudo grub-install --target=x86_64-efi --efi-directory=/boot --removable
Installing for x86_64-efi platform.
Installation finished. No error reported.

Eh, forgot about sudo. Please ignore previous post. I have external USB disk (no ISO image, it is completely irrelevant here) with installed Arch in /dev/sdb2. In /dev/sdb1 I have EFI partition mounted as /boot. Full partition information was provided in the first message.

The problem is follows. I can boot from external USB disk at my computer, but cannot boot from other computers. Installing loader through efibootmgr is not an option, because it requires ‘pre-installation’, but I want to boot from USB disk ‘on fly’, like it is the case with MBR. In this thread I receive advice to install both MBR and UEFI grub loaders (although I don’t quite understand how installing MBR loder will help to fix UEFI loader…)

Regarding the commands. After trying to install i386 I have:

Installing for i386-pc platform.
grub-install: warning: this GPT partition label contains no BIOS Boot Partition; embedding won't be possible.
grub-install: warning: Embedding is not possible.  GRUB can only be installed in this setup by using blocklists.  However, blocklists are UNRELIABLE and their use is discouraged..
grub-install: error: will not proceed with blocklists.

Regarding installing for x86_64-efi — I have successfull installation (just like when I install Arch on my computer). I did not consider —removable option when was installing Arch. I will try to boot from other computers and will see whether this option helps.

#10 2016-04-09 14:05:17

Head_on_a_Stick
Member
From: London
Registered: 2014-02-20
Posts: 6,876
Website

Re: [SOLVED] Bootable USB UEFI

mxfm wrote:

[I can boot from external USB disk at my computer, but cannot boot from other computers. Installing loader through efibootmgr is not an option, because it requires ‘pre-installation’, but I want to boot from USB disk ‘on fly’, like it is the case with MBR.

The «—removable» flag copies the GRUB bootloader to the default .efi loader location at $ESP/EFI/BOOT/BOOTX64.EFI — this will boot without an NVRAM entry.

mxfm wrote:

In this thread I receive advice to install both MBR and UEFI grub loaders (although I don’t quite understand how installing MBR loder will help to fix UEFI loader…)

I gave that advice because in the OP you claimed:

I cannot boot from usb UEFI from computers which do not support option to choose EFI loader upon startup

This is somewhat ambiguous and I decided that you might have meant that the machines in question did not support UEFI booting.

mxfm wrote:

Regarding the commands. After trying to install i386 I have:

Installing for i386-pc platform.
grub-install: warning: this GPT partition label contains no BIOS Boot Partition; embedding won't be possible.
grub-install: warning: Embedding is not possible.  GRUB can only be installed in this setup by using blocklists.  However, blocklists are UNRELIABLE and their use is discouraged..
grub-install: error: will not proceed with blocklists.

I think you have specified a partition number with that command — you should just use the drive letter.

Always post the *exact* commands you have used along with any output.

#11 2016-04-09 14:23:40

mxfm
Member
Registered: 2015-10-23
Posts: 163

Re: [SOLVED] Bootable USB UEFI

Head_on_a_Stick wrote:

The «—removable» flag copies the GRUB bootloader to the default .efi loader location at $ESP/EFI/BOOT/BOOTX64.EFI — this will boot without an NVRAM entry.

The file existed before I applied —removable flag, it didn’t help. Is EFI naming case sensitive?

Head_on_a_Stick wrote:

This is somewhat ambiguous and I decided that you might have meant that the machines in question did not support UEFI booting.

OK, I see.

Head_on_a_Stick wrote:

I think you have specified a partition number with that command — you should just use the drive letter. Always post the *exact* commands you have used along with any output.

OK

sudo grub-install --recheck --target=i386-pc /dev/sdb
Installing for i386-pc platform.
grub-install: warning: this GPT partition label contains no BIOS Boot Partition; embedding won't be possible.
grub-install: warning: Embedding is not possible.  GRUB can only be installed in this setup by using blocklists.  However, blocklists are UNRELIABLE and their use is discouraged..
grub-install: error: will not proceed with blocklists. 

Actually I am not suprised that this is not working because the disk is labelled as gpt…

#12 2016-04-09 16:23:50

Head_on_a_Stick
Member
From: London
Registered: 2014-02-20
Posts: 6,876
Website

Re: [SOLVED] Bootable USB UEFI

mxfm wrote:

Is EFI naming case sensitive?

No, the FAT filesystem used by the ESP is case-insensitive.

Try changing the boot order for attached devices from the firmware («BIOS») options in the target machines.

Be aware that some firmwares will boot $ESP/EFI/Microsoft/Boot/bootmgfw.efi in preference to the BOOTX64.EFI variant.

mxfm wrote:

sudo grub-install --recheck --target=i386-pc /dev/sdb
Installing for i386-pc platform.
grub-install: warning: this GPT partition label contains no BIOS Boot Partition; embedding won't be possible.
grub-install: warning: Embedding is not possible.  GRUB can only be installed in this setup by using blocklists.  However, blocklists are UNRELIABLE and their use is discouraged..
grub-install: error: will not proceed with blocklists. 

Actually I am not suprised that this is not working because the disk is labelled as gpt…

You need to create a BIOS boot partition to hold GRUB’s core.img when booting in non-UEFI mode.

This can be created in sectors 34-2047 (these will be empty in an optimally aligned disk) and will be type «EF02» in gdisk; it should *not* have a filesystem.

#13 2016-04-09 17:41:19

mxfm
Member
Registered: 2015-10-23
Posts: 163

Re: [SOLVED] Bootable USB UEFI

Head_on_a_Stick wrote:

No, the FAT filesystem used by the ESP is case-insensitive.

Try changing the boot order for attached devices from the firmware («BIOS») options in the target machines.

Be aware that some firmwares will boot $ESP/EFI/Microsoft/Boot/bootmgfw.efi in preference to the BOOTX64.EFI variant.

The problem is that BIOS does not detect UEFI loaders. I also placed grub loader to that place (I have written this in the first message), nothing helped.

Head_on_a_Stick wrote:

You need to create a BIOS boot partition to hold GRUB’s core.img when booting in non-UEFI mode.

This can be created in sectors 34-2047 (these will be empty in an optimally aligned disk) and will be type «EF02» in gdisk; it should *not* have a filesystem.

Thanks for the suggestion, will try.

#14 2016-04-10 08:21:43

mxfm
Member
Registered: 2015-10-23
Posts: 163

Re: [SOLVED] Bootable USB UEFI

Head_on_a_Stick wrote:

You need to create a BIOS boot partition to hold GRUB’s core.img when booting in non-UEFI mode.

This can be created in sectors 34-2047 (these will be empty in an optimally aligned disk) and will be type «EF02» in gdisk; it should *not* have a filesystem.

Well, it worked, thanks. However, booting in UEFI mode on second computer still not works. Will try on others.

#15 2016-04-11 06:51:02

mxfm
Member
Registered: 2015-10-23
Posts: 163

Re: [SOLVED] Bootable USB UEFI

Thanks for the suggestions, booting from UEFI and MBR works.

  1. Grub Installation Failed: «‘/boot/grub/i386-pc’ : No such file or directory» Error

    Hello, I have recently completed a Lubuntu 17.10 install, alongside Windows 10 on my Acer Aspire Switch 10E.

    In order to get anything Linux-related to boot past the initial bootloader off of a LiveUSB, I have to add the «nomodeset» command every time.
    The Lubuntu installation itself was successfull, with the exception of an error stating that Grub could not be installed. Re-installing yielded the same results.

    The automated BootRepair function in the «BootRepair live USB» did not sort the problem, as I do not have wireless drivers or an ethernet port.
    The proprietary linux drivers I do have access to need to be compiled before being used. (unless tar.gz can be magically «double-clicked» by the virtue of some amazing, live-USB-compatible software?)

    I have attempted to do a manual grub installation according to these sets of instructions:
    http://howtoubuntu.org/how-to-repair…ubuntu-live-cd
    https://askubuntu.com/questions/1265…ll-boot-loader
    These attempts always resulted in:
    «cannot open directory ‘/boot/grub/i386-pc’ : No such file or directory» error.
    (I did remember to use /dev/mmcblk0 or /dev/mmcblk0p5 instead of /dev/sda or /dev/sdaX)
    Could this be related to the «nomodeset» command, and the fact my CPU is actually a x64 Atom Z8300?

    Finally, there was one instance where I managed to connect to WiFi upon being informed that connections were available — this was after issuing 10 different variations of the grub-install /directory command, and forgetting to unmount the previously mounted directories (this also resulted in a permanently-blank terminal window and caused me to re-install the whole BootRepair… and subsequently lose internet access, either to re-booting or reinstalling haha).

    Any help would be greatly appreciated. Windows 10 is ridiculously slow, and I am not settling for sub-par slaveware.


  2. Re: Grub Installation Failed: «‘/boot/grub/i386-pc’ : No such file or directory» Erro

    Do not use any tar.gz unless nothing in repository works.

    Is this one the those that uses 32 bit UEFI, but is a 64 bit chip?
    Did you install in UEFI boot mode? But you have to add grubia32.efi which is not part of standard Ubuntu.

    https://gist.github.com/franga2000/2154d09f864894b8fe84
    https://ubuntuforums.org/showthread.php?t=2234219


  3. Re: Grub Installation Failed: «‘/boot/grub/i386-pc’ : No such file or directory» Erro

    Thanks for the quick reply!

    Not sure whether the UEFI itself is 32 or 64 bit.
    I am using a newer SW3-016 (2016) model, and I’m pretty sure it’s incompatible with Legacy boot. The installations of both x64Win10Home and Lubuntu were completed with Secure Boot «ON» and a whitelisted boot64.efi (can’t remember if the Windows file had the same name, but was definitely x64).

    I will try the solutions in the threads you have linked (ommitting the repeated Ubuntu installation — unless you think that’s a bad idea) and see if that works!


  4. Re: Grub Installation Failed: «‘/boot/grub/i386-pc’ : No such file or directory» Erro

    Do not know then if you have 32 bit or 64 bit UEFI.

    Re-install is a last resort. But can be done, just only use Something Else and choose same / (root) and /home if you created that also.

    UEFI only boots from external drives from an ESP or FAT32 partition with boot flag and /EFI/Boot/bootx64.efi, if 64 bit or bootia32.efi, if 32 bit UEFI (even if system is 64 bit). With Window that would have been a copy or version of Windows .efi boot file.
    With Ubuntu it is a copy of grub, but not the full install configuration of grub. It just has parts needed to boot live installer in UEFI mode with either Secure boot on or off. Ubuntu live installer also has BIOS boot but uses syslinux for that to avoid issues.


  5. Re: Grub Installation Failed: «‘/boot/grub/i386-pc’ : No such file or directory» Erro

    Not sure if this would apply. https://bugs.launchpad.net/ubuntu/+s…x/+bug/1734147 It apparently is affecting some Acer products.


  6. Re: Grub Installation Failed: «‘/boot/grub/i386-pc’ : No such file or directory» Erro

    Thanks again, I will update on how I get on with the 32bit Grub installation.

    Fortunately I don’t think this is the «Corrupting BIOS» bug. My UEFI Firmware seems as functional and poorly though-out as ever


  7. Re: Grub Installation Failed: «‘/boot/grub/i386-pc’ : No such file or directory» Erro

    Thank you all for your help, it was a rather silly mistake on my part.

    The root of the issue was most likely me attempting to boot from the wrong file. After trying multiple linux distros and looking closer at a few tutorials, I tried the boot-repair again with a wireless USB dongle. The final message after a successful grub repair mentioned that I should select the «shimx64.efi» file. Previously I was attempting to boot from «grubx64.efi» and «bootx64.efi» (once grub was correctly installed with lubuntu 16.04).

    My Acer Aspire Switch 10 E (2016) SW3-016 did not appear to suffer from the 17.10 Ubuntu BIOS corruption error.

    //For now I switched to Xubuntu due to Lubuntu’s networking issues with the USB dongle


This article documents issues that might arise when trying to use or install GRUB2.

Installation errors

Installing GRUB2 from within a chroot

When a separate /boot partition exists, be sure to mount the target root partition before chrooting, but do not mount the /boot partition until after chrooting to the new environment. This is required because grub-mkconfig will not detect /boot as a separate partition and will assume the /boot directory and the root (/) directory are on the same partition.

Reinstalling the GRUB2 EFI boot manager entry

In case the boot manager entries need to be restored, they can be re-added without invoking grub-install. Load the efivars kernel module and install sys-boot/efibootmgr:

root #emerge --ask sys-boot/efibootmgr

Next add a boot menu entry:

root #efibootmgr --create --gpt --disk /dev/sda --part 1 --write-signature --label "gentoo" --loader "\EFI\gentoo\grubx86.efi"

grub-install: error: cannot find EFI directory.

Note
The following examples presumes a 64-bit EFI GRUB2 install, adjust accordingly for 32-bit EFI.

root #grub-install --target=x86_64-efi

grub-install: error: cannot find EFI directory.

Properly setting the GRUB_PLATFORMS variable in /etc/portage/make.conf (the first time!) as listed above should resolve this error. Set the GRUB_PLATFORMS variable then re-emerge GRUB2 using the following command:

root #emerge --ask --newuse sys-boot/grub:2

In the case this error persists try forcing the install to the EFI directory by issuing the grub-install command with correct parameters for the --target and --efi-directory options:

root #grub-install --target=x86_64-efi --efi-directory=/boot

grub-install: Attempting to install GRUB2 to a disk or partition

root #grub-install /dev/sda1

Attempting to install GRUB to a partition disk or to a partition.  This is a BAD idea.
Embedding is not possible.  GRUB can only be installed in this setup by using blocklists. 
However, blocklists are UNRELIABLE and their use is discouraged.

There could be many reasons for this error to come up.

No mounted /boot

A /boot partition is not mounted.

No BIOS boot partition while using BIOS-GPT setup

This could mean there is not a EF02 or bios_boot partition to embed the core.img file in.

Creating a little partition of a few hundreds kilobytes may be enough, although it is good practice to align this partition to 2048 sectors to avoid a performance penalty with the disk. A 1 MiB partition should work well.

Attempting to install GRUB2 in a partition

When attempting to install GRUB2 in a partition e.g. /dev/sda5 (for instance because the boot loader will be chainloaded by a different boot loader), simply add --force option switch to force install.

Missing target detection

If grub-install does not print any errors message or if the error message is about scanning disk files and several platforms are enabled in /etc/portage/make.conf while nothing is installed on the disk, then edit the /sbin/grub-install script with a text editor of choice.

Change the platform variable to the appropriate platform for the current use case. The platform must be rightly set when emerging sys-boot/grub, else it will be incorrectly configured in the /sbin/grub-install script.

For example, to set the platform for «PC», change platform=qemu to platform=pc.

Note
This is true for GRUB version 1.99x only… for GRUB2 the correct file to investigate can be found at /etc/grub.d/00_header; change transform="s,grub,grub-qemu," to transform="s,grub,grub2," for instance to install rightly with grub-$platform-install.

grub-setup: no post-MBR gap

root #grub-bios-setup

grub-setup: warn: This msdos-style partition label has no post-MBR gap; embedding won't be possible!
grub-bios-setup: warn: Embedding is not possible. GRUB can only be installed in this setup by using blocklists.
            However, blocklists are UNRELIABLE and its use is discouraged.
grub-bios-setup: error: If you really want blocklists, use --force.

This error means that GRUB2 could not find the usual gap between the MBR and first partition of a disk. It is possible that the gap does not exist. Some tools (e.g. LiveUSB disk installer) format disks so that the first partition starts at sector 1 instead of 2048.

Repartitioning might be necessary to resolve the issue.

grub-install: embedding area is unusually small

root #grub-install /dev/sda

grub-install: warn: Your embedding area is unusually
small. core.img won't fit in it.
grub-install: warn: Embedding is not possible. GRUB can
only be installed in this setup by using blocklists. However,
blocklists are UNRELIABLE and their use is discouraged.
grub-install: error: will not proceed with blocklists.

There is not enough room at the beginning of the disk before the first partition.

In general this is a bit of trouble to fix. One or more partitions need to be resized in order to leave some free space at the beginning of the drive. The GParted LiveCD or SystemRescueCD are excellent tools to make this job less difficult.

If the swap partition is the first partition on the disk (e.g. /dev/sda1) it is possible to simply remove the existing swap space partition and re-partition the space. This resolution would avoid the need for booting into a live medium in order to resize a root (/) partition.

Понравилась статья? Поделить с друзьями:

Читайте также:

  • Grub install error cannot find efi directory ubuntu
  • Grub install error cannot find efi directory manjaro
  • Grub install error cannot find efi directory linux mint
  • Grub install error cannot find efi directory gentoo
  • Grub install error cannot find efi directory arch

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии