가상 콘솔에서 최소의 시스템 부팅으로 getty를 시작하려면 무엇이 필요합니까?


21

시스템 V를 들어 init, 내가 필요 /etc/inittab게티 항목의 respawning /sbin/init쉘 이진, 이진 파일과 공유 라이브러리를, login의 getty는 PAM / 보안 / 그림자 물건, 그리고 몇 가지 장치 파일.

들어 upstart거의 같은 요구 사항, 대신의 필요 나 /etc/inittab, 나는 몇 가지가 *.conf아래 파일 /etc/init: *의 .conf 하나 start on startup와 그 세트 런레벨 telinit, 한 *의 .conf 각 청각 장애에 대한 그 시작 / 부활 getty적절한 실행 수준에 그 청각 장애에 .

어떤 구성 및 바이너리가 필요 systemd init합니까?

내가 찾은 문서는 이미 설치된 시스템을 사용하여 서비스를 시작하고 중지하는 방법에 중점을 둔 것으로 보입니다.

실행중인 Arch 또는 fedora 설치 에서 복사 할 최소한의 파일 목록 (커널 / initrd 제외) 은 괜찮을 것입니다.하지만에 대한 정보는 찾을 수 없습니다 systemd.


내가 알고 싶은 systemd것은 initramfs가 로그인 쉘을 switch_root호출 한 후 로그인 쉘을 시작하기 위해 필요한 파일과 파일에 포함 해야하는 내용 systemd /sbin/init입니다.


예를 들어 upstart바이너리와 두 *.conf파일 :

파일 /etc/init/whatever.conf:

시작시 시작
런레벨을 방출
태스크
스크립트
  telinit 2
엔드 스크립트

파일 /etc/init/tty1.conf:

런레벨에서 시작 [12345]
리스폰
exec / sbin / agetty -8 --noclear 38400 tty1 리눅스

sysvinit이진 및 1 conf 파일의 예는 다음과 /etc/inittab같습니다.

id : 2 : 초기 기본값 :
c1 : 12345 : repawn : / sbin / agetty 38400 tty1 리눅스

이제 나는 systemd동등한 것을 따릅니다.

and가 포함 *.service된 [Service]항목 과 함께 어딘가에 적어도 하나의 파일이 필요 하다고 가정 하지만 다른 무엇이 필요합니까?ExecStart=-/sbin/agetty --noclear %I linuxRestart=always


이제이 URL에 시스템 부팅을 설명하는 최신 RedHat 기술 자료 문서 (754933) 가 있습니다. RHEL 7에 대한 systemd 개요
— MattBianco

사람들이 단일 구성 라인을 어떻게 큰 혼란에 빠뜨리고 개선이라고 부르는지는 매우 우울합니다.
— 17 년

답변:


17

우선 systemd, 전통적인 유닉스가 아닙니다 init. Systemd는 훨씬 더 많으므로 둘을 비교하는 것은 약간 불공평합니다.

질문에 대답하기 위해 필요한 것으로 보이는 것은 일부 바이너리와 다음 구성 파일입니다.

/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

발행 systemctl enable console-getty.service getty@tty2.service하면 다음과 같은 심볼릭 링크가 생성됩니다.

/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

참고 : + 등을 누를 때 필요에 따라 동적으로 systemd시작 하기 위해 의 특수 기능 을 활용하려면 다음 두 파일도 있어야합니다.agettyAltF3

/etc/systemd/logind.conf
/lib/systemd/system/autovt@.service

에 autovt@.service대한 심볼릭 링크는 어디에 있습니까 getty@.service?

구성 파일의 내용 :

는 default.target, getty.target, sysinit.target파일을 제외하고 비어있을 수 있습니다 [Unit]태그와 (아마도) Description=xxx.

basic.target 종속성 정보도 포함합니다.

[단위]
Description = 기본 시스템
요구 사항 = sysinit.target
Wants = sockets.target timers.target paths.target slices.target
After = sysinit.target sockets.target timers.target paths.target slices.target

파일로 존재하지 않는 대상에 대한 참조가 필요한지 확실하지 않습니다. systemd.special(7)매뉴얼 페이지 에 설명되어 있습니다.


console-getty.service: (콘솔에서 사용하는 특별한 경우)

[단위]
Description = 콘솔 게티
After = systemd-user-sessions.service plymouth-quit-wait.service
Before = getty.target

[서비스]
ExecStart =-/ sbin / agetty --noclear --keep-baud console 115200,38400,9600 $ TERM
유형 = 유휴
다시 시작 = 항상
RestartSec = 0
UtmpIdentifier = 단점
TTYPath = / dev / console
TTYReset = 예
TTYVHangup = 예
KillMode = 프로세스
무시 SIGPIPE = 아니오
SendSIGHUP = 예

[설치]
WantedBy = getty.target

getty@.service: (콘솔을 제외한 모든 게티 서비스에 대한 일반 구성)

[단위]
Description = % I에 게티
After = systemd-user-sessions.service plymouth-quit-wait.service
Before = getty.target
IgnoreOnIsolate = 예
ConditionPathExists = / dev / tty0

[서비스]
ExecStart =-/ sbin / agetty --noclear % I $ TERM
유형 = 유휴
다시 시작 = 항상
RestartSec = 0
UtmpIdentifier = % I
TTYPath = / dev / % I
TTYReset = 예
TTYVHangup = 예
TTYVT 할당 해제 = 아니오
KillMode = 프로세스
무시 SIGPIPE = 아니오
SendSIGHUP = 예

[설치]
WantedBy = getty.target
DefaultInstance = tty1

마지막으로 몇 가지 특수 바이너리가 필요할 것입니다 (중요한 것이 무엇인지 시도하지 않았습니다).

/ lib / systemd / systemd (/ sbin / init는 보통 이것을 가리 킵니다)
/ lib / systemd / systemd-logind
/ lib / systemd / systemd-cgroups-agent
/ lib / systemd / systemd-user-sessions
/ 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-activate
/ 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-journal-gatewayd
/ lib / systemd / systemd-journal-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-wait-online
/ lib / systemd / systemd-quotacheck
/ lib / systemd / systemd- 랜덤 시드
/ lib / systemd / systemd-readahead
/ lib / systemd / systemd-remount-fs
/ lib / systemd / systemd-resolved
/ 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

시스템 시작 프로세스를 요약하면 다음과 같이 작동합니다.

  1. systemd는 basic.target(또는 모든 *.target파일을 찾습니다 )
  2. 종속의 기반이 해결 WantedBy=, Wants=, Before=, After=...에서 지침 [Install]의 섹션 *.service및 *.target구성 파일.
  3. *.service시작해야하는 ( "특별한"서비스가 아닌) 지시문 이있는 [Service]섹션이 있으며 ExecStart=실행 파일이 시작되도록 지정합니다.

1
AFAIK [Install]섹션은 부팅 순서에 의해 사용되지 않으며에 의해서만 사용됩니다 systemctl enable. 부팅에서 보이는 것은에 /etc/systemd/system/basic.target.wants/의해 생성 된 심볼릭 링크입니다 systemctl enable.
— Stefan Majewsky

6

systemd터미널로 전환 할 때 특정 최대 수까지 게티가 자동으로 생성됩니다. 기본값은 6입니다 (따라서 alt + f1에서 alt + f6에 대한 getty를 자동으로 얻습니다). 이 파라미터 /etc/systemd/logind.conf를 변경하려면 NAutoVTs파라미터를 다른 숫자 (최대 12) 로 변경 하도록 편집 할 수 있습니다

수동으로 전환하지 않아도 게티가 생성 /usr/lib/systemd/system/getty@.service되도록하려면 /etc/systemd/system/getty.target.wants/디렉토리에 심볼릭 링크를 추가 할 수 있습니다 .

ln -sf /usr/lib/systemd/system/getty@.service /etc/systemd/system/getty.target.wants/getty@tty9.service

이로 인해 getty.target하나 이상의 getty@서비스 가 필요 합니다. 대상은 종속을 지원하는 런레벨을 대체하고 생성해야하는 서비스 모음입니다. 기본 대상은getty.target

ArchWiki의 systemd FAQ를 참조하십시오

편집 : 나는 문서 에서 조금 더 연구했다 .

부팅시 systemd데몬은 default대상의 모든 시스템 과 해당 종속성을 로드합니다 . 대상은 파일에 의해 정의됩니다

/etc/systemd/system/default.target
/usr/lib/systemd/system/default.target

대상은 디렉토리에서 심볼릭 링크로 지정된 첨부 서비스 목록을 가지고 있습니다.

/etc/systemd/system/default.target.wants
/usr/lib/systemd/system/default.target.wants

/etc버전의 배포 기본값을 재정의합니다 /usr/lib. .target파일 중 하나만 필요하지만 디렉토리는 필요하지 않습니다.

gettyinit 스크립트로 실행할 수있는 서비스 중 하나 일뿐입니다. 내가 확인한 배포판 (fedora, arch) getty은 두 가지 방식으로 실행됩니다.

  1. 각 터미널에 대한 특정 스크립트에 의해 시작합니다 (링크 /usr/lib/systemd/system/getty@.service파일이있는 청각 장애 이름으로 치환되는 systemd링크 파일 이름에서 )
  2. logind사용자가 가상 ​​터미널로 전환 할 때 필요에 따라 자동으로 표시됩니다 ( inetd요청이 도착할 때만 기존 서비스를 가져온 방식과 유사 함 ). logind는로 배포 된 다른 데몬 systemd이며 /etc/systemd/logind.conf파일 에서 해당 구성을 읽습니다 .

이것이 만족 스럽기를 바랍니다.


필요한 파일과 포함 할 파일을 알고 싶습니다. 답을 필요한 파일 목록과 어떤 순서로 읽게하는 원인으로 요약 할 수 있습니까? 해당 디렉토리에서 무엇이 필요한지에 대한 정보가 없습니다. 나는 내 질문을 조금 더 자세히 설명하려고 노력할 것이다. 감사!
— MattBianco

@MattBianco 당신은 불필요하게 적대적 systemd입니다. 나는 약간의 연구를하고 있는데 일단 당신이 물건이 어떻게 작동하는지 이해하면 아주 간단 해 보인다
— pqnet

1
예, 다른 오픈 소스 프로젝트의 문서가 손상되었습니다. 적대적으로 들려서 죄송합니다. 부팅 과정을 설명하는 간단한 문서가없는 것 같습니다. (지금은 systemd가 간단하지 않기 때문에 이해합니다.) 유머러스 한 방식 systemd으로, 개방형 시스템이 시작되는 방식을 적대적으로 인수하는 것과 같이 유머러스하다고 말할 수 있습니다. GNU / Linux를 Unix에서 멀어지게 만듭니다. 그것이 나쁜 일이라고 말하지는 않지만, 전통적으로 일이 있었던 것과는 매우 다릅니다. 그리고 약간의 인터넷 검색은 내가 혼자가 아니라는 것을 나타냅니다.
— MattBianco
당사 사이트를 사용함과 동시에 당사의 쿠키 정책과 개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.