4

I am compiling the Linux kernel for my specific hardware and I only select the drivers/options which I really need. This is in contrast to a typical distribution kernel, where they compile almost everything, to be compatible with as many hardware configurations as possible.

I imagine, for my kernel, I am only using 1% of the total kernel code (order of magnitude estimate).

Is there any way to find out which files from the kernel source I have actually used when I build my kernel?

This is not an academical question. Suppose I have compiled my kernel 3.18.1. Now a security update comes along, and 3.18.2 is released. I have learned in my other question how to find which files have change between releases. If I knew whether any of the files I am using have changed, I would recompile my kernel to the new version. If, on the other hand, the changes only affect files which I am not using anyway, I can keep my current kernel version.

2
  • I can't see an easy and reliable way to make this monitoring based on your screen output. However, you could use the inotify api and right before you hit enter on make, create a notification to log to a file or print to STDOUT unix.stackexchange.com/questions/163572/… - is just a matter of monitoring what files are read during your build process :)
    – user34720
    Commented Mar 18, 2015 at 19:58
  • If there is a change in a file which you do not compile. How does it affect you. You can just run make to be safe, and see if make says "up-to-date" or is building some files? Commented Mar 19, 2015 at 9:29

1 Answer 1

6

Compiling my comment as answer:

  1. Run the following command on one shell. You can make a shell script of it or demonize with the -d option.

    inotifywait -m -r -e open --format '%f' /kernel_sources/directory/in_use/ -o /home/user/kernel_build.log
    
  2. On other shell, execute make

  3. The log file /home/user/kernel_build.log will have a list of the files that have been opened(read operation) during the build process.
4
  • this looks like this might work. I wonder though, whether there is no easier (more direct) way to do it. Commented Mar 18, 2015 at 20:39
  • You could use find /home/ -atime +1 to see what files were acessed on the last 2 days for example, but i think inotify would be a more reliable way to get this info ;)
    – user34720
    Commented Mar 18, 2015 at 20:53
  • yes, but atime only works if your filesystem supports it (is mounted with that option). Commented Mar 18, 2015 at 21:06
  • For sure. Since even the "purest" form of read still writes something to disc, like cat /etc/fstab will write on the file metadata information about when it was last acessed, mount points with noatime will cause you problems and, that's why i marked the find solution as not reliable :)
    – user34720
    Commented Mar 18, 2015 at 21:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .