How to set mount point of boot partition to /boot/efi?

18,209

See if this adds an entry in UEFI to boot from NVMe drive. See man efibootmgr for details on parameters.

sudo efibootmgr -c -L "Ubuntu-NVMe" -l "\EFI\ubuntu\shimx64.efi" -d /dev/nvme0n1 -p 1

But whenever I use a -L label different than Ubuntu, it still boots from the /EFI/ubuntu/grub.cfg, so make sure you have that also and it is correct. It used to not even have a 3 line grub.cfg in other labels, now it does, but something internally is still coded to only use /EFI/ubuntu/grub.cfg.

Script has not been updated to fully show NVMe drives. Your grub.cfg in it should be:

search.fs_uuid 22ac8da3-d60a-46db-811d-a09ce5538215 root hd0,gpt2 
set prefix=($root)'/boot/grub'
configfile $prefix/grub.cfg

And the one in sda, should have UUID of install in sda, but probably hd1,gpt2, UUID should override device setting. Not sure how UEFI and grub see drives. I plug in external SSD and it becomes hd0 even though sdc in Ubuntu. And then grub/UEFI bumps up all my other drives one number. And if I also have flash drive plugged in I have to change hd0 to hd2 to find install in sda.

Share:
18,209

Related videos on Youtube

hirschme
Author by

hirschme

Updated on September 18, 2022

Comments

  • hirschme
    hirschme over 1 year

    I have two ubuntu installed in my system, one on the SSD (nvme0n1p1), and one on the Harddrive (sda1).

    After upgrade to 17.10, ubuntu on the SSD wont boot, not being able to find file '/boot/vmlinuz-4.13.0-041300-generic', although the files are there. (See error: file '/boot/vmlinuz-4.13.0-041300-generic' not found , how to create?)

    I see now on gparted, that the partition containing these files is not mounted correctly, so grub cannot see the files.

    enter image description here

    Where as for the other OS installed in the harddrive, which is working fine, gparted shows:

    enter image description here

    On start, grub also complaints that "22ac8da-d6..." partition was not found. This is how the SSD partition is apparently mounted.

    I guess I should change the mount settings, so nvme0n1p1 has /boot/efi/ as the mount point, and have nvme0n1p2 on / , in other words, exactly how the partitions are set on the harddrive (sda1, sda2).

    Any help on how I can do this?

    the content of /etc/fstab shows that /boot/efi/ was previously on nvme0n1p1

    # /etc/fstab: static file system information.
    #
    # Use 'blkid' to print the universally unique identifier for a
    # device; this may be used with UUID= as a more robust way to name devices
    # that works even if disks are added and removed. See fstab(5).
    #
    # <file system> <mount point>   <type>  <options>       <dump>  <pass>
    # / was on /dev/nvme0n1p2 during installation
    UUID=22ac8da3-d60a-46db-811d-a09ce5538215 /               ext4    errors=remount-ro 0       1
    # /boot/efi was on /dev/nvme0n1p1 during installation
    UUID=C1DE-5B29  /boot/efi       vfat    umask=0077      0       1
    /swapfile                                 none            swap    sw              0       0
    

    And the output of blkid:

    /dev/nvme0n1: PTUUID="eb5c38b1-7f71-4b49-a4e9-9e6ab2c9b6a4" PTTYPE="gpt"
    /dev/nvme0n1p1: UUID="C1DE-5B29" TYPE="vfat" PARTLABEL="EFI System Partition" PARTUUID="5b57c19c-750b-457a-89f1-87130509735e"
    /dev/nvme0n1p2: UUID="22ac8da3-d60a-46db-811d-a09ce5538215" TYPE="ext4" PARTUUID="2e1b8924-98f4-4821-8f48-8452620182b8"
    /dev/sda1: UUID="DF5C-3936" TYPE="vfat" PARTLABEL="EFI System Partition" PARTUUID="2798e3ca-54f4-4528-8753-0b516c1a749c"
    /dev/sda2: UUID="d37fc604-163d-4e04-83de-88993c28e419" TYPE="ext4" PARTUUID="a1331af1-a3e0-4f4e-846c-2ae70d53cb26"
    

    Output of lsblk -f , which agrees with display of gparted:

    NAME        FSTYPE LABEL UUID                                 MOUNTPOINT
    sda                                                           
    ├─sda1      vfat         DF5C-3936                            /boot/efi
    └─sda2      ext4         d37fc604-163d-4e04-83de-88993c28e419 /
    sr0                                                           
    nvme0n1                                                       
    ├─nvme0n1p1 vfat         C1DE-5B29                            
    └─nvme0n1p2 ext4         22ac8da3-d60a-46db-811d-a09ce5538215 /media/lukas/22ac8da3-d60a-46db-811d-a09ce5538215
    

    In summary: How can I set the Mount Point of /dev/nvme0n1p1 to /boot/efi/ ?

    The error message upon booting on 17.10 in nvme0n1p1 is:

    error: failure reading sector 0x3b9e12a0 from 'hd2'
    error: failure reading sector 0x3b9e1200 from 'hd2'
    error: failure reading sector 0x0 from 'hd2'
    error: failure reading sector 0x3b9e12a0 from 'hd2'
    error: failure reading sector 0x3b9e1200 from 'hd2'
    error: failure reading sector 0x0 from 'hd2'
    error: no such device: 22ac8da3-d60a-46db-811d-a09ce5538215 
    error: file '/boot/vmlinuz-4.13.0-041300-generic' not found
    error: you need to load the kernel first
    

    Output of efibootmgr -v

    BootCurrent: 0000
    Timeout: 1 seconds
    BootOrder: 0000,0001,0002,0008,0009
    Boot0000* ubuntu    HD(1,GPT,2798e3ca-54f4-4528-8753-0b516c1a749c,0x800,0x100000)/File(\EFI\ubuntu\shimx64.efi)
    Boot0001* grub  HD(1,GPT,2798e3ca-54f4-4528-8753-0b516c1a749c,0x800,0x100000)/File(\EFI\ubuntu\grubx64.efi)
    Boot0002* boot  HD(1,GPT,2798e3ca-54f4-4528-8753-0b516c1a749c,0x800,0x100000)/File(\EFI\Boot\bootx64.efi)
    Boot0008  Onboard NIC (IPV4)    PciRoot(0x0)/Pci(0x1c,0x3)/Pci(0x0,0x0)/MAC(14b31f18c7f5,0)/IPv4(0.0.0.0:0<->0.0.0.0:0,0,0)..BO
    Boot0009  Onboard NIC (IPV6)    PciRoot(0x0)/Pci(0x1c,0x3)/Pci(0x0,0x0)/MAC(14b31f18c7f5,0)/IPv6([::]:<->[::]:,0,0)..BO
    

    Boot-Info summary:

    http://paste.ubuntu.com/p/bG54zn47VZ/

    boot/efi/EFI/ubuntu/grub.cfg on both the SSD and HD are the same:

    search.fs_uuid d37fc604-163d-4e04-83de-88993c28e419 root hd0,gpt2 
    set prefix=($root)'/boot/grub'
    configfile $prefix/grub.cfg
    

    UPDATES from suggestions of Oldfred:

    Current output of efibootmgr -v

    BootOrder: 0003,0000,0001,0002,0008,0009
    Boot0000* ubuntu    HD(1,GPT,2798e3ca-54f4-4528-8753-0b516c1a749c,0x800,0x100000)/File(\EFI\ubuntu\shimx64.efi)
    Boot0001* grub  HD(1,GPT,2798e3ca-54f4-4528-8753-0b516c1a749c,0x800,0x100000)/File(\EFI\ubuntu\grubx64.efi)
    Boot0002* boot  HD(1,GPT,2798e3ca-54f4-4528-8753-0b516c1a749c,0x800,0x100000)/File(\EFI\Boot\bootx64.efi)
    Boot0003* Ubuntu-NVMe   HD(1,GPT,5b57c19c-750b-457a-89f1-87130509735e,0x800,0x100000)/File(\EFI\ubuntu\shimx64.efi)
    Boot0008  Onboard NIC (IPV4)    PciRoot(0x0)/Pci(0x1c,0x3)/Pci(0x0,0x0)/MAC(14b31f18c7f5,0)/IPv4(0.0.0.0:0<->0.0.0.0:0,0,0)..BO
    Boot0009  Onboard NIC (IPV6)    PciRoot(0x0)/Pci(0x1c,0x3)/Pci(0x0,0x0)/MAC(14b31f18c7f5,0)/IPv6([::]:<->[::]:,0,0)..BO
    

    /boot/efi/EFI/ubuntu/grub.cfg on NVMe:

    search.fs_uuid 22ac8da3-d60a-46db-811d-a09ce5538215 root hd0,gpt2 
    set prefix=($root)'/boot/grub'
    configfile $prefix/grub.cfg
    

    /boot/efi/EFI/ubuntu/grub.cfg on HDD:

    search.fs_uuid d37fc604-163d-4e04-83de-88993c28e419 root hd0,gpt2 
    set prefix=($root)'/boot/grub'
    configfile $prefix/grub.cfg
    
    • hirschme
      hirschme almost 6 years
      @mook765 thank for looking into this issue. I ran sudo update-grub from the harddrive installed ubuntu, but sadly it did not change anything. I am concerned too why lsblk -f and geparted do not agree on the content of /etc/fstab on showing the SSD as /boot/efi...
    • mook765
      mook765 almost 6 years
      You are confused with two instances of Grub installed on different ESP's. Your mount points look good, only the currently used ESP and /-partition are mounted at /boot/efi and /, the other ESP is not mounted at all (not used in this moment) and the second install mounted under /media, totally correct. Did you try to reboot after running sudo update-grub?
    • hirschme
      hirschme almost 6 years
      @mook765 you are right, I am a bit confused. I did reboot and nothing changed. Because there are two instances of Grub, how to make sure I am updating the "right" instance? If I can only run ubuntu on sda2, am I just updating the grub instance that I do not care about right now?
    • mook765
      mook765 almost 6 years
      Please add the output of efibootmgr -v to your question. Please don't post screenshots of plain text, copy and paste from terminal into question make things better readable and text-processing possible.
    • mook765
      mook765 almost 6 years
      You use the instance of Grub installed on sda1 at the moment. I don't understand the error no such device: 22ac8da3-d60a-46db-811d-a09ce5538215, lsblk and blkid show the correct UUID for this partition, it should be found, that's quite mystic.
    • hirschme
      hirschme almost 6 years
      I included the whole error messages that I get when booting, don't think its going to help much, but in any case... I think there is overall a bit of a mess on the booting procedure, as when I installed ubuntu, I could not make it find the boot files on the SSD and not on sda2, so had to install a second ubuntu on sda2 and point boot files to the OS on nvme0n1p1. Thinking about installing the whole thing again from scratch
    • mook765
      mook765 almost 6 years
      You should first check your SSD, failure reading sector has a bad sound. help.ubuntu.com/community/Smartmontools
    • oldfred
      oldfred almost 6 years
      With UEFI, only one ESP and one /EFI/ubuntu folder is used. Usually the install finds the first ESP often sda's, but with NVMe drives it usually finds it as first drive. Better to see all details at once. Post the link to the Create BootInfo summary report. Is part of Boot-Repair: help.ubuntu.com/community/Boot-Info Drive order can make a difference on booting, and whether I have my flash drive plugged in or not can make a difference.
    • hirschme
      hirschme almost 6 years
      @oldfred I posted the link as you suggested. I found another thread with a similar background setting (two ubuntus, confusion over proper setting and management of grub) for which apparently you also could help nicely: ubuntuforums.org/showthread.php?t=2377786. So I guess I should stick to one /EFI/ubuntu and properly configure it to detect the SSD?
    • oldfred
      oldfred almost 6 years
      You have two ESP, but only one ubuntu entry in the UEFI boot menu. And that has the GUID/PARTUUID (from BLKID) of your sda1's ESP. And then the ESP have the UUID of you install in sda. You could use efibootmgr to add another entry with different name to use GUID from NVMe drive. And edit grub.cfg in NVMe's ESP to have UUID of install in NVMe drive. But either UEFI and grub.cfg should load a grub.cfg in either install and have entries to boot both installs.
    • hirschme
      hirschme almost 6 years
      @oldfred I am sorry but I dont understand very well. Is this a suggestion for a solution? If so, could you maybe post it as an answer in a more detailed way? How to add another entry (on what, and what entry) with efibootmgr, and explicitly how to edit grub.cfg on the ssd?
  • hirschme
    hirschme almost 6 years
    I ran the efibootmgr command and rebooted the system. Selecting ubuntu on NVMe actually worked this time, however after inspection I found out it loaded the ubuntu on the harddrive. Seems a step closer though...
  • oldfred
    oldfred almost 6 years
    Does the NVMe drive's /EFI/ubuntu/grub.cfg in the ESP have the UUID of the ubuntu install on the HDD, not the UUID of the install on the NVMe drive? It may have correct grub.cfg in /EFI/Ubuntu-NVMe folder in ESP. The efibootmgr -v for the new ubuntu-nvme entry will have the GUID/PartUUID of the NVMe drive's ESP. And the grub.cfg in /EFI/ubuntu on NVMe should have UUID of install partition on NVMe drive. The ubuntu entry in efibootmgr -v should still be GUID of ESP on sda and its grub.cfg should have UUID of install partition on HDD.
  • hirschme
    hirschme almost 6 years
    the efibootmgr -v for the new ubuntu-nvme entry does have the GUID/PARTUUID of the NVMe's drive, that is correct. BUT, the grub.cfg in NVMe's /EFI/ubuntu does NOT have the UUID of the NVMe drive, and still has the UUID of the HDD, which may explain why is it still booting the HDD ubuntu
  • oldfred
    oldfred almost 6 years
    Change that to correct UUID, you may just need to copy from /EFI/Ubuntu-NVMe/grub.cfg or manually edit with correct UUID. It will not use the grub.cfg in the new entry (but it should), it only wants to use /EFI/ubuntu/grub.cfg.
  • hirschme
    hirschme almost 6 years
    I changed the grub.cfg (see update on question to see grub.cfg and efibootmgr). I still boots only ubuntu on the HDD, although the initial errors that I had before (on failure to load kernels) are gone.
  • hirschme
    hirschme almost 6 years
    Isn't a problem that efibootmgr boots shimx64.efi from the NVMe, but then proceeds for grubx64.efi and bootx64.efi on the HDD? (Boot0001 and Boot0002)
  • hirschme
    hirschme almost 6 years
    I added two more entries into efibootmgr linking to shimx64 and grubx64 in the NVMe, with priority for booting order, but still redirects the booting into ubuntu on the HDD
  • oldfred
    oldfred almost 6 years
    The shimx64.efi is a version of grub for UEFI Secure Boot and should work whether Secure boot is on or off. The grubx64.efi is only for UEFI with Secure boot off. Or it should not matter which you use if Secure Boot is off. I would think UUID would override HD0 if not correct. But then what does fstab show? Some have copied fstab, so it boots incorrect install? Compare fstabs on NVMe and HDD. Boot-Repair report only shows fstab from HDD.
  • hirschme
    hirschme almost 6 years
    The content of fstab from NVMe is already in the post, it points to the correct locations on NVMe
  • oldfred
    oldfred almost 6 years
    Do you have in the ESP on the NVMe drive /EFI/ubuntu and /EFI/Ubuntu-NVMe folders? and then are grub.cfg same in each?
  • hirschme
    hirschme almost 6 years
    No /EFI/Ubuntu-NVMe folder was created. Should i do that manually and copy the content of EFI/ubuntu?
  • oldfred
    oldfred almost 6 years
    You could try it, but do not think that is the issue. But then perhaps UEFI is defaulting back to the ubuntu entry? I think when I rename an install, it did create a folder, but that was several versions ago.