Kernel headers in LXC - makefile

I'm trying to compile some drivers in an LXC debian container (host is Ubuntu), but when it reach some module to install got this error:
make[2]: *** /lib/modules/4.15.0-45-generic/build: No such file or directory. Stop.
I know that LXC shares kernel with the host.
There is a way to install those kernel headers and compile the driver in the container?
Thanks

Related

modprobe: FATAL: Module fuse not found in directory

I am trying to mount a remote dir onto my local machine using sshfs.
My local is running Ubuntu 20.04. When I try:
sudo modprobe fuse
I get:
modprobe: FATAL: Module fuse not found in directory /lib/modules/5.4.162-1-pve
Fuse (2.9.9-3) is installed on my local machine. The /lib path does not hold a modules/ directory.
How can I make modprobe work?
The remote machine is a Linux container. That explains why the modprobe command is not working.

Resize qcow2 image on Ubuntu via WSL2? Kernel cannot be read by libguestfs-tools virt-resize

I'm trying to resize a qcow2 img I created and installed a guest mac os. When I try to use virt-resize I get the following error:
virt-resize: error: libguestfs error: /usr/bin/supermin exited with error status 1.
This seems to have to do with not being able to access the kernel or wrong permissions on the kernel. I'm running Ubuntu via WSL2 and I'm not sure how to give libguestfs-tools access to the kernel WSL2 runs on. How would you do this?
This comes about because there's not really a good way (at least, not any obvious one after a bit of time with Google) to get access to the WSL2 kernel from within WSL2 without custom-compiling your own.
In lieu of that, libguestfs-tools will work just fine if you install the normal Ubuntu kernel packages and do the usual Ubuntu follow-up step for libguestfs-tools:
sudo apt install linux-image-generic-hwe-20.04
sudo chmod go+r /boot/vmlinuz-*
This will populate your /boot and /lib/modules/* directories with a kernel that will satisfy libguestfs-tools.

Getting [Errno 39] Directory not empty issue while installing python modules inside shared folder of vagrant using virtual environment

I am trying to build debian package of my module inside shared folder of VM (Vagrant + VirtualBox) using virtual environment and I am gettting following error
[Errno 39] Directory not empty: '__pycache__'
<mymodule_path>/devenv/lib/python3.7/site-packages/__pycache__
python version : 3.7
vagrant version: 2.2.10
Guest addition plugin: latest
Virtual Box version: 6.1
Can you help me here to resolve this issue

Installation kernel modules to specific path

I want to try my simple kernel module hello.ko on QEMU. I have root filesystem on hdd.img file and compiled kernel in another folder. I run QEMU by this command from directory with sources:
qemu-system-i386 -m 128M -kernel arch/x86/boot/bzImage -append "root=/dev/sda" -hda hdd.img
How to install my module? Modprobe? But how to specify WHERE to install? As I
understand, modprobe install module to my host system, not to QEMU-related?
Installing own kernel module into target machine is very similar to installing into current machine:
Mount device with root filesystem for target machine. Mount point is referred as <mount-point> below.
Copy (e.g. with cp command) your module file (hello.ko) into directory with other kernel's modules, located at <mount-point>/lib/modules/<kernel-version>/. It is better to use additional subdirectory extra/ for 3d-party modules.
If you want you module to be loaded with modprobe on target machine, you need to use depmod command, which has been used for the kernel itself:
depmod -b <mount-point>/lib/modules/<kernel-version>

Unable to find the source of current linux Kernel

While trying to install guest additions on a Debian guest I get the error:
Unable to find the source of your current linux Kernel. Specify KERN_DIR= and run Make again.
Some said that this is because linux headers are missing. But when I try to run
sudo apt-get install linux-headers-3.16.0-4amd64
I get the error could not resolve ftp.debian.org.uk
My guest operating system was not connected to my host's wifi. So
apt-get update
apt-get install linux-headers-3.16.0-4amd64
Did not work, but when I edited my VirtualBox network settings to Bridged Adapter, both commands worked. Note that it is also important to run the command
sh /media/cdrom/VBoxLinuxAdditions.run
to complete the installation of guest editions.

Resources