- Init system in linux
- Contents
- Inits (integrated)
- Inits
- Init scripts
- Service managers
- Configuration
- Migrate running services
- logind
- Scheduled tasks
- Tips and tricks
- systemd-nspawn
- 5 Best Modern Linux ‘init’ Systems (1992-2015)
- 1. System V Init
- 2. SystemD
- 3. Upstart
- 4. OpenRC
- 5. runit
- If You Appreciate What We Do Here On TecMint, You Should Consider:
- 6 шагов загрузки Linux на пальцах
- 1. BIOS
- 2. MBR
- 3. GRUB
- 4. Ядро или Kernel
- 5. Init
- 6. Уровень выполнения программ (Runlevel)
- Дополнения, исправления, уточнения
Init system in linux
Init is the first process started during system boot. It is a daemon process that continues running until the system is shut down. Init is the direct or indirect ancestor of all other processes, and automatically adopts all orphaned processes. It is started by the kernel using a hard-coded filename; if the kernel is unable to start it, panic will result. Init is typically assigned process identifier 1.
The init scripts (or rc) are launched by the init process to guarantee basic functionality on system start and shutdown. This includes (un)mounting of file systems and launching of daemons. A service manager takes this one step further by providing active control over launched processes, or process supervision. An example is to monitor for crashes and restart processes accordingly.
These components combine to the init system. Some inits include the service manager in the init process, or have init scripts in close relation to them. These inits are below referred to as integrated, though entries in different categories may explicitly depend on each other.
Contents
Inits (integrated)
- anopa — Init system built around the s6 supervision suite.
https://jjacky.com/anopa/ || anopaAUR
- GNU Shepherd — Init system written in Guile.
https://www.gnu.org/software/shepherd/ || shepherdAUR
- OpenRC — Dependency-based init system.
https://www.gentoo.org/proj/en/base/openrc/ || openrcAURopenrc-arch-services-gitAUR
- systemd — Dependency-based init system with aggressive parallelization, process supervision using cgroups, and the ability to depend on a given mount point or dbus service.
https://freedesktop.org/wiki/Software/systemd/ || systemd
Inits
- BusyBox — Utilities for rescue and embedded systems.
https://busybox.net/ || busybox
- sinit — Simple init initially based on Rich Felker’s minimal init.
https://core.suckless.org/sinit || sinitAUR
- SysVinit — Traditional System V init.
https://savannah.nongnu.org/projects/sysvinit || sysvinitAUR
Init scripts
- initscripts-fork — Maintained fork of SysVinit scripts in Arch Linux.
https://bitbucket.org/TZ86/initscripts-fork/overview || initscripts-forkAUR
- minirc — Minimal init script designed for BusyBox.
https://github.com/hut/minirc/ || minirc-gitAUR
- kisslinux-init — Init framework of KISS Linux.
https://github.com/kisslinux/init || kisslinux-initAUR
Service managers
- daemontools — Collection of tools for managing UNIX services.
https://cr.yp.to/daemontools.html || daemontoolsAUR
- Monit — Monit is a process supervision tool for Unix and Linux. With monit, system status can be viewed directly from the command line, or via the native HTTP(S) web server.
https://mmonit.com/monit/ || monit
- perp — Persistent process (service) supervisor and management framework for UNIX.
http://b0llix.net/perp/ || perpAUR
- runit — UNIX init scheme with service supervision, a replacement for SysVinit, and other init schemes.
http://smarden.org/runit/ || busybox
- s6 — Small suite of programs for UNIX, designed to allow service supervision in the line of daemontools and runit.
https://skarnet.org/software/s6/ || s6AUR
- Supervisor — A system that allows its users to monitor and control processes on UNIX-like operating systems.
https://supervisord.org/ || supervisor
Configuration
Migrate running services
To run daemons under the new init, save a list of running daemons:
and configure the #Init scripts accordingly. See also [2].
logind
logind requires systemd to be the init process. [3] As such, local sessions and other functionality is not available.
Add users to respective user groups for device access and reboot. Current group membership should first be checked with id user .
As Xorg.wrap does not check if logind is active [5], root rights for Xorg need be enabled manually:
Scheduled tasks
Arch uses timer files instead of cron by default. See archlinux-cronjobs for basic cron jobs.
This article or section needs expansion.
User instances of dbus-daemon are launched by systemd/User [6]. When requiring IPC between desktop applications, restore 30-dbus.sh :
Tips and tricks
systemd-nspawn
systemd-nspawn is a tool for systemd systems. Since Linux 2.6.19 it is however possible to run systemd on a non-systemd system by using PID namespace. For it, the kernel needs to be configured with CONFIG_PID_NS and CONFIG_NAMESPACES ).
The PID namespace creates a new hierarchy of processes starting with PID 1. In addition to this, systemd requires a chrooted root filesystem to be mounted. Hence, you have to at least make a bind mount, because otherwise some services will fail with
as systemd tries to remount the root with private option.
To setup a chroot with a new PID namespace you can use jchroot.[7] [8]. Make sure not to mount /proc inside the new root before chrooting, otherwise systemd will detect the chroot environment. You can mount it later once systemd is running.
Источник
5 Best Modern Linux ‘init’ Systems (1992-2015)
In Linux and other Unix-like operating systems, the init (initialization) process is the first process executed by the kernel at boot time. It has a process ID (PID) of 1, it is executed in the background until the system is shut down.
The init process starts all other processes, that is daemons, services and other background processes, therefore, it is the mother of all other processes on the system. A process can start many other child processes on the system, but in the event that a parent process dies, init becomes the parent of the orphan process.
Linux init Systems (1992-2015)
Over the years, many init systems have emerged in major Linux distributions and in this guide, we shall take a look at some of the best init systems you can work with on the Linux operating system.
1. System V Init
System V (SysV) is a mature and popular init scheme on Unix-like operating systems, it is the parent of all processes on a Unix/Linux system. SysV is the first commercial Unix operating system designed.
Almost all Linux distributions first used SysV init scheme except Gentoo which has a custom init and Slackware using BSD-style init scheme.
As years have passed by, due to some imperfections, several SysV init replacements have been developed in quests to create more efficient and perfect init systems for Linux.
Although these alternatives seek to improve SysV and probably offer new features, they are still compatible with original SysV init scripts.
2. SystemD
SystemD is a relatively new init scheme on the Linux platform. Introduced in Fedora 15, its is an assortment of tools for easy system management. The main purpose is to initialize, manage and keep track of all system processes in the boot process and while the system is running.
Systemd init is comprehensively distinct from other traditional Unix init systems, in the way it practically approaches system and services management. It is also compatible with SysV and LBS init scripts.
It has some of the following eminent features:
- Clean, straightforward and efficient design
- Concurrent and parallel processing at bootup
- Better APIv
- Enables removal of optional processes
- Supports event logging using journald
- Supports job scheduling using systemd calender timers
- Storage of logs in binary files
- Preservation of systemd state for future reference
- Better integration with GNOME plus many more
3. Upstart
Upstart is an event-based init system developed by makers of Ubuntu as a replacement for SysV init system. It starts different system tasks and processes, inspects them while the system is running and stops them during system shut down.
It is a hybrid init system which uses both SysV startup scripts and also Systemd scripts, some of the notable features of Upstart init system include:
- Originally developed for Ubuntu Linux but can run on all other distributions
- Event-based starting and stopping of tasks and services
- Events are generated during starting and stopping of tasks and services
- Events can be sent by other system processes
- Communication with init process through D-Bus
- Users can start and stop their own processes
- Re-spawning of services that die abruptly and many more
4. OpenRC
OpenRC is a dependency-based init scheme for Unix-like operating systems, it is compatible with SysV init. As much as it brings some improvements to Sys V, you must keep in mind that OpenRC is not an absolute replacement for /sbin/init file.
It offers some illustrious features and these include:
- It can run on other many Linux distributions including Gentoo and also on BSD
- Supports hardware initiated init scripts
- Supports a single configuration file
- No per-service configurations supported
- Runs as a daemon
- Parallel services startup and many more
5. runit
runit is also a cross-platform init system that can run on GNU/Linux, Solaris, *BSD and Mac OS X and it is an alternative for SysV init, that offers service supervision.
It comes with some benefits and remarkable components not found in SysV init and possibly other init systems in Linux and these include:
- Service supervision, where each service is associated with a service directory
- Clean process state, it guarantees each process a clean state
- It has a reliable logging facility
- Fast system boot up and shutdown
- It is also portable
- Packaging friendly
- Small code size and many more
As I had earlier on mentioned, the init system starts and manages all other processes on a Linux system. Additionally, SysV is the primary init scheme on Linux operating systems, but due to some performance weaknesses, system programmers have developed several replacements for it.
And here, we looked at a few of those replacements, but there could be other init systems that you think are worth mentioning in this list. You can let us know of them via the comment section below.
If You Appreciate What We Do Here On TecMint, You Should Consider:
TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
We are thankful for your never ending support.
Источник
6 шагов загрузки Linux на пальцах
Нажмите кнопку включения питания на вашем системнике, и спустя несколько секунд вы увидите окно входа в систему.
Посмею предположить, что каждого интересовало хоть когда-либо то, что происходит за занавесом заставок и загрузочных экранов с момента включения питания компьютера к моменту, когда предлагается войти в систему.
Я предлагаю вам познакомиться со следующими уровнями типичной загрузки Linux:
1. BIOS
2. MBR
3. GRUB
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.18-194.el5PAE)
root (hd0,0)
kernel /boot/vmlinuz-2.6.18-194.el5PAE ro root=LABEL=/
initrd /boot/initrd-2.6.18-194.el5PAE.img
4. Ядро или Kernel
5. Init
6. Уровень выполнения программ (Runlevel)
- Когда Линукс выполняет свою загрузку, вы можете наблюдать загрузку различных служб. К примеру, это могут быть сообщения типа «starting Postfix … OK» (запускается Postfix). Эти службы — и называются программами уровня выполнения, выполняемые из директории, которая соответствует нужному уровню выполнения.
- Исходя из настроек по умолчанию, система будет выполнять файлы в соответствии с нижеприведенными директориями.
- Выполнение уровня 0 – /etc/rc.d/rc0.d/
- Выполнение уровня 1 – /etc/rc.d/rc1.d/
- Выполнение уровня 2 – /etc/rc.d/rc2.d/
- Выполнение уровня 3 – /etc/rc.d/rc3.d/
- Выполнение уровня 4 – /etc/rc.d/rc4.d/
- Выполнение уровня 5 – /etc/rc.d/rc5.d/
- Выполнение уровня 6 – /etc/rc.d/rc6.d/
- Но имейте ввиду, что еще в каталоге /etc могут быть символические ссылки. Например, /etc/rc0.d залинкован на /etc/rc.d/rc0.d.
- В каталогах /etc/rc.d/rc*.d/ вы можете увидеть список программ, имя которых начинается из букв S и K.
- Программы, начинающиеся на S используются для запуска. S, потому что startup.
- Программы, которые начинаются с литеры K используются — правильно — для завершения работы. K, потому что kill.
- Еще есть номера рядом с буквами S и K в именах программ. Эти номера используются для определения порядка запуска этих программ.
- К примеру, S12syslog предназначен для запуска демона syslog, его порядковый номер 12. S80sendmail — для запуска демона sendmail, имеющего порядковый номер 80. Таким образом, программа syslog будет запущена перед sendmail.
Вот и все. Возможно, некоторым из вас это не ново и особого интереса не было при чтении статью, поскольку она более ориентирована на начально-средний уровень знакомства з Линуксом.
В таком случае могу лишь сказать, что «повторение — мать учения» (с).
Дополнения, исправления, уточнения
В комментариях неоднократно было апеллировано к тексту статьи, поэтому, думаю, стоит учесть некоторые важные комментарии хабрасообщества. (спасибо artemlight, 3al, Tishka17, HhyperH, Next_Alex, Ilya_Shmelykh, Aux, soomrack, Xpeh )
- artemlight:: «Ну скажем прямо — так грузятся далеко не все дистры». С ним согласилось большинство, отмечая и bsd-style init, u-boot, и хоть initrd в статье пропущен, стоить заметить, что он нужен ядру не во всех дистрибутивах. Также отмечено, что в slackware поддержка rc.d осуществляется только в качестве совместимости, а встраиваемые системы грузятся иначе. На декстопах иногда бывает EFI, а кроме того Linux популярен в мире embedded и там ещё куча разных платформ. Линукс в телефоне вообще иначе грузится.
- soomrack, ссылая на википедию: Еще хочется сделать замечание по поводу MBR, первого сектора и пр. Все несколько усложнилось за последние годы. Сейчас уместней говорить о EFI.
Источник