DaemonForums  

Go Back   DaemonForums > NetBSD > NetBSD General

NetBSD General Other questions regarding NetBSD which do not fit in any of the categories below.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 12th November 2019
notooth notooth is offline
Shell Scout
 
Join Date: Jul 2015
Posts: 125
Question How to enable kernel options?

Hello,

Can anyone tell me how to check if the following options are enable:
Quote:
option COMPAT_LINUX
option EXEC_ELF64
and if they are not, how can I enable them?
Reply With Quote
  #2   (View Single Post)  
Old 12th November 2019
IdOp's Avatar
IdOp IdOp is offline
Too dumb for a smartphone
 
Join Date: May 2008
Location: twisting on the daemon's fork(2)
Posts: 1,027
Default

These kinds of options are set (or unset) at the time the kernel is compiled. Each kernel will have a specific configuration file that is used to set the desired options, and then the kernel will be built with reference to the desired configuration file. The configuration files are found in the source code tree, in the directory usr/src/sys/arch/amd64/conf/, for example. For i386 you would replace "amd64" with "i386".

For example, the generic kernel distributed with the system is configured by the file called GENERIC.

With that background, to answer your first question, you would look into the configuration file used to compile the binary kernel in question. If you're using a kernel supplied with the system this can be found on the web, e.g.,

http://ftp.netbsd.org/pub/NetBSD/Net...4/conf/GENERIC

For the second question: If you want to change option values, or enable/disable options, then you need to create a new configuration file with all the options you want in it. This would often be done by taking an existing config file, like GENERIC, and editing it a bit. Then you would compile a new kernel using the new configuration file.

To learn more about all this you can study the NetBSD Guide, Section 32 Compiling the kernel .

Hope that helps.

Last edited by IdOp; 12th November 2019 at 03:05 PM. Reason: pre-pend usr/ to directory; wording
Reply With Quote
  #3   (View Single Post)  
Old 12th November 2019
notooth notooth is offline
Shell Scout
 
Join Date: Jul 2015
Posts: 125
Default

Thank you for the information.
Reply With Quote
  #4   (View Single Post)  
Old 12th November 2019
IdOp's Avatar
IdOp IdOp is offline
Too dumb for a smartphone
 
Join Date: May 2008
Location: twisting on the daemon's fork(2)
Posts: 1,027
Default

You're welcome. I wanted to add one other thing. The default configuration files are also found in the system source archive file syssrc.tgz . It's a pretty big file, so it may be easier just to look at the config file on the web as I suggested. But if you're compiling kernels, you already have it on your disk.
Reply With Quote
  #5   (View Single Post)  
Old 12th November 2019
notooth notooth is offline
Shell Scout
 
Join Date: Jul 2015
Posts: 125
Default

I got it. Thanks.
Reply With Quote
  #6   (View Single Post)  
Old 21st March 2020
Sehnsucht94's Avatar
Sehnsucht94 Sehnsucht94 is offline
Real Name: Paolo Vincenzo Olivo
Package Pilot
 
Join Date: Oct 2017
Location: Rome
Posts: 169
Default

Quote:
Originally Posted by IdOp View Post
With that background, to answer your first question, you would look into the configuration file used to compile the binary kernel in question. If you're using a kernel supplied with the system this can be found on the web, e.g.,

http://ftp.netbsd.org/pub/NetBSD/Net...4/conf/GENERIC.

Quote:
Originally Posted by IdOp View Post
You're welcome. I wanted to add one other thing. The default configuration files are also found in the system source archive file syssrc.tgz . It's a pretty big file, so it may be easier just to look at the config file on the web as I suggested. But if you're compiling kernels, you already have it on your disk.

TBH, there's no need to either fetch the GENERIC config remotely or extract syssrc.tgz just to get the file, as config(1) can extract the configuration embedded in a loaded kernel ELF at any time with the -x option, and print it to stdout;


For a quick config lookup, I keep this in my ~/.shrc:
Code:
chkconf() {
        echo "Which option would you like to check?"
        read VAR
        if config -x /netbsd | grep -q $VAR; then
                echo found  
        else
                echo not found
        fi
}
__________________
“Mi casa tendrá dos piernas y mis sueños no tendrán fronteras„
Reply With Quote
  #7   (View Single Post)  
Old 22nd March 2020
IdOp's Avatar
IdOp IdOp is offline
Too dumb for a smartphone
 
Join Date: May 2008
Location: twisting on the daemon's fork(2)
Posts: 1,027
Default

Excellent info, thank you Sensucht94 !
Reply With Quote
  #8   (View Single Post)  
Old 22nd March 2020
Sehnsucht94's Avatar
Sehnsucht94 Sehnsucht94 is offline
Real Name: Paolo Vincenzo Olivo
Package Pilot
 
Join Date: Oct 2017
Location: Rome
Posts: 169
Default

Anytime 😜
PS: in order for the config to be embedded in a custom kernel, option INCLUDE_CONFIG_FILE is needed (enabled by default in GENERIC)
__________________
“Mi casa tendrá dos piernas y mis sueños no tendrán fronteras„
Reply With Quote
  #9   (View Single Post)  
Old 22nd March 2020
Sehnsucht94's Avatar
Sehnsucht94 Sehnsucht94 is offline
Real Name: Paolo Vincenzo Olivo
Package Pilot
 
Join Date: Oct 2017
Location: Rome
Posts: 169
Default

Quote:
Originally Posted by IdOp View Post
For the second question: If you want to change option values, or enable/disable options, then you need to create a new configuration file with all the options you want in it. This would often be done by taking an existing config file, like GENERIC, and editing it a bit. Then you would compile a new kernel using the new configuration file.
By the way, I use this awk script on new hardware to strip down GENERIC of unneeded options; it simply relies on dmesg(8) to grasp the list of currently attached drivers.

Dropping it here as it may come in handy to others; it's by no means the perfect tool to automate the process, but at least returns a first draft for ad-hoc configurations
Code:
#!/bin/sh

if [ "X"$1 = X"-s" ]; then
    shift; VS="-v strip=1"
fi

/usr/bin/awk `echo ${VS:-"-v strip=0"}` '
BEGIN {
  progname = "deconf";
  comment_chars  = "#-#";

  if (ARGC < 2) {
    print "Usage: " progname " [-s] GENERIC_FILE";
    print "Reading dmesg(8) output from standart input" \
     " and output config template.";
    bailout = 1; exit;
  }

  if ((getline < (gen = ARGV[1])) == -1) {
    print progname ": " gen ": not found or not readable" > "/dev/stderr";
    bailout = 1; exit;
  }
  close(gen);

  ARGV[1] = "-"; # read output from dmesg from standart input
}

/^[a-z]+[0-9]+[ ]+at[ ]+[a-z]+[0-9]+/ {
  sub(/:$/, "", $3);
  dmesg[$1] = $3;
}

END {
  if (bailout) exit(1);

  while(getline < gen) {
    if (match($0, /^[a-z]+[*?0-9]+[ \t]+at[ \t]+[a-z]+[*?0-9]+/)) {
    split(substr($0, RSTART, RLENGTH), spec);
    gdev = ggdev = spec[1]; gwhere = ggwhere = spec[3];
    matches = 0;
    sub(/[*?0-9]+$/, "", ggdev);
    sub(/[*?0-9]+$/, "", ggwhere);
    for(s in dmesg) {
      if ((substr(s, 1, length(s)-1) == ggdev) &&
          (substr(dmesg[s], 1, length(dmesg[s])-1) == ggwhere)) {
        #print gdev " -> " gwhere " : " s " -> " dmesg[s];
        if ((gdev ~ /[*?]+$/ && gwhere ~ /[*?]+$/) ||
        (gdev == s && gwhere ~ /[*?]+$/)  ||
        (gdev == s && gwhere == dmesg[s]) ||
        (gdev ~ /[*?]+$/ && gwhere == dmesg[s])) {
          matches++; delete dmesg[s];
          continue;
        }
      }
      # phys can have any parent
      if ((substr(s, 1, length(s)-1) == ggdev) && ggwhere == "mii") {
        matches++; delete dmesg[s];
      }
    }
    if (matches == 0) { if (!strip) print comment_chars $0; } else print;
    }
    else {
      if ((/^[ \t]*$/ || /^[ \t]*#/) && strip) continue;
      print;
    }
  }
  close(gen);

  matches = 0; for(s in dmesg) matches++;
  if (matches) {
    print "\n# deconfig orphaned records: ";
    for(s in dmesg) { print "#" s " at " dmesg[s]; }
  }
}
' $@
__________________
“Mi casa tendrá dos piernas y mis sueños no tendrán fronteras„
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
enable php in apache2 MatthiasKoch OpenBSD Packages and Ports 2 30th September 2016 11:54 AM
OpenBSD 5.0 - How to enable dfs ? mayuka OpenBSD General 5 13th November 2011 07:09 AM
Enable SNMP? dzudja100 FreeBSD Ports and Packages 1 20th May 2010 05:52 PM
boot bug with USB enable nORKy FreeBSD Installation and Upgrading 5 12th June 2008 04:56 PM


All times are GMT. The time now is 09:38 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick