Im running linux on my board and have to read info in /proc/[pid]/io. But it is not found.
For ex:
$ dd if=/dev/zero of=/tmp/aa &
[1] 926
$ cat /proc/926/io
cat: /proc/926/io: No such file or directory
Which I need enable to have kernel export that?
Many thanks for your help!
I just discovered that another thing is necessary.
I just recompiled a 4.4 kernel (for an embedded system) and enabling the CONFIG_TASKSTATS was not enough. I have to enable
CONFIG_TASKSTATS=y
CONFIG_TASK_XACCT=y
CONFIG_TASK_IO_ACCOUNTING=y
in order for the /proc/<pid>/io to appear.
According to this, you need CONFIG_TASKSTATS enabled in your kernel.
You can check your current kernel's config in various ways depending on distribution, but looking at /boot/config-$(uname -r) works in Redhat flavors.
If you don't have that option configured, you'll need to recompile your kernel, or investigate why your distro doesn't enable it.
Related
I compiled my Linux kernel according to the Linux Device Driver Chapter 4: Debugging Techniques. After I loaded my first hello world module and then checked the output by dmesg, however, all I can see is evbug: ........
I know I can turn off evbug's output by execute sudo rmmod evbug. But, obviously, it is inconvenient to execute this command after each reboot.
How could I disable this module's autoloading? I just want to load it manually when I need it.
You need to blacklist the module. For debian systems see https://wiki.debian.org/KernelModuleBlacklisting. For redhat systems see https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Installation_Guide/rescuemode_drivers-blacklisting.html
I know that for a common Linux OS, the clocksource can be viewed by the command
cat /sys/devices/system/clocksource/clocksource0/available_clocksource
However I have a Linux system with kernel version 2.6.27.7, and there is no /sys/ folder inside. Then how can I see which clocksource is used?
Thanks ahead.
It should be in /usr/src/linux-2.6.27.7-9/drivers/clocksource. If you haven't defined a totally different 'tree', of course... (don't forget to sudo when you run 'find'!)
What's the best way to programmatically determine if the current machine is running Ubuntu, what architecture it has, and what version of Ubuntu it is running?
One way would be to scan the output of uname -a to check for the right kernel version and architecture.
Another way would be to scan /etc/apt/sources.list for the Ubuntu distribution keyword (eq precise, quantal, etc)
Is there a better way?
Apart from uname -a, There are several way to get information about the current distribution.
The best way is to parse the release files. They usually ended with -release or _release and located in /etc. Following command will find them all.
ls /etc/*{-,_}release
Ubuntu uses lsb_release
Redhat/Fedora uses redhat-release
Slackware uses slackware-release
Gentoo uses gentoo-release
Debian's corresponding file is /etc/debian_version. This file will also (somewhat misleadingly, but for a good reason) be present on Ubuntu systems, though.
Another file is /etc/issue which is used for machine identification and pre-login prompt can be used to determine current distribution information.
System information can be found in /proc/version too.
cat /proc/version
One way would be to scan the output of uname -a to check for the right kernel version and architecture.
But one does not generally want to parse the output of such tools, because it's not elegant (it's considered a hack, so to say).
However, you can use the uname() function/syscall:
#include <sys/utsname.h>
struct utsname sysinfo;
if (uname(&sysinfo) < 0) {
printf("Cannot determine OS\n");
exit(-1);
}
printf("Operating system name: %s\n", sysinfo.sysname);
You can use a library as a neutral to the operating system. A solution is lsband your question became close to using lsb question.
Afaik most Linux distributions also use /etc/issue. The text in it can ofcourse have been changed by the admin to show a different login message.
Sample from fedora:
Fedora release 17 (Beefy Miracle)
Kernel \r on an \m (\l)
Sample from ubuntu:
Ubuntu 11.04 \n \l
I have started reading the book Essential Linux Device Drivers. I am following the process for compiling and booting into a new kernel. However I am unable to boot into the newly compiled kernel - I select the new kernel in grub and then ..nothing...the screen just stays the same.
Here are the steps I am taking, as described in the book (I am using kernel 2.6.24 as that is what the book is based on) -
cd /usr/src/linux-2.6.24 (the base dir of the kernel I downloaded)
make clean
cp arch/x86/configs/i386_defconfig .config
make bzImage cp arch/x86/boot/bzImage /boot/vmlinuz
The book says that 'you might need to alert your bootloader about the arrival of the new boot image. If you are using the GRUB bootloader, it figures this out automatically'.
Well it didn't figure it out automatically in my case as there was no option to select this kernel in GRUB. So I did it manually by typing update-grub in the terminal. And this didn't work either. However once I changed the filename from vmlinuz to vmlinuz-2.6.24 and type update-grub it picked it up. So on page 11 of the book there seems to already be multiple things left out...
The book says to then reboot the machine.
Anyway, I am now able to select this kernel in GRUB but as I said above it doeesn't boot properly, the screen just goes blank and never changes. So am I missing something? I have followed the instructions in the book exactly.
Most automatic grub setups include kernel options to hide the messages generated as the kernel attempts to boot. For example:
/boot/vmlinuz-x.x.x.x-generic root=UUID=something ro quiet splash
While on the grub menu line of the kernel you wish to boot, press 'e' to temporarily edit it, and delete options such as quiet and splash (but leave the ro).
Then boot the temporarily modified line, and see the progress messages in order to get an idea where the boot is failing.
The default configuration probably requires an initrd (e.g. because the file system and root device needs their driver, from modules, which is what initrd provides).
You could either configure your kernel appropriately (carefully enabling as in-kernel, not in-modules, the essential drivers) for your particular hardware, or use a procedure to build a kernel package with its initrd.
You should find a procedure appropriate for your linux distribution and habits, e.g. something like this or that. I am using on Debian:
time fakeroot make-kpkg -j2 --initrd --revision=3.4.2 --append-to-version=-amd64 binary
For now, I need to use some packages to do a emulation for IOMMU (it is similar to MMU), and I got some source about it, but I don't know how to use them.
http://www.spinics.net/lists/kvm/msg38514.html Here is a link of source for emulating IOMMU
http://repo.or.cz/w/qemu-kvm/amd-iommu.git Here is a link for downloading file for this emulation
My problem is how to use qemu to do this and there are so many file in the download list, I don't know how to use them...
Thanks for your help, really appreciate!!! If you know something detail, please tell me
you can use download option in the right side of the page ( Generally snapshot option is available in repositories )
or this
then simply use configure script to generate makefile
i.e.
use ccache if you want to recompile it again and again
$CC="ccache gcc"./configure --prefix=$PREFIX <br>
then make to build and install, use -j<no_of_cpu+1>
$make -j5 all install
if you have dependencies issue, solve them using synaptic manager or apt-get
P.S. AFAIK You should have iommu support available in hardware, if you have 64-bit machine then you might have. You can check flags in using cat /proc/cpuinfo