# Specify modules to load from an initramfs?

## John R. Graham

I'm looking for something like the /etc/modules.autoload.d/kernel-2.x file to specify extra kernel modules to load at init time but that mechanism doesn't appear to be present on the initramfs image.  Surely there's some sort of mechanism but I can't seem to find it or any documentation for that matter.

The reason I started this quest was that I was moving my working system image around among different hard drives, including different types (IDE, SATA, SCSI).  I started doing experiments in very modular kernels.  I thought I should be able to make the drivers for the boot device into modules (i.e., not built in) and nevertheless load them from the initramfs.  I even thought that mdev might do it automagically, like udev does.  Alas, no such luck.  The init process announces that it's loading modules and then stops with the following error message:

```
>> Loading modules

>> Activating mdev

>> Determining root device...

!! Block device /dev/sda3 is not a valid root device...

!! The root block device is unspecified or not detected.

   Please specify a device to boot, or "shell" for a shell...

boot() ::
```

Now, I know that the modules I need are present on the initramfs because I can go into the busybox shell and load them manually:

```
boot() :: shell

...

/ # modprobe sym53c8xx

sym53c8xx loaded.

/ # modprobe sd_mod

sd_mod loaded.

/ # exit

!! The root block device is unspecified or not detected.

   Please specify a device to boot, or "shell" for a shell...

boot() :: /dev/sda3

>> Mounting root...

INIT: version 2.86 booting

...

(system boots normally from here)
```

Before you all jump on me for not building the drivers for my boot device into the kernel, let me emphasize that I'm experimenting.  My system is working; I have no trouble building a bootable system with the aforementioned drivers built in.

Has anyone been down this road?

- John

----------

## drak

I had the same problem... found out that for some reason the MODULES_SCSI section is not loaded, I have solved this by adding 

```
doload=sd_mod
```

 to my grub.conf on the kernel line. 

You might need something a little more such as

```
doload=sym53c8xx,sd_mod
```

as I use a sata device and those modules load from the initramfs I have created.

Also looks like you are not getting any modules loading have you generated a initramfs or an initrd?

----------

## John R. Graham

It's an initramfs.  All you see happening under the busybox shell is happening under the initramfs, before pivot_root() is used to establish real_root as the new root.  Some modules are loading, but they are not being loaded off of the initramfs; they're being loaded by udev once the kernel is loaded and the real init (as opposed to the initramfs init) has started.

You know, I had begun to suspect that the solution you proposed might be possible.  I've just been slammed at work and haven't had the time to experiment properly lately.

The way this started out is that the first device I had on the SCSI bus was my tape drive, which is not needed for boot, of course.  All the kernel pieces needed to use the tape drive were modules and udev had no trouble finding them and loading them.  Then I added a SCSI drive to the chain and subsequently decided it would be cool to move my root partition to the SCSI drive and that's when I started having trouble.

I intend to delve into this deeper as I have the time because I'm half convinced that the necessity to mention the modules on the kernel command line  results from a bug or limitation in mdev that c|(sh)ould be corrected.

Thanks for the insight.

- John

----------

## JeliJami

If the modules are available in your initramfs, you could do the modprobes in your /linuxrc (or whatever init= you're using)

----------

## John R. Graham

Yes, that's exactly what drack's suggestion

```
doload=sym53c8xx,sd_mod
```

does.  The way it works is kind of interesting.  The kernel silently ignores any command line parameters it doesn't understand but makes the whole kernel command line available through /proc/cmdline.  The linuxrc init script retrieves the kernel command line and parses additional  options, including doload.  It took me a while to figure out what piece of code was providing the functionality that reacted to the doload kernel command line parameter because linuxrc is only sparsely documented:Some features are documented in the genkernel man page under the section labeled "INITRD OPTIONS" (but, alas, not doload).

A more complete explanation is on the Gentoo Wiki at A guided tour around the init script.

Anyway, in the case of doload, linuxrc parses the comma-separated list of modules and modprobes each of 'em.

- John

Edit 2013-07-02: Fixed a broken link as the old gentoo-wiki.com is no more.

Removed link to old WiKi at gentoo-wiki dot info  as its now redirecting to spam.

-- NeddySeagoon 16 Jul 2018

----------

