Linux /proc/config.gz – Why It Shows 0 Bytes

fileskernellinuxproc

I have an Android TV stck
I compiled Linux for IT from https://github.com/Galland/rk3x_kernel_3.0.36

But when I booted that Image I found /proc/config.gz is of 0 bytes

can some please explain how the command line params from .config file in kernel source get mounted to /proc.
I mean what goes in the background??

Best Answer

Files in /proc do not have a file size in general, and are shown as having 0 size in ls -l, but you can read data from them anyway (see man 5 proc).

Try, for example:

zcat /proc/config.gz | wc

or:

$ ls -l /proc/cmdline
-r--r--r-- 1 root root 0 Aug  4 10:16 /proc/cmdline

Looks empty. But:

$ cat /proc/cmdline | wc
      1       5     114

it contains data. Let's see:

$ cat /proc/cmdline
BOOT_IMAGE=/boot/vmlinuz-3.13.0-24-generic root=UUID=fc48808f-8f06-47fc-a1fe-5d08ee9e0a50 ro noirqdebug nomodeset

feels like a normal file - except if you want to do anything special, like reading by blocks, seek(), or loking at the size.


In case you can not read /proc/config.gz, there is a file that normally contains the same:

less /lib/modules/$(uname -r)/build/.config

See man proc for details.

Related Question