Editing OpenRC

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 1: Line 1:
 
{{welcome}}
 
{{welcome}}
{{Navbar GhostBSD Boot Process}}
+
{{Navbar System}}
 
{{Navbar OpenRC}}
 
{{Navbar OpenRC}}
  
 
==Introduction==
 
==Introduction==
 
+
OpenRC is a dependency-based ''init system'' that works with the system-provided init program, normally ''/sbin/init''. Currently, it does not have an init program of its own. It does not function as a replacement for the /sbin/init file. OpenRC is located on /sbin/openrc.
'''OpenRC''' is a dependency-based ''init system'' that works with the system-provided init program, normally ''/sbin/init''. Currently, it does not have an init program of its own. It does not function as a replacement for the /sbin/init file. OpenRC is located on /sbin/openrc.
+
  
 
There are  105 [https://github.com/OpenRC/openrc/graphs/contributors contributors on GitHub].
 
There are  105 [https://github.com/OpenRC/openrc/graphs/contributors contributors on GitHub].
  
 
GhostBSD/FreeBSD provides for booting from both the older MBR standard and the newer GUID Partition Table (GPT).
 
GhostBSD/FreeBSD provides for booting from both the older MBR standard and the newer GUID Partition Table (GPT).
Once the kernel boot process is finished, the kernel passes control to the user process [https://www.freebsd.org/cgi/man.cgi?query=init&sektion=8&manpath=freebsd-release-ports init(8)], which is located at ''/sbin/init''.  The '''[[/boot/defaults/loader.conf]]''' states as GhostBSD defaults: ''rc_system="openrc".''
+
Once the kernel boot process is finished, the kernel passes control to the user process [https://www.freebsd.org/cgi/man.cgi?query=init&sektion=8&manpath=freebsd-release-ports init(8)], which is located at ''/sbin/init''.  The ''/boot/defaults/loader.conf'' states as GhostBSD defaults: ''rc_system="openrc".''
  
 
The loader is the final stage of the three-stage bootstrap process. It is located on the file system, usually as ''/boot/loader.''
 
The loader is the final stage of the three-stage bootstrap process. It is located on the file system, usually as ''/boot/loader.''
  
The loader will read ''/boot/loader.rc,'' which by default reads in '''[[/boot/defaults/loader.conf]]''' which sets reasonable defaults for variables and reads '''[[/boot/loader.conf]]''' for local changes to those variables. loader.rc then acts on these variables, loading whichever modules and kernel are selected.
+
The loader will read ''/boot/loader.rc,'' which by default reads in ''/boot/defaults/loader.conf'' which sets reasonable defaults for variables and reads ''/boot/loader.conf'' for local changes to those variables. loader.rc then acts on these variables, loading whichever modules and kernel are selected.
 
+
A very useful command to edit rc files is '''[[Sysrc|sysrc]]'''.
+
  
 
==Installation==
 
==Installation==
Line 95: Line 92:
 
==Scripts to run OpenRC==
 
==Scripts to run OpenRC==
  
Scripts to run OpenRC are located on '''/etc/[[init.d]]/''' and '''/usr/[[local/etc/init.d]]'''.
+
Scripts to run OpenRC are located on ''/etc/[[init.d]]/''.
  
 
==OpenRC Users Guide==
 
==OpenRC Users Guide==
Line 141: Line 138:
 
'''OpenRC''' has a concept of runlevels, similar to what sysvinit historically offered. A runlevel is basically a collection of services that needs to be started. Instead of random numbers they are named, and users can create their own if needed. This allows, for example, to have a default runlevel with "everything" enabled, and a "powersaving" runlevel where some services are disabled.
 
'''OpenRC''' has a concept of runlevels, similar to what sysvinit historically offered. A runlevel is basically a collection of services that needs to be started. Instead of random numbers they are named, and users can create their own if needed. This allows, for example, to have a default runlevel with "everything" enabled, and a "powersaving" runlevel where some services are disabled.
  
The '''[[rc-status]]''' helper will print all currently active runlevels and the state of services in them.
+
The rc-status helper will print all currently active runlevels and the state of services in them:
  
All runlevels are represented as folders in ''/etc/runlevels/'' with symlinks to the actual service scripts.<br/>
+
<nowiki># rc-status</nowiki>
All services must reside in the '''/etc/[[Init.d|init.d]]''' or '''/usr/[[Local/etc/init.d|local/etc/init.d]]''' directories. They must also conform to the '''OpenRC''' runscript standard.
+
* Caching service dependencies ... [ ok ]
 +
* Runlevel: default
 +
* modules                    [  started  ]
 +
* lvm                        [ started  ]
  
Calling '''OpenRC''' with an argument (openrc default) will switch to that runlevel; this will start and stop services as needed.
+
All runlevels are represented as folders in ''/etc/runlevels/'' with symlinks to the actual service scripts.
  
Managing runlevels is usually done through the '''[[rc-update]]''' helper, but could of course be done by hand if desired. e.g. ''rc-update add foo default'' - add foo to the default runlevel '''Note:''' This will not auto-start foo! You'd still have to trigger rc or run the service script by hand.
+
Calling OpenRC with an argument (openrc default) will switch to that runlevel; this will start and stop services as needed.
 +
 
 +
Managing runlevels is usually done through the ''rc-update helper'', but could of course be done by hand if desired. e.g. ''rc-update add nginx default'' - add nginx to the default runlevel '''Note:''' This will not auto-start nginx! You'd still have to trigger rc or run the service script by hand.
  
 
FIXME: Document stacked runlevels
 
FIXME: Document stacked runlevels
Line 187: Line 189:
 
Setting ''ulimit'' and nice values per service can be done through the ''rc_ulimit'' variable.
 
Setting ''ulimit'' and nice values per service can be done through the ''rc_ulimit'' variable.
  
Under Linux, OpenRC can use cgroups for process management as well. Once the kernel is configured appropriately, the ''rc_cgroup_mode'' setting in '''/etc/[[Rc.conf|rc.conf]]''' should be used to control whether ''cgroups'' version one, two, or both are used. The default is to use both if they are available.
+
Under Linux, OpenRC can use cgroups for process management as well. Once the kernel is configured appropriately, the ''rc_cgroup_mode'' setting in ''/etc/rc.conf'' should be used to control whether ''cgroups'' version one, two, or both are used. The default is to use both if they are available.
  
By changing certain settings in the service's ''conf.d'' file limits can be enforced per service. These settings are documented in detail in the default '''/etc/[[Rc.conf|rc.conf]]''' under LINUX CGROUPS RESOURCE MANAGEMENT.
+
By changing certain settings in the service's ''conf.d'' file limits can be enforced per service. These settings are documented in detail in the default ''/etc/rc.conf'' under LINUX CGROUPS RESOURCE MANAGEMENT.
  
 
===Dealing with Orphaned Processes===
 
===Dealing with Orphaned Processes===
Line 213: Line 215:
  
 
===Additional Directories, Programs and Files related to OpenRC===
 
===Additional Directories, Programs and Files related to OpenRC===
 
In this directory we collect files are not described above yet.
 
  
 
{|class="wikitable" style="width:96.5%;background:#FFFFFF; border:2px solid #008000;text-align:left;padding: 10px"  
 
{|class="wikitable" style="width:96.5%;background:#FFFFFF; border:2px solid #008000;text-align:left;padding: 10px"  
Line 221: Line 221:
 
! scope="col" style="width: 350px;"|'''Description'''
 
! scope="col" style="width: 350px;"|'''Description'''
 
|-
 
|-
|/boot/loader.rc||Includes additional commands; Load boot menu; Start the boot menu
+
|/bin/rc-status||
 
|-
 
|-
|/boot/loader.rc.local||set 0
+
|/etc/rc.d/   ||system and daemon startup/control scripts; see [https://www.freebsd.org/cgi/man.cgi?query=rc&sektion=8&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports rc(8)]
|-
+
|/etc/devd-openrc||Contains the following files: asus.conf, devmatch-openrc.conf, hyperv.conf, uath.conf, ulpt.conf, and zfs.conf
+
 
|-
 
|-
 
|/etc/openrc.shutdown||[https://manpages.debian.org/testing/openrc/openrc-shutdown.8.en.html openrc-shutdown] is the utility that communicates with [https://manpages.debian.org/testing/openrc/openrc-init.8.en.html openrc-init(8)] to bring down the system or instruct openrc-init to re-execute itself.
 
|/etc/openrc.shutdown||[https://manpages.debian.org/testing/openrc/openrc-shutdown.8.en.html openrc-shutdown] is the utility that communicates with [https://manpages.debian.org/testing/openrc/openrc-init.8.en.html openrc-init(8)] to bring down the system or instruct openrc-init to re-execute itself.
Line 245: Line 243:
 
|-
 
|-
 
|/etc/rc.suspend||If drivers can be properly loaded and unloaded, automate this by putting the appropriate commands in [https://www.freebsd.org/doc/handbook/acpi-overview.html /etc/rc.suspend] and /etc/rc.resume.
 
|/etc/rc.suspend||If drivers can be properly loaded and unloaded, automate this by putting the appropriate commands in [https://www.freebsd.org/doc/handbook/acpi-overview.html /etc/rc.suspend] and /etc/rc.resume.
 +
|-
 +
|/sbin/openrc||The [https://github.com/OpenRC/openrc OpenRC] is a dependency-based init system that works with the system-provided init program, normally /sbin/init. Currently, it does not have an init program of its own. A good documentation you will find on [https://wiki.gentoo.org/wiki/OpenRC gentoo]
 
|-
 
|-
 
|/sbin/openrc-run||[https://manpages.debian.org/testing/openrc/openrc-run.8.en.html openrc-run] is basically an interpreter for shell scripts which provides an easy interface to the often complex system commands and daemons. When a service runs a command it first loads its multiplexed configuration file, then its master configuration file, then /etc/rc.conf and finally the script itself. At this point openrc-run then runs the command given.  
 
|/sbin/openrc-run||[https://manpages.debian.org/testing/openrc/openrc-run.8.en.html openrc-run] is basically an interpreter for shell scripts which provides an easy interface to the often complex system commands and daemons. When a service runs a command it first loads its multiplexed configuration file, then its master configuration file, then /etc/rc.conf and finally the script itself. At this point openrc-run then runs the command given.  
 +
|-
 +
|/sbin/rc||[https://www.freebsd.org/cgi/man.cgi?query=rc&apropos=0&sektion=0&manpath=FreeBSD+12.1-RELEASE+and+Ports&arch=default&format=html rc]  is a command interpreter and programming language similar to [https://www.freebsd.org/cgi/man.cgi?query=sh&sektion=1&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports sh(1).]
 +
It is based on the AT&T Plan 9 shell of the same name.  The  shell  offers  a C-like syntax (much more so than the C shell), and a powerful mechanism for manipulating variables.  It is reasonably small and  reasonably fast, especially when compared to contemporary shells.  Its use is intended to be interactive, but the language lends  itself  well  to  scripts.
 +
|-
 +
|/sbin/rc-service||[https://github.com/OpenRC/openrc OpenRC  services].
 +
|-
 +
|/sbin/rc-update||update  [https://github.com/OpenRC/openrc OpenRC]
 +
|-
 +
|/sbin/rcorder|| The [https://www.freebsd.org/cgi/man.cgi?query=rcorder&apropos=0&sektion=0&manpath=FreeBSD+12.1-RELEASE+and+Ports&arch=default&format=html rcorder] utility is designed to print out a dependency ordering of a      set of interdependent files.  Typically it is used to find an execution    sequence for a set of shell scripts in which certain files must be executed before others.
 +
|-
 +
|/sbin/rdump||The [https://www.freebsd.org/cgi/man.cgi?query=rdump&apropos=0&sektion=0&manpath=FreeBSD+12.1-RELEASE+and+Ports&arch=default&format=html dump] utility examines files on a file system and determines which      files need to be backed up.  These files are copied to the given disk,    tape or other storage medium for safe keeping (see the -f option below
 +
for doing remote backups).
 
|}
 
|}
  

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)