Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

nitro_check_script.sh - false positive checking for nvme in kernel #181

Open
benformosa opened this issue Oct 20, 2021 · 1 comment
Open

Comments

@benformosa
Copy link

The code which checks if the nvme module is build into the kernel matches on nvmem, which seems to be a separate kernel component.

(grep 'nvme' /boot/System.map-$(uname -r)) > /dev/null 2>&1

I attempted to change a RHEL 7.9 machine to a Nitro-based instance type and it wasn't able to boot.
After restoring to the previous instance type, I ran nitro_check_script.sh, and got the following output:

------------------------------------------------
OK NVMe Module is installed and available on your instance

OK ENA Module with version 2.0.3K is installed and available on your instance

OK fstab file looks fine and does not contain any device names.
------------------------------------------------

However, the nvme module is not loaded in the initrd; the following command produces no output:

lsinitrd | grep nvme

I came up with a potential fix:

diff --git a/nitro_check_script.sh b/nitro_check_script_fix.sh
index 8147602..371bb5c 100755
--- a/nitro_check_script.sh
+++ b/nitro_check_script_fix.sh
@@ -131,7 +131,7 @@ if [ `id -u` -ne 0 ]; then                                              # Checks
         exit 1
 fi

-(grep 'nvme' /boot/System.map-$(uname -r)) > /dev/null 2>&1
+(grep '\[nvme\]' /boot/System.map-$(uname -r)) > /dev/null 2>&1
 if [ $? -ne 0 ]
     then
     # NVMe modules is not built into the kernel

When running my modified script, I get this output:

------------------------------------------------
OK NVMe Module is installed and available on your instance

ERROR NVMe Module is not loaded in the initramfs image.
- Please run the following command on your instance to recreate initramfs:
# sudo dracut -f -v

OK ENA Module with version 2.0.3K is installed and available on your instance

OK fstab file looks fine and does not contain any device names.
------------------------------------------------
@iitggithub
Copy link

iitggithub commented Oct 12, 2022

Modifying the grep command did solve the problem of grep matching against nvmem but it didn't fix the issue. As you can see, the nvme kernel module is there:

`[ec2-user@ip-172-31-10-160 ~]$ uname -r

5.16.10-1.el7.elrepo.x86_64

[ec2-user@ip-172-31-10-160 ~]$ sudo grep '[nvme]' /boot/System.map-$(uname -r)

[ec2-user@ip-172-31-10-160 ~]$ modinfo nvme

filename: /lib/modules/5.16.10-1.el7.elrepo.x86_64/kernel/drivers/nvme/host/nvme.ko

version: 1.0

license: GPL

...`

Removing all of the nvmem lines and this is all we've got to match against:

`[ec2-user@ip-172-31-10-160 ~]$ sudo grep 'nvme' /boot/System.map-$(uname -r) | grep -v nvmem

ffffffff81534220 t nvme_disable_and_flr

ffffffff81a019e4 t nvme_disable_and_flr.cold`

Instead using lsinitrd against the initramfs file rather than grepping the System.map file is probably a better option:

`
[ec2-user@ip-172-31-10-160 ~]$ sudo lsinitrd /boot/initramfs-$(uname -r).img | grep nvme.ko

-rwxr--r-- 1 root root 81216 Feb 17 2022 usr/lib/modules/5.16.10-1.el7.elrepo.x86_64/kernel/drivers/nvme/host/nvme.ko
`

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants