Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to find module 'sg' #1099

Closed
mabod opened this issue Feb 15, 2021 · 19 comments · Fixed by #1436
Closed

Failed to find module 'sg' #1099

mabod opened this issue Feb 15, 2021 · 19 comments · Fixed by #1436
Labels
bug Our bugs
Milestone

Comments

@mabod
Copy link

mabod commented Feb 15, 2021

I am using EndeavourOS (Arch). With custom kernel linux-xanmod I get an error message in the journal during boot:

systemd-modules-load[297]: Failed to find module 'sg'

This does not happen with other kernels because the xanmod kernel does not come with this module. It is compiled into the kernel:

#
# SCSI support type (disk, tape, CD-ROM)
#
CONFIG_BLK_DEV_SD=y
CONFIG_CHR_DEV_ST=m
CONFIG_BLK_DEV_SR=y
CONFIG_CHR_DEV_SG=y
CONFIG_CHR_DEV_SCH=m
CONFIG_SCSI_ENCLOSURE=m
CONFIG_SCSI_CONSTANTS=y
CONFIG_SCSI_LOGGING=y
CONFIG_SCSI_SCAN_ASYNC=y

dracut seems to have the sg module dependency hardcoded into the 90kernel-modules module:


/usr/lib/dracut/modules.d/90kernel-modules/module-setup.sh:

[...]
        # if not on hostonly mode, or there are hostonly block device
        # install block drivers
        if ! [[ $hostonly ]] || \
            for_each_host_dev_and_slaves_all record_block_dev_drv;
        then
            hostonly='' instmods sg sr_mod sd_mod scsi_dh ata_piix

            if [[ "$hostonly_mode" == "strict" ]]; then
                install_block_modules_strict
            else
                install_block_modules
            fi
        fi
[...]

The PC is still booting and I do not experience any misbehavior. But the message in the log is annoying.

Can the dependency on the sg.ko module be removed from dracut?

@mabod mabod added the bug Our bugs label Feb 15, 2021
@haraldh
Copy link
Collaborator

haraldh commented Feb 15, 2021

Is the module mentioned in /lib/modules/<KERNEL_VERSION>/modules.builtin ?

@haraldh
Copy link
Collaborator

haraldh commented Feb 15, 2021

Did you forget to do a depmod -a <KERNEL_VERSION> ?

@mabod
Copy link
Author

mabod commented Feb 15, 2021

Is the module mentioned in /lib/modules/<KERNEL_VERSION>/modules.builtin ?

6# grep -i sg /lib/modules/5.10.16-xanmod1-cacule-1-cacule/modules.builtin
kernel/block/bsg.ko
kernel/drivers/scsi/sg.ko

Did you forget to do a depmod -a <KERNEL_VERSION> ?

No. This is done automatically when the kernel is installed.

The module is not in the modules tree:

content of /lib/modules

5.10.15-lqx2-1-lqx  
5.10.16-1-ck  
5.10.16-arch1-1  
5.10.16-xanmod1-cacule-1-cacule  
5.10.16-zen1-1-zen  
5.4.98-1-lts
find . -name sg.ko\*
./5.10.15-lqx2-1-lqx/kernel/drivers/scsi/sg.ko
./5.10.16-zen1-1-zen/kernel/drivers/scsi/sg.ko.xz
./5.10.16-arch1-1/kernel/drivers/scsi/sg.ko.xz
./5.4.98-1-lts/kernel/drivers/scsi/sg.ko.xz
./5.10.16-1-ck/kernel/drivers/scsi/sg.ko.xz

@haraldh
Copy link
Collaborator

haraldh commented Feb 15, 2021

Ok, then I'll have to revisit this. Thanks for reporting!

@haraldh haraldh added this to the dracut-053 milestone Feb 15, 2021
@mabod
Copy link
Author

mabod commented May 3, 2021

This is still open and it happens with most recent xanmod kernel and most recent dracut on Arch.

I believe the issue is that this script /usr/lib/dracut/modules.d/90kernel-modules/module-setup.sh is trying to load module sg.ko even if it is built into the kernel like with the xanmod kernels.

@haraldh
Copy link
Collaborator

haraldh commented May 3, 2021

What is your output of:

$ egrep -r . /usr/lib/modules-load.d /etc/modules-load.d

@haraldh
Copy link
Collaborator

haraldh commented May 3, 2021

$ sudo /lib/systemd/systemd-modules-load 
Module 'msr' is built in
Module 'sg' is built in

@mabod
Copy link
Author

mabod commented May 3, 2021

27# egrep -r . /usr/lib/modules-load.d /etc/modules-load.d
/usr/lib/modules-load.d/cdrecord.conf:sg
/usr/lib/modules-load.d/pkcs8.conf:# When distributions use CONFIG_PKCS8_PRIVATE_KEY_PARSER=m kernel option,
/usr/lib/modules-load.d/pkcs8.conf:# using keyctl(2) will fail for loading PKCS#8 private keys since there is
/usr/lib/modules-load.d/pkcs8.conf:# no automatic module loading for key type parsers.  This entry ensures
/usr/lib/modules-load.d/pkcs8.conf:# that the kernel module pkcs8_key_parser.ko is loaded at boot time.
/usr/lib/modules-load.d/pkcs8.conf:pkcs8_key_parser
/usr/lib/modules-load.d/bluez.conf:crypto_user
/usr/lib/modules-load.d/virtualbox-host-dkms.conf:vboxdrv
/usr/lib/modules-load.d/virtualbox-host-dkms.conf:vboxnetadp
/usr/lib/modules-load.d/virtualbox-host-dkms.conf:vboxnetflt
29# sudo /lib/systemd/systemd-modules-load
Module 'sg' is built in

/usr/lib/modules-load.d/cdrecord.conf is owned by cdrtools 3.02a09-4

It looks like/usr/lib/modules-load.d/cdrecord.conf is asking for the sg module.
But why isn't that an issue with mkinitcpio?

@haraldh
Copy link
Collaborator

haraldh commented May 3, 2021

Is modules.builtin included in your initramfs?

$ lsinitrd <initrdfile> | grep modules.builtin

@mabod
Copy link
Author

mabod commented May 3, 2021

This is with the initramfs-linux-xanmod-lts.img created by dracut:

53# lsinitrd initramfs-linux-xanmod-lts.img | grep modules.builtin
-rw-r--r--   1 root     root        10186 Mar 30 17:46 usr/lib/modules/5.10.34-xanmod1-1-lts/modules.builtin
-rw-r--r--   1 root     root           12 Mar 30 17:46 usr/lib/modules/5.10.34-xanmod1-1-lts/modules.builtin.alias.bin
-rw-r--r--   1 root     root        12923 Mar 30 17:46 usr/lib/modules/5.10.34-xanmod1-1-lts/modules.builtin.bin

and

2# grep sg /usr/lib/modules/5.10.34-xanmod1-1-lts/modules.builtin
kernel/block/bsg.ko
kernel/drivers/scsi/sg.ko

EDIT:
And /usr/lib/modules-load.d/cdrecord.conf is not the issue. I moved this file somehwere else and I still get the warning: systemd-modules-load[299]: Failed to find module 'sg'

@haraldh
Copy link
Collaborator

haraldh commented May 3, 2021

EDIT:
And /usr/lib/modules-load.d/cdrecord.conf is not the issue. I moved this file somehwere else and I still get the warning: systemd-modules-load[299]: Failed to find module 'sg'

Well, it might still be in the initramfs.

# lsinitrd initramfs-linux-xanmod-lts.img | grep modules-load.d

@haraldh
Copy link
Collaborator

haraldh commented May 3, 2021

also try this:

# lsinitrd initramfs-linux-xanmod-lts.img -f usr/lib/modules/5.10.34-xanmod1-1-lts/modules.builtin | grep sg.ko

@mabod
Copy link
Author

mabod commented May 3, 2021

12# lsinitrd initramfs-linux-xanmod-lts.img -f usr/lib/modules/5.10.34-xanmod1-1-lts/modules.builtin | grep sg.ko
kernel/block/bsg.ko
kernel/drivers/scsi/sg.ko

@haraldh haraldh modified the milestones: dracut-054, dracut-055 May 3, 2021
@haraldh
Copy link
Collaborator

haraldh commented May 4, 2021

The PC is still booting and I do not experience any misbehavior. But the message in the log is annoying.

Can the dependency on the sg.ko module be removed from dracut?

The instruction in module-setup.sh only installs the kernel module into the initrd image.
Due to /usr/lib/modules-load.d/cdrecord.conf being installed into the initrd, systemd-modules-load is trying to load it and causes:

systemd-modules-load[297]: Failed to find module 'sg'

Although modules.builtin contains sg.ko, so systemd-modules-load should only display Module 'msr' is built in.

@haraldh
Copy link
Collaborator

haraldh commented May 4, 2021

So, you will have to add rd.shell rd.break to your kernel command line and run:

# /lib/systemd/systemd-modules-load 
# modinfo sg

manually to see if the modinfo output also reports:

# modinfo sg
name:           sg
filename:       (builtin)
[…]

haraldh added a commit to haraldh/dracut that referenced this issue May 4, 2021
This solves all issues, where builtin kernel modules are not recognized
as such.

Fixes: dracutdevs#1146
Fixes: dracutdevs#1099
@haraldh
Copy link
Collaborator

haraldh commented May 4, 2021

This is likely the culprit: #1436

@mabod
Copy link
Author

mabod commented May 4, 2021

modinfo does not find the module. See screenshot:

21-05-04 11-25-23 4256

@haraldh
Copy link
Collaborator

haraldh commented May 4, 2021

modinfo does not find the module. See screenshot:

21-05-04 11-25-23 4256

yeah, the fix is PR #1436

@mabod
Copy link
Author

mabod commented May 4, 2021

This is likely the culprit: #1436

Yes! I tested it and it fixes my issue.
Thanks.

haraldh added a commit that referenced this issue May 4, 2021
This solves all issues, where builtin kernel modules are not recognized
as such.

Fixes: #1146
Fixes: #1099
mikhailnov pushed a commit to mikhailnov/dracut that referenced this issue Mar 5, 2024
This solves all issues, where builtin kernel modules are not recognized
as such.

Fixes: dracutdevs#1146
Fixes: dracutdevs#1099
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Our bugs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants