Kernel's not found error in arch - linux

I run this command:
sudo dkms autoinstall -k 3.11.6-1-ARCH
and have error:
Error! echo
Your kernel headers for kernel 3.11.6-1-ARCH cannot be found at
/usr/lib/modules/3.11.6-1-ARCH/build or /usr/lib/modules/3.11.6-1-ARCH/source.
Error! echo
Your kernel headers for kernel 3.11.6-1-ARCH cannot be found at
/usr/lib/modules/3.11.6-1-ARCH/build or /usr/lib/modules/3.11.6-1-ARCH/source.
what should I do?

Do you actually have kernel headers for the stock repo kernel installed? They're not installed by default, so unless you explicitly did, you probably don't. Try running:
pacman -Sy linux-headers
and see what happens.
Also, does the kernel version you have match with what you're trying to run against it? If the above doesn't fix the problem, please post the output of
uname -a

Related

How to use Linux perf tool on WSL2? How to have perf for the correct kernel?

I am trying to use the perf tool of Linux on my WSL2 using Windows10 machine. I have done every step of the accepted answer here:Is there any method to run perf under WSL?
When I ran "make" comment, I got a warning:
Warning: Kernel ABI header at 'tools/include/uapi/linux/stat.h'
differs from latest version at 'include/uapi/linux/stat.h'
But the perf executable was still created.
However when I try to use perf like this:
sudo perf record -g myexe myargs
I received this error:
WARNING: perf not found for kernel 5.10.16.3-microsoft
You may need to install the following packages for this specific
kernel:
linux-tools-5.10.16.3-microsoft-standard-WSL2
linux-cloud-tools-5.10.16.3-microsoft-standard-WSL2
Then I tried to run this:
sudo apt install linux-tools-5.10.16.3-microsoft-standard-WSL2
However that did not work either, I got this:
Reading package lists... Done Building dependency tree Reading state
information... Done E: Unable to locate package
linux-tools-5.10.16.3-microsoft-standard-WSL2 E: Couldn't find any
package by glob 'linux-tools-5.10.16.3-microsoft-standard-WSL2'
What should I do now?

How to enable CONFIG_RT_GROUP_SCHED in Ubuntu to make it RT

I need to run real time applications on Ubuntu RT Linux and was reading about ways to make linux act as RT system and I learned two ways to do it
preemptive_rt kernel patching
enabling CONFIG_RT_GROUP_SCHED flag in the kernel.
I've already tried my hands on 1st method Install RT Linux patch for Ubuntu
However, apart from uname -r showing #1 SMP PREEMPT RT I've no other proof that it is actually a RT system and hence want to try the 2nd method. Enable CONFIG_RT_GROUP_SCHED flag in the kernel and see its performance.
I read we can confirm if the kernel already has the flag by following command:
# zcat /proc/config.gz | grep RT_GROUP
CONFIG_RT_GROUP_SCHED=y
However, my system doesn't even have the config.gz file in proc, so I believe my kernel does not have this enabled.
I'm relatively new to linux kernels so this might be naive but how can I enable this in the kernel?
Step 1
Download linux kernel from https://www.kernel.org/pub/linux/kernel/. For the purpose of this PoC we downloaded linux-4.16.18.tar.gz kernel from above link.
Step 2
Unzip the kernel
$ tar -xzvf linux-4.16.18.tar.gz
Step 3
Move to kernel source directory
$ cd linux-4.16.18
Step 4
Install kernel build dependencies
$ sudo apt install git build-essential kernel-package fakeroot libncurses5-dev libssl-dev ccache bison flex
Step 5
Run kernel configuration
$make menuconfig
Step 6
Go to General setup ─> Control Group Support ─> CPU controller ─> Group scheduling for SCHED_RR/FIFO configuration as shown below:
Go to General setup ─> Kernel .config support and enable access to .config through /proc/config.gz
Step 7
Compile the kernel
$ make -j20
Make modules & install
$ sudo make modules_install -j20
$ sudo make install -j20
Step 8
Open the grub.cfg file to verify if kernel is installed
$ vim /boot/grub/grub.cfg
Look for the menuentry with menuentry 'Ubuntu, with Linux linux-4.16.18'
If it's not your default kernel then change the GRUB_DEFAULT=0 value to your kernel
Step 9
Reboot your system
sudo reboot
Step 10
Verify the system by the following command:
# zcat /proc/config.gz | grep RT_GROUP
CONFIG_RT_GROUP_SCHED=y

Linux kernel compile error

I cloned the kernel sources from Linus's github, I made a little modification to the usbhid driver (thats compiles fine as a module, no errors), but if I try to build the whole kernel, I get this error:
AR drivers/gpu/drm/built-in.o
AR drivers/gpu/built-in.o
Makefile:1023: recipe for target 'drivers' failed
make: *** [drivers] Error 2
And thats all nothing specific. What could be the problem?
UPDATE: 9-15-18 This issue is resolved.. The kernel will now compile with the commands I have given below.
Same issue here. 4.19.0-rc3 will not compile on the Threadripper 2990WX. BTW, I am currently running 4.19.0-rc2 with no issues.
These are the commands I used. Please note, I also tried without the LD static flag.
wget https://git.kernel.org/torvalds/t/linux-4.19-rc3.tar.gz && tar -xzf linux-4.19-rc3.tar.gz && cd linux-4.19-rc3 && make -j 64 clean && make -j 64 mrproper && zcat /proc/config.gz >> ./.config && LDFLAGS=--static make -j 64
The issue is in your config file. I have faced the same issue before and and appears to be due to a missing CONFIG option in the .config file generated through make menuconfig.
You need to add these two CONFIG options in your .config file:
CONFIG_EXTRA_FIRMWARE_DIR="lib/firmware"
CONFIG_EXTRA_FIRMWARE="<name_of_firmware_along_with_path>"
In some platforms, the GPU uses firmware that needs to be built-in by stitching it with kernel. This firmware is placed in the directory path provided by CONFIG_EXTRA_FIRMWARE option while building the kernel. And unless we don't provide CONFIG_EXTRA_FIRMWARE_DIR path to tell the kernel where to pick this firmware from, the above build failure occurs.

Compiling erlang with systemtap but require dtrace

I'm compiling erlang otp from source like following:
./configure --with-dynamic-trace=systemtap
But it reports error:
checking for dtrace... no
configure: error: No dtrace utility found.
I think systemtap is for linux usage and it is different from dtrace, am I right?
After installed dtrace Now the error is:
dtrace: failed to compile script emulator/beam/erlang_dtrace.d: Preprocessor not found
configure: error: Could not precompile erlang_dtrace.d: dtrace -h failed
configure: error: /root/otp/erts/configure failed for erts
Which distro are you using? I'd forget using DTRACE, it will be a bit harder to make it to work than Systemtap (at least it was for me). I'm using Systemtap and it works perfectly.
If you are not using Fedora/RH you should patch your kernel with UTRACE or use a kernel >= 3.5 with UPBOBES enabled.
To verify if your kernel has UTRACE/UPROBE enabled run this:
grep UTRACE /boot/config-$(uname -r)
or
grep PROBES /boot/config-$(uname -r)
For example, in my machine (Ubuntu 12.04 with Mainline kernel 3.5):
$ grep UTRACE /boot/config-$(uname -r)
$
$ grep UPROBES /boot/config-$(uname -r)
CONFIG_ARCH_SUPPORTS_UPROBES=y
CONFIG_UPROBES=y
You should also have systemtap installed. The version shipped with Ubuntu (my case) is quite old, so I compiled it from source (traditional configure/make/make install). You can get it here:
http://sourceware.org/systemtap/ftp/releases/
I'm using version 1.8.
Then try to recompile it again. It should work.
Regards
After installing systemtap(sudo apt-get install systemtap), exiting or logging out from the current shell session then logging in may help.
Also, you may try using kerl.

How to debug my Cross compiled Linux Kernel?

I 've cross compiled a Linux Kernel (for ARM on i686 - using Cross-LFS).
Now I'm trying to boot this Kernel using QEMU.
$ qemu-system-arm -m 128 -kernel /mnt/clfs-dec4/boot/clfskernel-2.6.38.2 --nographic -M versatilepb
Then, it shows this line and waits for infinite time !!
Uncompressing Linux... done, booting the kernel.
So, I want to debug the kernel, so that I can study what exactly is happening.
I'm new to these kernel builds, Can someone please help me to debug my custom built kernel as it is not even showing anything after that statement. Is there any possibility of the kernel being broken? ( I dont think so, b'se it didnot give any error while compiling )
And my aim is to generate a custom build very minimal Linux OS. Any suggestions regarding any tool-chains etc which would be easy & flexible depending on my requirements like drivers etc.,
ThankYou
You can use GDB to debug your kernel with QEMU you can use -s -S options. If you want a simple and reliable toolchain, you can use ELDK from DENX (http://www.denx.de/wiki/DULG/ELDK).
You can install it like this (It's not the last version, but you got the idea):
wget http://ftp.denx.de/pub/eldk/4.2/arm-linux-x86/iso/arm-2008-11-24.iso
sudo mkdir -p /mnt/cdrom (if necessary)
sudo mount -o loop arm-2008-11-24.iso /mnt/cdrom
/mnt/cdrom/install -d $HOME/EMBEDDED_TOOLS/ELDK/
The command above should install the toolchain under $HOLE/EMBEDDED_TOOLS/ELDK (modify it if you need)
echo "export PATH=$PATH:$HOME/EMBEDDED_TOOLS/ELDK/ELDK42/usr/bin" >> $HOME/.bashrc
You can then see the version of your ARM toolchain like this:
arm-linux-gcc -v
You can test a hello_world.c program like this:
arm-linux-gcc hello_world.c -o hello_world
And you type: file hello_wrold to see the target architecture of the binary, it should be something like this:
hello_wrold: ELF 32-bit LSB executable, ARM, version 1 (SYSV)
Now if you want to compile a production kernel, you need to optimize it (i suggest using busybox) and if you want just one for testing now, try this steps:
Create a script to set your chain tool set_toolchain.sh:
#! /usr/bin/sh
PATH=$PATH:$HOME/EMBEDDED_TOOLS/ELDK/ELDK42/usr/bin
ARCH=arm
CROSS_COMPILE=arm-linux-gnueabi-
export PATH ARCH CROSS_COMPILE
And run your script (source ./set_toolchain.sh)
Download a linux kernel and unzip it (Let's assume 2.6.x, it's an old kernel, but there are a lot of chances that it work without compilation errors).
Inside your unzipped kernel:
cd ~/linux-2.6.29/arch/arm/configs
make versatile_defconfig
Here we use versatile chip, you may need to use make menuconfig to modify the option OABI and set it to ARM EABI, this option is under Kernel features menu
After all this steps, you can compile you kernel:
make
if you want verbose compilation make v=1
After this you got your kernel under arch/arm/boot/zImage.
Hope this help.
Regards.
I would suggest to build your kernel by activating the option in the section Kernel hacking of your configuration file.
Then you may use kdb or kgdb which is easier to use but requires another machine running gdb.
`
You can also connect Qemu and GDB. Qemu has the -s and -S options that run a GDB server and allow you to connect to it via TCP to localhost:1234. Then you can load your kernel image (the unzipped one) in GDB and see how far your kernel boots.

Resources