Zach
Zach

Reputation: 333

User Mode Linux - Installing a module error

I am trying to run 'make' on a module in User Mode Linux to install a simple makefile. Here is my make file:

obj-m    := hello.o

KDIR    := /lib/modules/$(shell uname -r)/build
PWD    := $(shell pwd)

default:
    $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules

When I run this in User Mode Linux I get the following error:

make[1]: Entering directory `/lib/modules/2.6.28/build'
make[1]: *** No rule to make target `modules'.  Stop.
make[1]: Leaving directory `/lib/modules/2.6.28/build'
make: *** [default] Error 2

The problem is that no files are present under /lib/modules/. There's no directory for 2.6.28 or build. From what I've read, these should be symlinks to /usr/src, but under /usr/src, I don't see any files under that either.

Upvotes: 1

Views: 1108

Answers (2)

osgx
osgx

Reputation: 94345

Sources and headers of your UML kernel must be used to compile module for it.

You can compile it either inside UML or just in main system, but you must to use UML's kernel's headers and build scripts

Upvotes: 1

Nikolai Fetissov
Nikolai Fetissov

Reputation: 84189

You need to build and install the version of the kernel you are compiling for. Get the source from kernel.org, configure (I think make menuconfig picks the config up from the running kernel), build, and install it. You can do the build in your home directory under regular user, then of course you would need root to install it.

Edit:

Just in case you missed this - here's User Mode Linux HOWTO. It contains specific items for building and installing kernel and modules. Hope this helps.

Upvotes: 0

Related Questions