Unable to boot from SATA HDD

I'm struggling to get OpenWRT 21.02.0-rc3 to boot on an x86_64 machine that uses an NVIDIA SATA controller.

With the stock image, at boot time, the kernel fails to recognize the root partition and waits indefinitely. I've verified the kmod-ata-nvidia-sata driver works with this setup: if I boot from USB and then install that driver via opkg, the same HDD and its partitions get recognized instantly, and their contents are all readable.

However, when I try to build from source and include the same driver (and ata-core) in the kernel, I still get the same result when I flash the freshly-compiled image to the HDD and try to boot: the root partition is never found.

Am I missing some other dependency in the build process that would make this system bootable directly from SATA?

yes you are missing some other dependancy

When I load kmod-ata-nvidia-sata after a USB boot with the stock image, the only listed dependency (other than the kernel) is ata-core...so I'm pretty stumped as to what else could be missing.

so you have the disk working... and you build from source...

there is a large but tracable gap between the two...

if this means what I think it means... then you'd be able to backtrack over;

  • what ipks (kmods) you have when it works
  • what KCONFIG they relate to
  • what you are missing

if it means not what I think it means... then you have an issue with module order / boot.d vs KCONFIG and need to resolve when the module is loaded...

I assume you are selecting the packages as "built in" (they show a * in the make menuconfig interface)

Because that's not integrated in kernel, but preinstalled in root filesystem and part of filesystem image you build. That's still a module, not integrated in kernel.

And obviously when booting the kernel cannot find the root filesystem, because the module it needs to see it is in the root filesystem (that it cannot see).

If you want to actually build it in you need to add its symbols in this file https://github.com/openwrt/openwrt/blob/master/target/linux/x86/64/config-5.10
or the other one called config-5.4 if you use kernel 5.4

This is the symbol that is enabled to compile that as a package https://github.com/openwrt/openwrt/blob/ec6293febc244d187e71a6e54f44920be679cde4/package/kernel/linux/modules/block.mk#L110

and this is the symbol for the package ata-core https://github.com/openwrt/openwrt/blob/ec6293febc244d187e71a6e54f44920be679cde4/package/kernel/linux/modules/block.mk#L29

so you should add
CONFIG_ATA=y
CONFIG_SATA_NV=y
anywhere in the file I said, and then recompile the firmware

I don't see why you need to install OpenWrt on Sata anyway, you can just keep OpenWrt on the USB drive (by default it does not write anything in the root filesystem unless you are changing configuration or installing packages so it will not just wear out the USB flash like most other operating systems will do) and use the Sata as a pure data drive, which also makes upgrades and maintenance much more convenient.

That's why Sata for most devices is a module/package and is not built-in the kernel, even on x86 targets. The "expected" and "recommended" way is to keep OpenWrt root system on a USB drive.

3 Likes

Thanks very much for this. You're exactly right -- I had wrongly believed that "*" in make menuconfig was designed to build the module into the kernel rather than merely adding it to the root fs. Your method -- editing the proper kernel config file -- worked perfectly.

Thanks again for the detailed explanation. Next it seems I need to study up a bit on the (intended) structure of the Openwrt filesystem.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.