읽기 전용 Raspberry Pi에서는 ntp가 작동하지 않습니다.

읽기 전용 Raspberry Pi에서는 ntp가 작동하지 않습니다.

ntp(서비스)가 라즈베리 파이에서 시간을 올바르게 설정하지 않는 이유를 이해하려고 애쓰고 있습니다.

SD 카드를 저장하기 위해 파일 시스템을 읽기 전용으로 구성했지만 이전에는 작동했는데 지금은 ntp가 작동하지 않는 이유를 알 수 없는 것 같습니다.

로그에는 해당 메시지의 여러 줄이 표시됩니다.

ntpd[415]: kernel reports TIME_ERROR: 0x41: Clock Unsynchronized
ntpd[415]: kernel reports TIME_ERROR: 0x41: Clock Unsynchronized
ntpd[415]: error resolving pool 0.debian.pool.ntp.org: Temporary failure in name resolution (-3)
ntpd[415]: error resolving pool 1.debian.pool.ntp.org: Temporary failure in name resolution (-3)
ntpd[415]: error resolving pool 2.debian.pool.ntp.org: Temporary failure in name resolution (-3)
ntpd[415]: error resolving pool 3.debian.pool.ntp.org: Temporary failure in name resolution (-3)
ntpd[415]: error resolving pool 3.debian.pool.ntp.org: Temporary failure in name resolution (-3)
ntpd[415]: error resolving pool 2.debian.pool.ntp.org: Temporary failure in name resolution (-3)
ntpd[415]: error resolving pool 1.debian.pool.ntp.org: Temporary failure in name resolution (-3)
ntpd[415]: error resolving pool 0.debian.pool.ntp.org: Temporary failure in name resolution (-3)

내 /etc/resolv.conf는 다음과 같습니다:

# Generated by resolvconf
nameserver 8.8.8.8
nameserver 192.168.1.22

해당 RPi에서 인터넷에 액세스할 수 있고, 풀 주소를 핑하고, Google을 핑하고, 적절하게 업데이트할 수 있습니다(rw에 다시 마운트한 후)...

또한 ntpdate 명령을 수동으로 실행할 수도 있으며 작동합니다!

$ sudo ntpdate -u 0.fr.pool.ntp.org 1.fr.pool.ntp.org
24 Nov 23:04:34 ntpdate[578]: step time server 129.250.35.250 offset 2418.621037 sec

네, 여기서 머리카락을 당기고 있습니다. NTP 서비스가 작동하지 않는 이유를 이해할 수 없습니다. 인터넷을 뒤져보니 이 특별한 문제가 있는 사람은 없는 것 같습니다(모두 DNS가 제대로 작동하지 않지만 내 것은 작동합니다).

내 읽기 전용 설정은 다음과 같습니다.https://hallard.me/raspberry-pi-read-only/

여러분, 어떤 생각이 있으신가요?

답변1

비슷한 문제에 직면하면서 이 질문을 발견했습니다.

문제는 systemdPrivateTmp기능이 읽기 전용 구성에서 작동하지 않는 것으로 밝혀졌습니다.

  1. 반드시 설치 ntp하고ntpdate
    sudo apt install -y ntp ntpdate
    
  2. /lib/systemd/system/ntp.service에게 복사/etc/systemd/system/ntp.service

    cp /lib/systemd/system/ntp.service /etc/systemd/system/ntp.service
    
  3. 을 열고 /etc/systemd/system/ntp.service주석 처리하세요 PrivateTmp=true.

    sudo nano /etc/systemd/system/ntp.service
    

이제 올바르게 작동할 것입니다!

추가 단계로 이제 권장 사항 /var/lib/ntp으로 마운트했습니다.tmpfs여기

  1. 파일을 열고 파일 끝에 /etc/fstab추가하세요 .tmpfs /var/lib/ntp tmpfs nosuid,nodev 0 0
    sudo nano /etc/fstab
    

내 경우에는 이것이 필요하다고 생각하지 않았지만 거기에는 읽기 전용 파일 시스템에서 실행하는 것에 대한 추가 통찰력이 있습니다.

답변2

마크 로저의 답변작동하지만 사용자가 재정의하는 것이 더 낫다고 생각합니다.

echo -e '[Service]\nPrivateTmp=false' > /etc/systemd/system/ntp.service.d/override.conf

그런 다음 재부팅하거나 systemctl daemon-reload충분할 수도 있습니다.

관련 정보