Difference between revisions of "Kenv"

From GhostBSD Wiki
Jump to: navigation, search
 
(4 intermediate revisions by the same user not shown)
Line 4: Line 4:
 
==Introduction==
 
==Introduction==
  
With kenv you can dump or modify the kernel environment.
+
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==
 
==Usage==
  
If you you write
 
  
<code>>kenv</code>
 
  
 +
===Kenv without options===
 +
If you you write:  <code>kenv</code>
 
in your terminal, you will get the complete ''kernel environment'' tree.
 
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.
 
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''   
 
Kernel environment variables can be set in the ''/boot/loader.conf''   
  
There are following options:
+
===Options===
 +
 
 +
'''There are following options:'''
 
* <code>>kenv -h</code> ''-h'' will limit the report to kernel probe hints.
 
* <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 an optional ''variable name'' is specified, kenv will  only report that value.
Line 34: Line 278:
 
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.
 
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.
  
 
+
|}
  
  

Latest revision as of 07:20, 11 March 2020

Welcome to Icon Disti GhostBSD.png Kenv.
Kernel Competence
Sysctl Kldstat Third-party Kernel Modules
Kernel Modules FreeBSD Ports: Kld Kenv
Compiling a new GhostBSD kernel
Back to the Icon Disti GhostBSD.pngSystem

Introduction[edit]

With kenv(1) you can dump or modify the kernel environment. The 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[edit]

Kenv without options[edit]

If you you write: kenv 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
/u/h/yourusername> kenv

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[edit]

There are following options:

  • >kenv -h -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

env filename

in the kernel config file. The file can contain lines of the form name = value # this is a comment

where whitespace around `name' and `=', and everything after a `# ' 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[edit]

The action argument can be one of the following:

Action 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.