티스토리 뷰

728x90

오래간만에 우분투 가상 머신을 열고 패키지를 설치하려는데 다음과 같은 메시지와 함께 설치가 되지 않는다.

 

E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 2836 (unattended-upgr)
N: Be aware that removing the lock file is not a solution and may break your system.
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?

말인즉슨 unattended-upgr 프로세스가 수행 중이니 설치할 수 없다는 것이다. 윈도우 업데이트처럼 우분투도 업데이트를 자동으로 수행하도록 되어 있으므로 해당 업데이트가 모두 끝날 때까지 기다리거나 업데이트가 중요하지 않다면 자동 업데이트를 해제하면 된다. 

 

물론 자동 업데이트가 완료될 때까지 기다릴 정도로 여유가 있으면 문제가 될 것은 없다. 그렇지만, 위의 그림에서 보듯이 주기적으로 업데이트 프로세스가 CPU를 100% 잡아먹고 있을 정도라면 그냥 두는 것도 녹록하지 않을 것이다. 이번 글에서는 업데이트가 중요하지 않은 환경에서 시스템이 자동 업데이트를 수행하지 않도록 막는 방법을 정리할까 한다.

 

osboxes@osboxes:~$ systemctl list-timers | grep apt
Mon 2023-06-19 12:19:31 EDT 10h left    Mon 2023-06-19 01:07:37 EDT 18min ago apt-daily.timer              apt-daily.service             
n/a                         n/a         Mon 2023-06-19 01:07:37 EDT 18min ago apt-daily-upgrade.timer      apt-daily-upgrade.service  

우선 위의 그림처럼 시스템에 등록된 타임 서비스 중에서 업데이트와 관련된 것을 "systemctl list-timers | grep apt" 명령으로 조회한다. 

 

systemctl stop apt-daily.timer apt-daily-upgrade.timer

목록에 있는 타이머 이름을 참조하여 위의 그림처럼 "systemctl stop" 명령으로 타이머를 중단시키고 "systemctl list-timers | grep apt" 명령으로 다시 조회하면 해당 타이머들은 목록에서 보이지 않게 된다.

 

osboxes@osboxes:~$ systemctl disable apt-daily.timer apt-daily.service apt-daily-upgrade.timer apt-daily-upgrade.service
Removed /etc/systemd/system/timers.target.wants/apt-daily.timer.
Removed /etc/systemd/system/timers.target.wants/apt-daily-upgrade.timer.

다음으로 해야 할 작업은 "systemctl disable" 명령으로 타이머와 서비스를 모두 비활성화한다.

 

sudo vi /etc/apt/apt.conf.d/20auto-upgrades
PT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";

또 다른 작업은 APT 환경 설정 파일을 수정하는 것으로 그림처럼 sudo 권한으로 해야 수정할 수 있다. 1을 0으로 바꾸고 저장하면 된다.

 

sudo systemctl stop unattended-upgrades

마지막으로 현재 수행 중인 업데이트를 중단시키는 명령은 "sudo systemctl stop unattended-upgrades"로 수행하면 된다. 

 

이제 설치가 정상적으로 수행된다.

728x90
댓글
최근에 올라온 글
최근에 달린 댓글
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함