Pertama-tama, systemdini bukan unix tradisional init. Systemd jauh lebih banyak, jadi agak tidak adil untuk membandingkan keduanya.
Untuk menjawab pertanyaan, yang tampaknya diperlukan adalah beberapa biner dan file konfigurasi berikut:
/usr/lib/systemd/system/default.target
/usr/lib/systemd/system/basic.target
/usr/lib/systemd/system/sysinit.target
/usr/lib/systemd/system/getty.target
/usr/lib/systemd/system/getty@.service
/usr/lib/systemd/system/console-getty.service
mengeluarkan systemctl enable console-getty.service getty@tty2.servicekemudian membuat symlinks ini:
/etc/systemd/system/default.target.wants/getty@tty2.service -> / lib / systemd / system / getty @ service
/etc/systemd/system/getty.target.wants/console-getty.service -> /lib/systemd/system/console-getty.service
CATATAN : Untuk memanfaatkan systemdfitur khusus untuk memulai agettysecara dinamis, sesuai permintaan saat menekan Alt+ F3dan seterusnya, tampaknya Anda juga harus memiliki setidaknya dua file ini:
/etc/systemd/logind.conf
/lib/systemd/system/autovt@.service
di mana autovt@.servicesymlink ke getty@.service.
Isi file konfigurasi:
The default.target, getty.target, sysinit.targetfile bisa kosong kecuali untuk [Unit]tag dan (mungkin) Description=xxx.
basic.target juga mengandung informasi ketergantungan:
[Satuan]
Deskripsi = Sistem Dasar
Membutuhkan = sysinit.target
Mau = sockets.target timers.target paths.target slices.target
Setelah = sysinit.target sockets.target timers.target paths.target slices.target
Saya tidak yakin apakah referensi ke target yang tidak ada karena file diperlukan atau tidak. Mereka dijelaskan di systemd.special(7)halaman manual.
console-getty.service: (Kasus khusus untuk agetty di konsol)
[Satuan]
Deskripsi = Konsol Getty
Setelah = systemd-user-session.service plymouth-quit-wait.service
Sebelum = getty.target
[Layanan]
ExecStart = - / sbin / agetty --noclear --keep-baud console 115200,38400,9600 $ TERM
Ketik = idle
Mulai ulang = selalu
RestartSec = 0
UtmpIdentifier = kontra
TTYPath = / dev / console
TTYReset = ya
TTYVHangup = ya
KillMode = proses
IgnoreSIGPIPE = no
SendSIGHUP = ya
[Memasang]
WantedBy = getty.target
getty@.service: (konfigurasi umum untuk semua layanan getty kecuali konsol)
[Satuan]
Keterangan = Getty on% I
Setelah = systemd-user-session.service plymouth-quit-wait.service
Sebelum = getty.target
IgnoreOnIsolate = ya
ConditionPathExists = / dev / tty0
[Layanan]
ExecStart = - / sbin / agetty --noclear% I $ TERM
Ketik = idle
Mulai ulang = selalu
RestartSec = 0
UtmpIdentifier =% I
TTYPath = / dev /% I
TTYReset = ya
TTYVHangup = ya
TTYVTDisallocate = no
KillMode = proses
IgnoreSIGPIPE = no
SendSIGHUP = ya
[Memasang]
WantedBy = getty.target
DefaultInstance = tty1
Akhirnya Anda mungkin perlu beberapa binari khusus ini (saya belum mencoba yang mana yang penting):
/ lib / systemd / systemd (/ sbin / init biasanya menunjukkan ini)
/ lib / systemd / systemd-logind
/ lib / systemd / systemd-cgroups-agent
/ lib / systemd / systemd-pengguna-sesi
/ lib / systemd / systemd-vconsole-setup
/ lib / systemd / systemd-update-utmp
/ lib / systemd / systemd-sleep
/ lib / systemd / systemd-sysctl
/ lib / systemd / systemd-initctl
/ lib / systemd / systemd-reply-password
/ lib / systemd / systemd-ac-power
/ lib / systemd / systemd-aktifkan
/ lib / systemd / systemd-backlight
/ lib / systemd / systemd-binfmt
/ lib / systemd / systemd-bootchart
/ lib / systemd / systemd-bus-proxyd
/ lib / systemd / systemd-coredump
/ lib / systemd / systemd-cryptsetup
/ lib / systemd / systemd-fsck
/ lib / systemd / systemd-hostnamed
/ lib / systemd / systemd-journald
/ lib / systemd / systemd-jurnal-gatewayd
/ lib / systemd / systemd-jurnal-remote
/ lib / systemd / systemd-localed
/ lib / systemd / systemd-machined
/ lib / systemd / systemd-modules-load
/ lib / systemd / systemd-multi-seat-x
/ lib / systemd / systemd-networkd
/ lib / systemd / systemd-networkd-tunggu-online
/ lib / systemd / systemd-quotacheck
/ lib / systemd / systemd-random-seed
/ lib / systemd / systemd-readahead
/ lib / systemd / systemd-remount-fs
/ lib / systemd / systemd-diselesaikan
/ lib / systemd / systemd-rfkill
/ lib / systemd / systemd-shutdown
/ lib / systemd / systemd-shutdownd
/ lib / systemd / systemd-socket-proxyd
/ lib / systemd / systemd-timedated
/ lib / systemd / systemd-timesyncd
/ lib / systemd / systemd-udevd
/ lib / systemd / systemd-update-done
Untuk meringkas proses mulai systemd, saya pikir itu bekerja seperti ini:
- systemd mencari
basic.target(atau semua *.targetfile?)
- dependensi diselesaikan berdasarkan
WantedBy=, Wants=, Before=, After=... arahan dalam [Install]bagian dari *.servicedan *.targetkonfigurasi file.
*.services yang harus dimulai (yang bukan layanan "khusus"), memiliki [Service]bagian dengan ExecStart=arahan, yang menunjukkan eksekusi untuk memulai.