Editing Kenv

Jump to: navigation, search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 2: Line 2:
 
{{Navbar Kernel Competence}}
 
{{Navbar Kernel Competence}}
  
==Introduction==
 
  
With [https://www.freebsd.org/cgi/man.cgi?kenv(1) kenv(1)] you can dump or modify the kernel environment.
 
The [https://www.freebsd.org/cgi/man.cgi?query=kenv&sektion=2&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports kenv(2)] system call manipulates kernel environment variables.  It supports the well known userland actions of getting, setting and unsetting  environment variables, as well as the ability to dump all of the entries  in the kernel environment.
 
  
==Usage==
 
  
  
  
===Kenv without options===
 
If you you write:  <code>kenv</code>
 
in your terminal, you will get the complete ''kernel environment'' tree.
 
These variables are the loader variables and relate to initial hardware probes. The right decision has to be made before anything in the kernel accesses the specific hardware.
 
 
'''Example'''<br/>
 
/u/h/yourusername> '''kenv<br/>
 
{|class="wikitable" style="width:75.5%;background:#FFFFFF; border:2px solid #008000;text-align:left;padding: 10px"
 
|-
 
|LINES="24"
 
|-
 
|acpi.oem="ACPIAM"
 
|-
 
|acpi.revision="1"
 
|-
 
|acpi.rsdp="0x000facd0"
 
|-
 
|acpi.rsdt="0xcffa0000"
 
|-
 
|acpi_load="YES"
 
|-
 
|autoboot_delay="02"
 
|-
 
|boot_mute="YES"
 
|-
 
|bootenv_autolist="YES"
 
|-
 
|bootenvs[0]="zfs:tank/ROOT/initial"
 
|-
 
|bootenvs_count="1"
 
|-
 
|bootfile="kernel"
 
|-
 
|comconsole_pcidev=""
 
|-
 
|comconsole_port="1016"
 
|-
 
|comconsole_speed="9600"
 
|-
 
|console="vidconsole"
 
|-
 
|currdev="zfs:tank/ROOT/initial:"
 
|-
 
|efi_max_resolution="1x1"
 
|-
 
|hint.acpi.0.disabled="0"
 
|-
 
|hint.acpi.0.oem="ACPIAM"
 
|-
 
|hint.acpi.0.revision="1"
 
|-
 
|hint.acpi.0.rsdp="0x000facd0"
 
|-
 
|hint.acpi.0.rsdt="0xcffa0000"
 
|-
 
|hint.acpi_throttle.0.disabled="1"
 
|-
 
|hint.atkbd.0.at="atkbdc"
 
|-
 
|hint.atkbd.0.irq="1"
 
|-
 
|hint.atkbdc.0.at="isa"
 
|-
 
|hint.atkbdc.0.port="0x060"
 
|-
 
|hint.atrtc.0.at="isa"
 
|-
 
|hint.atrtc.0.irq="8"
 
|-
 
|hint.atrtc.0.port="0x70"
 
|-
 
|hint.attimer.0.at="isa"
 
|-
 
|hint.attimer.0.irq="0"
 
|-
 
|hint.attimer.0.port="0x40"
 
|-
 
|hint.fd.0.at="fdc0"
 
|-
 
|hint.fd.0.drive="0"
 
|-
 
|hint.fd.1.at="fdc0"
 
|-
 
|hint.fd.1.drive="1"
 
|-
 
|hint.fdc.0.at="isa"
 
|-
 
|hint.fdc.0.drq="2"
 
|-
 
|hint.fdc.0.irq="6"
 
|-
 
|hint.fdc.0.port="0x3F0"
 
|-
 
|hint.p4tcc.0.disabled="1"
 
|-
 
|hint.ppc.0.at="isa"
 
|-
 
|hint.ppc.0.irq="7"
 
|-
 
|hint.psm.0.at="atkbdc"
 
|-
 
|hint.psm.0.irq="12"
 
|-
 
|hint.sc.0.at="isa"
 
|-
 
|hint.sc.0.flags="0x100"
 
|-
 
|hint.uart.0.at="isa"
 
|-
 
|hint.uart.0.flags="0x10"
 
|-
 
|hint.uart.0.irq="4"
 
|-
 
|hint.uart.0.port="0x3F8"
 
|-
 
|hint.uart.1.at="isa"
 
|-
 
|hint.uart.1.irq="3"
 
|-
 
|hint.uart.1.port="0x2F8"
 
|-
 
|hw.memtest.tests="0"
 
|-
 
|hw.psm.synaptics_support="1"
 
|-
 
|hw.usb.no_boot_wait="1"
 
|-
 
|kern.geom.eli.visible_passphrase="2"
 
|-
 
|kernel="kernel"
 
|-
 
|kernel_options=""
 
|-
 
|kernel_path="/boot/kernel"
 
|-
 
|kernelname="/boot/kernel/kernel"
 
|-
 
|kernels_autodetect="YES"
 
|-
 
|legal.intel_ipw.license_ack="1"
 
|-
 
|legal.intel_iwi.license_ack="1"
 
|-
 
|legal.realtek.license_ack="1"
 
|-
 
|loaddev="zfs:tank/ROOT/initial:"
 
|-
 
|loader_brand="ghostbsd"
 
|-
 
|loader_conf_files="/boot/device.hints /boot/loader.conf /boot/loader.conf.local"
 
|-
 
|loader_logo="ghostbsd"
 
|-
 
|loader_menu_title="Welcome to GhostBSD"
 
|-
 
|module_blacklist="drm drm2 radeonkms i915kms amdgpu"
 
|-
 
|module_path="/boot/kernel;/boot/modules;/boot/dtb;/boot/dtb/overlays"
 
|-
 
|net.inet.ip.fw.default_to_accept="1"
 
|-
 
|nextboot_conf="/boot/nextboot.conf"
 
|-
 
|nextboot_enable="NO"
 
|-
 
|pcibios.config1="1"
 
|-
 
|pcibios.config2="0"
 
|-
 
|pcibios.major="3"
 
|-
 
|pcibios.maxbus="5"
 
|-
 
|pcibios.minor="0"
 
|-
 
|rc_system="openrc"
 
|-
 
|script.lang="lua"
 
|-
 
|smbios.bios.reldate="07/07/2009"
 
|-
 
|smbios.bios.vendor="American Megatrends Inc."
 
|-
 
|smbios.bios.version="080015 "
 
|-
 
|smbios.chassis.maker="ECS"
 
|-
 
|smbios.chassis.serial="                      "
 
|-
 
|smbios.chassis.tag="                      "
 
|-
 
|smbios.chassis.version="                      "
 
|-
 
|smbios.memory.enabled="4194304"
 
|-
 
|smbios.planar.location="                      "
 
|-
 
|smbios.planar.maker="ECS"
 
|-
 
|smbios.planar.product="GF8100VM-M5"
 
|-
 
|smbios.planar.serial="                      "
 
|-
 
|smbios.planar.tag="                      "
 
|-
 
|smbios.planar.version="1.0                  "
 
|-
 
|smbios.socket.enabled="1"
 
|-
 
|smbios.socket.populated="1"
 
|-
 
|smbios.system.family="                      "
 
|-
 
|smbios.system.maker="ECS"
 
|-
 
|smbios.system.product="GF8100VM-M5"
 
|-
 
|smbios.system.serial="                      "
 
|-
 
|smbios.system.sku="                      "
 
|-
 
|smbios.system.uuid="03000200-0400-0500-0006-000700080009"
 
|-
 
|smbios.system.version="1.0"
 
|-
 
|smbios.version="2.6"
 
|-
 
|twiddle_divisor="1"
 
|-
 
|verbose_loading="NO"
 
|-
 
|vfs.root.mountfrom="zfs:tank/ROOT/initial"
 
|-
 
|vfs.zfs.arc_max="512M"
 
|-
 
|vfs.zfs.boot.primary_pool="2274887038975416023"
 
|-
 
|vfs.zfs.boot.primary_vdev="13128611794753525809"
 
|-
 
|zfs_be_active="zfs:tank/ROOT/initial"
 
|-
 
|zfs_be_currpage="1"
 
|-
 
|zfs_be_root="tank/ROOT"
 
|}
 
 
Kernel environment variables can be set in the ''/boot/loader.conf'' 
 
 
===Options===
 
 
'''There are following options:'''
 
* <code>>kenv -h</code> ''-h'' will limit the report to kernel probe hints.
 
* If an optional ''variable name'' is specified, kenv will  only report that value.
 
* If the ''-N'' option is specified, kenv will only display variable names and not their values.
 
* If the ''-u'' option is specified, kenv will delete the given environment variable.  If the environment variable is followed by an optional value, kenv will set the environment variable to this value.
 
* If the ''-q'' option is set, warnings normally printed as a result of being unable to perform the requested operation will be suppressed.
 
* If the ''-v'' option is set, the variable name will be printed out for the environment variable in addition to the value when kenv is executed with a variable name.
 
 
Variables can be added to the kernel environment using the    /boot/loader.conf file, or also statically compiled into the kernel using the statement
 
 
<code>env ''filename''</code>
 
 
in the kernel config file. The file can contain lines of the form
 
<code>  name = value </code> <nowiki># </nowiki>this is a comment
 
 
where whitespace around `name' and `=', and everything after a `<nowiki># </nowiki>' character, are ignored.  Almost any printable character except `=' is accept able as part of a name.  Quotes are optional and necessary only if the  value contains whitespace.
 
 
'''Attention''': The kernel environment variables are also tunable. Before you play with them, reed the man pages. It is possible to crash your system with a false value.
 
 
===The Action Argument===
 
 
The action argument can be one of the following:
 
 
{|class="wikitable" style="width:96.5%;background:#FFFFFF; border:2px solid #008000;text-align:left;padding: 10px"
 
|-
 
!scope="col" style="width: 100px;"|'''Action'''
 
!scope="col" style="width: 500px;"|'''Desciption'''
 
|-
 
|KENV_GET || Get the value of the variable with the given name.  The size
 
of the value buffer is given by len, which should be at least
 
KENV_MVALLEN + 1 bytes to avoid truncation and to ensure NUL
 
termination.
 
|-
 
|    KENV_SET|| Set or add a variable. The name and value are limited to
 
KENV_MNAMELEN and KENV_MVALLEN characters, respectively (not
 
including the NUL terminator.) The len argument indicates the
 
length of the value and must include the NUL terminator.
 
This option is only available to the superuser.
 
|-
 
|KENV_UNSET || Unset the variable with the given name.  The value and len
 
arguments are ignored. This option is only available to the
 
superuser.
 
|-
 
|KENV_DUMP || Dump as much of the kernel environment as will fit in value,
 
whose size is given in len.  If value is NULL, kenv() will
 
return the number of bytes required to copy out the entire
 
environment.  The name is ignored.
 
 
|}
 
  
  

Please note that all contributions to GhostBSD Wiki are considered to be released under the Creative Commons Attribution (see GhostBSD Wiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To edit this page, please answer the question that appears below (more info):

Cancel | Editing help (opens in new window)