Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
GRUB2 with NVMe boot device.
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
Kresp
n00b
n00b


Joined: 17 Oct 2016
Posts: 73

PostPosted: Tue Mar 28, 2017 2:50 pm    Post subject: GRUB2 with NVMe boot device. Reply with quote

I'm having some trouble setting up the boot loader.

I use LiveDVD (standard multilib amd64) image dd'd to SATA ssd for installation and follow handbook closely.

When I run grub-install, it reports EFI variable errors:
Code:

(chroot) livecd / # grub-install --target=x86_64-efi --efi-directory=/boot/efi                                                         
Installing for x86_64-efi platform.                                                                                                   
EFI variables are not supported on this system.                                                                                       
EFI variables are not supported on this system.                                                                                       
Installation finished. No error reported.                                                                                             
(chroot) livecd / # fdisk -l /dev/nvme0n1                                                                                             
nvme0n1    nvme0n1p1  nvme0n1p2  nvme0n1p3                                                                                             
(chroot) livecd / # fdisk -l /dev/nvme0n1                                                                                             
Disk /dev/nvme0n1: 477 GiB, 512110190592 bytes, 1000215216 sectors                                                                     
Units: sectors of 1 * 512 = 512 bytes                                                                                                 
Sector size (logical/physical): 512 bytes / 512 bytes                                                                                 
I/O size (minimum/optimal): 512 bytes / 512 bytes                                                                                     
Disklabel type: gpt                                                                                                                   
Disk identifier: 21065991-1A10-498E-91B3-6F2383E570BD                                                                                 
                                                                                                                                       
Device          Start        End   Sectors   Size Type                                                                                 
/dev/nvme0n1p1   2048      71679     69632    34M EFI System                                                                           
/dev/nvme0n1p2  71680     583679    512000   250M Linux filesystem                                                                     
/dev/nvme0n1p3 583680 1000215182 999631503 476.7G Linux filesystem                                                                     
(chroot) livecd / # mount                                                                                                             
/dev/nvme0n1p3 on / type ext4 (rw,relatime,data=ordered)                                                                               
/proc on /proc type proc (rw,relatime)                                                                                                 
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)                                                                             
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)                                                   
debugfs on /sys/kernel/debug type debugfs (rw,nosuid,nodev,noexec,relatime)                                                           
configfs on /sys/kernel/config type configfs (rw,nosuid,nodev,noexec,relatime)                                                         
fusectl on /sys/fs/fuse/connections type fusectl (rw,nosuid,nodev,noexec,relatime)                                                     
cgroup_root on /sys/fs/cgroup type tmpfs (rw,nosuid,nodev,noexec,relatime,size=10240k,mode=755)                                       
openrc on /sys/fs/cgroup/openrc type cgroup (rw,nosuid,nodev,noexec,relatime,release_agent=/lib64/rc/sh/cgroup-release-agent.sh,name=openrc)                                                                                                                                 
cpuset on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)                                                   
cpu on /sys/fs/cgroup/cpu type cgroup (rw,nosuid,nodev,noexec,relatime,cpu)                                                           
cpuacct on /sys/fs/cgroup/cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpuacct)                                               
net_cls on /sys/fs/cgroup/net_cls type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls)                                               
udev on /dev type devtmpfs (rw,nosuid,relatime,size=10240k,nr_inodes=4110772,mode=755)                                                 
devpts on /dev/pts type devpts (rw,relatime,gid=5,mode=620)                                                                           
mqueue on /dev/mqueue type mqueue (rw,nosuid,nodev,noexec,relatime)                                                                   
shm on /dev/shm type tmpfs (rw,nosuid,nodev,noexec,relatime)                                                                           
/dev/nvme0n1p2 on /boot type ext4 (rw,relatime,data=ordered)                                                                           
/dev/nvme0n1p1 on /boot/efi type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)                                                                                                                                 


modprobe in chroot'ed environment says it can not find efivars in /lib/*/4.5.2*/ directory. 4.5.2 is LiveDVD kernel, the one I've built is 4.9.16 and has efivars.ko in /lib/*/4.5.16*/ dir.

If I ignore it and try booting, motherboard fails to even detect nvme drive as UEFI bootable.
Now, if I follow fallback advice on GRUB2 wiki page and copy /boot/efi/EFI/gentoo/grubx64.efi to /boot/efi/EFI/BOOT/BOOTX64.EFI - it detects as UEFI bootable, but it fails at mounting root partition. If I enter shell and ls block devices, nvme is not present, but sata (sda) is.

Any pointers?

Drive is Samsung 960 Pro, motherboard is MSI X370 Titanium with default (latest stable) UEFI.

Never used EFI before, my previous bootloader on older system was syslinux.
Back to top
View user's profile Send private message
Roman_Gruber
Advocate
Advocate


Joined: 03 Oct 2006
Posts: 3806
Location: Austro Bavaria

PostPosted: Tue Mar 28, 2017 3:04 pm    Post subject: Reply with quote

Quote:
Now, if I follow fallback advice on GRUB2 wiki page and copy /boot/efi/EFI/gentoo/grubx64.efi to /boot/efi/EFI/BOOT/BOOTX64.EFI - it detects as UEFI bootable, but it fails at mounting root partition. If I enter shell and ls block devices, nvme is not present, but sata (sda) is.


Quote:
but it fails at mounting root partition.


So grub2 is loaded? (the selection screen for different operating system is usually black and says somewhere on the screen which grub version is loaded!)

correct? => fix your kernel + initramfs => add support for your hardware (most likely you will need the latest kernel, and check staging section)

nope => fix your bootloader, or use another different bootloader (check linux forum for guys with similar hardware, how they have set up their boxes)
Back to top
View user's profile Send private message
Kresp
n00b
n00b


Joined: 17 Oct 2016
Posts: 73

PostPosted: Tue Mar 28, 2017 3:21 pm    Post subject: Reply with quote

Yeah, when I use fallback method, kernel loads.
I used defconfig, apparently it does not have NVMe support enabled and USB-keyboards don't work for some reason, only PS/2. I'll just rebuild kernel with added support, it'll probably be enough.

What I wonder about is why didn't grub-install install itself to correct path and what is the way to reinstall it properly.
How should file structure look in the first place?
Is /boot/efi/EFI/gentoo/grubx64.efi final loader, with all the stuff set up, or just a default copy?

Also, if I nuke /boot/efi - what steps will I have to repeat? Only grub-install, or some of the previous ones, like generating initramfs?
Back to top
View user's profile Send private message
Roman_Gruber
Advocate
Advocate


Joined: 03 Oct 2006
Posts: 3806
Location: Austro Bavaria

PostPosted: Tue Mar 28, 2017 5:19 pm    Post subject: Reply with quote

Kresp wrote:
Yeah, when I use fallback method, kernel loads.
I used defconfig, apparently it does not have NVMe support enabled and USB-keyboards don't work for some reason, only PS/2. I'll just rebuild kernel with added support, it'll probably be enough.



Nothing unusal to adapt the kernel.

Quote:
What I wonder about is why didn't grub-install install itself to correct path and what is the way to reinstall it properly.


edit: It is just a stupid script. e.g. linux mint nuked my data during those "awesome" grub scripts. Do not use them carelessly. /end edit

That depends on the grub version and the uefi in question.

In my case: ASUS g75VW with uefi: I keep a sheet of paper with the command in question + the sysrescue-cd in question on a shelf.
I have to reinstall grub on a regular basis. I switch my drives after I did my backup and hterefore I have to reinstall grub2

In my point of view, grub is only compatible to the disc I used during installation. not to every available livemedium!

--

I would not recommend reinstalling grub or using those grub scripts.

I only reinstall grub when uefi forgets the mappings for the discs.

I update my bootloader by hand. Just adapt the boot section! And just move the file / delete old files from folder /boot


Quote:
Also, if I nuke /boot/efi - what steps will I have to repeat? Only grub-install, or some of the previous ones, like generating initramfs?


I reuse my over one year old initramfs to boot my box.
I reuse hte microcode package from intel which is also a bit dated (both are sorta "initramfs", loaded with initrd)
edit: I normally never had a need to recreate an initramfs. I only use openrc / eudev. You can reuse your initramfs as long as it works. Sometimes there is a need to manually adapt genkernel initramfs(I had to do that!) Same with the kernel. as Long the kernel works you can reuse it. Of course it is recommended to update the kernel when a new stable one hits the tree. /endedit

You will just most likely need to redo the mapping UEFI => your bootloader

which is in my case

sysrescue-cd october 2015 => mounting boot => grub2-install --efi-directory=/boot/EFI

This of course depends on the platform / UEFI / grub version in case.

when you nuke /boot/efi or /boot/EFI, I have seen both so far, I assume it depends on how you made the folders during the setup phase of grub2, you will most likely have to redo the gentoo handbook regarding setup of grub2 for the discs.


Quote:
How should file structure look in the first place?
Is /boot/efi/EFI/gentoo/grubx64.efi final loader, with all the stuff set up, or just a default copy?


I have it seen differently in the past, efi written in small or big letters. Different folders and such

Code:
ASUS-G75VW roman # ls -alh /boot/EFI/gentoo/grubx64.efi
-rwxr-xr-x 1 root root 113K Mär 10 14:43 /boot/EFI/gentoo/grubx64.efi
ASUS-G75VW roman # ls -alh /boot/EFI/EFI/gentoo/grubx64.efi
-rwxr-xr-x 1 root root 113K Mär 11 22:30 /boot/EFI/EFI/gentoo/grubx64.efi


I assume / conclude, it has partly to do with the grub2-install command / script, how it is invoked on which folder. ... What the current guide the user used recommends.

I do clean up my boxes after a backup. So I get rid of lint over the time.

Grub2 is a bit better documented by now. I used it a bit longer as the average gentoo guy. As I used it, gentoo still used grub1 in their handbook. I used it because the Binary backup distro (i think ubuntu), at that time already used grub2. Syntax was nearly similar to comprehend, for an old style MBR box.
Back to top
View user's profile Send private message
DONAHUE
Watchman
Watchman


Joined: 09 Dec 2006
Posts: 7550
Location: Goose Creek SC

PostPosted: Wed Mar 29, 2017 1:59 pm    Post subject: Reply with quote

Quote:
(chroot) livecd / # grub-install --target=x86_64-efi --efi-directory=/boot/efi
Installing for x86_64-efi platform.
EFI variables are not supported on this system.
EFI variables are not supported on this system.
Usually means that the install system (livecd/liveusb) from which the chroot was initiated was not booted in uefi mode.
Recommend boot a system rescue cd/usb in uefi mode, mount the gentoo partitions, enter the chroot, ensure the EFI system partition (/dev/nvme0n1p1) is mounted at /boot/efi, run
Code:

emerge efivar grub
grub-install --target=x86_64-efi --efi-directory=/boot/efi
grub-mkconfig -o /boot/grub/grub.cfg
ls /boot/efi # -> EFI
ls /boot/efi/EFI # -> Boot  gentoo
ls /boot/efi/EFI/Boot # -> bootx64.efi
ls /boot/efi/EFI/gentoo # -> grubx64.efi

The directory/file structure of /boot/efi is as shown above.
Running
Code:
efibootmgr -v
should show something resembling/including
Quote:
Boot0000* gentoo HD(1,GPT,cad2219f-3047-4b03-a174-19475754a5cb,0xe1800,0x32000)/File(\EFI\gentoo\grubx64.efi)

_________________
Defund the FCC.
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