본문 바로가기

Engineering/__00. Linux

Ubuntu apt 패키지 의존성 문제

Ubuntu 에서 apt 로 install 하려는데 다음과 같이 패키지 의존성 문제로 실패하는 경우가 종종 생긴다.

(모든 명령은 root 계정이 아니라 사용자 계정에서 sudo 명령으로 수행하는 것이 좋다. 여기서 설명은 편의상 root 계정으로 한다.)

root@ubuntu:/opt/test# apt-get install testdisk
패키지 목록을 읽는 중입니다... 완료
의존성 트리를 만드는 중입니다       
상태 정보를 읽는 중입니다... 완료
다음을 바로잡으려면 'apt-get -f install'을 실행해 보십시오:
다음 패키지의 의존성이 맞지 않습니다:
 libperl5.22 : 의존: perl-modules-5.22 (>= 5.22.1-9ubuntu0.5) 하지만 5.22.1-9ubuntu0.3 패키지를 설치할 것입니다
 linux-image-extra-4.4.0-128-generic : 의존: linux-image-4.4.0-128-generic 하지만 %s 패키지를 설치하지 않을 것입니다
 linux-image-generic : 의존: linux-image-4.4.0-128-generic 하지만 %s 패키지를 설치하지 않을 것입니다
                       추천: thermald 하지만 %s 패키지를 설치하지 않을 것입니다
 perl : 의존: perl-modules-5.22 (>= 5.22.1-9ubuntu0.5) 하지만 5.22.1-9ubuntu0.3 패키지를 설치할 것입니다
E: 의존성이 맞지 않습니다. 패키지 없이 'apt-get -f install'을 시도해 보십시오 (아니면 해결 방법을 지정하십시오).
root@ubuntu:/opt/test# apt-get -f install testdisk
패키지 목록을 읽는 중입니다... 완료
의존성 트리를 만드는 중입니다       
상태 정보를 읽는 중입니다... 완료
다음을 바로잡으려면 'apt-get -f install'을 실행해 보십시오:
다음 패키지의 의존성이 맞지 않습니다:
 libperl5.22 : 의존: perl-modules-5.22 (>= 5.22.1-9ubuntu0.5) 하지만 5.22.1-9ubuntu0.3 패키지를 설치할 것입니다
 linux-image-extra-4.4.0-128-generic : 의존: linux-image-4.4.0-128-generic 하지만 %s 패키지를 설치하지 않을 것입니다
 linux-image-generic : 의존: linux-image-4.4.0-128-generic 하지만 %s 패키지를 설치하지 않을 것입니다
                       추천: thermald 하지만 %s 패키지를 설치하지 않을 것입니다
 perl : 의존: perl-modules-5.22 (>= 5.22.1-9ubuntu0.5) 하지만 5.22.1-9ubuntu0.3 패키지를 설치할 것입니다
E: 의존성이 맞지 않습니다. 패키지 없이 'apt-get -f install'을 시도해 보십시오 (아니면 해결 방법을 지정하십시오).

apt-get -f install 로 해결되면 되나 꺼림직하기도 하고 잘 되지도 않는다. 

apt-get clean
apt-get install -f
dpkg --configure -a
apt-get update

순으로 정리한다.

진행 중 /boot 파티션에 disk full 로 에러가 발생하면 /boot 파티션 공간을 늘려주거나 불필요한 파일을 삭제한다.

uname -a
Linux ubuntu 4.4.0-184-generic

현재 사용 중인 버전을 확인한다.

사용 중인 버전을 제외하고 모두 삭제를 시도한다. 

root@ubuntu:/boot# dpkg --list 'linux-image*'
희망상태=알수없음(U)/설치(I)/지우기(R)/깨끗이(P)/고정(H)
| 상태=아님(N)/설치(I)/설정(C)/풀림(U)/절반설정(F)/일부설치(H)/트리거대기(W)/
| /    트리거밀림(T)
|/ 오류?=(없음)/다시설치필요(R) (상태, 오류가 대문자=불량)
||/ 이름                             버전                  Architecture          설명
+++-================================-=====================-=====================-=====================================================================
un  linux-image                      <none>                <none>                (설명 없음)
ii  linux-image-4.4.0-101-generic    4.4.0-101.124         amd64                 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii  linux-image-4.4.0-109-generic    4.4.0-109.132         amd64                 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii  linux-image-4.4.0-112-generic    4.4.0-112.135         amd64                 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii  linux-image-4.4.0-116-generic    4.4.0-116.140         amd64                 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii  linux-image-4.4.0-119-generic    4.4.0-119.143         amd64                 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii  linux-image-4.4.0-121-generic    4.4.0-121.145         amd64                 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
iF  linux-image-4.4.0-124-generic    4.4.0-124.148         amd64                 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
iF  linux-image-4.4.0-127-generic    4.4.0-127.153         amd64                 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
in  linux-image-4.4.0-128-generic    <none>                amd64                 (설명 없음)
in  linux-image-4.4.0-184-generic    <none>                amd64                 (설명 없음)
rc  linux-image-4.4.0-21-generic     4.4.0-21.37           amd64                 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
rc  linux-image-4.4.0-72-generic     4.4.0-72.93           amd64                 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
rc  linux-image-4.4.0-83-generic     4.4.0-83.106          amd64                 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
rc  linux-image-4.4.0-87-generic     4.4.0-87.110          amd64                 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
rc  linux-image-4.4.0-89-generic     4.4.0-89.112          amd64                 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
rc  linux-image-4.4.0-91-generic     4.4.0-91.114          amd64                 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
rc  linux-image-4.4.0-92-generic     4.4.0-92.115          amd64                 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
rc  linux-image-4.4.0-93-generic     4.4.0-93.116          amd64                 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii  linux-image-4.4.0-96-generic     4.4.0-96.119          amd64                 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii  linux-image-4.4.0-97-generic     4.4.0-97.120          amd64                 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii  linux-image-4.4.0-98-generic     4.4.0-98.121          amd64                 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii  linux-image-extra-4.4.0-101-gene 4.4.0-101.124         amd64                 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
ii  linux-image-extra-4.4.0-109-gene 4.4.0-109.132         amd64                 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
ii  linux-image-extra-4.4.0-112-gene 4.4.0-112.135         amd64                 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
ii  linux-image-extra-4.4.0-116-gene 4.4.0-116.140         amd64                 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
ii  linux-image-extra-4.4.0-119-gene 4.4.0-119.143         amd64                 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
iF  linux-image-extra-4.4.0-121-gene 4.4.0-121.145         amd64                 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
iU  linux-image-extra-4.4.0-124-gene 4.4.0-124.148         amd64                 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
iU  linux-image-extra-4.4.0-127-gene 4.4.0-127.153         amd64                 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
iU  linux-image-extra-4.4.0-128-gene 4.4.0-128.154         amd64                 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
rc  linux-image-extra-4.4.0-21-gener 4.4.0-21.37           amd64                 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
rc  linux-image-extra-4.4.0-72-gener 4.4.0-72.93           amd64                 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
rc  linux-image-extra-4.4.0-83-gener 4.4.0-83.106          amd64                 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
rc  linux-image-extra-4.4.0-87-gener 4.4.0-87.110          amd64                 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
rc  linux-image-extra-4.4.0-89-gener 4.4.0-89.112          amd64                 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
rc  linux-image-extra-4.4.0-91-gener 4.4.0-91.114          amd64                 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
rc  linux-image-extra-4.4.0-92-gener 4.4.0-92.115          amd64                 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
rc  linux-image-extra-4.4.0-93-gener 4.4.0-93.116          amd64                 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
ii  linux-image-extra-4.4.0-96-gener 4.4.0-96.119          amd64                 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
ii  linux-image-extra-4.4.0-97-gener 4.4.0-97.120          amd64                 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
ii  linux-image-extra-4.4.0-98-gener 4.4.0-98.121          amd64                 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
iU  linux-image-generic              4.4.0.184.190         amd64                 Generic Linux kernel image
un  linux-image-unsigned-4.4.0-184-g <none>                <none>                (설명 없음)
root@ubuntu:/boot# apt-get remove linux-image-4.4.0-21-generic

이 마저 잘 안되면 /boot 파티션의 사용 버전을 제외하고 수동 삭제한 후 다시 히도한다.

rm /boot/*4.4.0-21*
apt-get remove linux-image-4.4.0-21-generic

충분한 공간이 확보될 때 까지 수행한다.

apt autoremoveroot@ubuntu:/boot# apt autoremove
패키지 목록을 읽는 중입니다... 완료
의존성 트리를 만드는 중입니다       
상태 정보를 읽는 중입니다... 완료
다음 패키지를 지울 것입니다:
  linux-headers-4.4.0-101 linux-headers-4.4.0-101-generic linux-headers-4.4.0-109 linux-headers-4.4.0-109-generic linux-headers-4.4.0-112
  linux-headers-4.4.0-112-generic linux-headers-4.4.0-116 linux-headers-4.4.0-116-generic linux-headers-4.4.0-119 linux-headers-4.4.0-119-generic
  linux-headers-4.4.0-124 linux-headers-4.4.0-124-generic linux-headers-4.4.0-127 linux-headers-4.4.0-127-generic linux-headers-4.4.0-96
  linux-headers-4.4.0-96-generic linux-headers-4.4.0-98 linux-headers-4.4.0-98-generic linux-image-4.4.0-109-generic linux-image-4.4.0-116-generic
  linux-image-4.4.0-119-generic linux-image-4.4.0-124-generic linux-image-4.4.0-127-generic linux-image-extra-4.4.0-109-generic
  linux-image-extra-4.4.0-116-generic linux-image-extra-4.4.0-119-generic linux-image-extra-4.4.0-124-generic linux-image-extra-4.4.0-127-generic
  xinetd
0개 업그레이드, 0개 새로 설치, 29개 제거 및 337개 업그레이드 안 함.
이 작업 후 1,817 M바이트의 디스크 공간이 비워집니다.
계속 하시겠습니까? [Y/n] y
(데이터베이스 읽는중 ...현재 453296개의 파일과 디렉터리가 설치되어 있습니다.)
Removing linux-headers-4.4.0-101-generic (4.4.0-101.124) ...
Removing linux-headers-4.4.0-101 (4.4.0-101.124) ...
Removing linux-headers-4.4.0-109-generic (4.4.0-109.132) ...

이 후 이전 버전의 관련 파일까지 깔끔히 삭제한다.

패키지를 정리 시키고 원래 설치하려던 패키지 설치를 다시 시도한다.

root@ubuntu:/boot# apt-get clean
root@ubuntu:/boot# apt-get install -f
패키지 목록을 읽는 중입니다... 완료
의존성 트리를 만드는 중입니다       
상태 정보를 읽는 중입니다... 완료
0개 업그레이드, 0개 새로 설치, 0개 제거 및 337개 업그레이드 안 함.
root@ubuntu:/boot# apt-get install OOOOO

 

'Engineering > __00. Linux' 카테고리의 다른 글

[Sendmail/Postfix]  (0) 2021.08.31
삭제된 파일 복구하기  (0) 2020.06.22
[Sendmail] dsn=4.0.0, stat=Deferred: Transport endpoint is not connected  (0) 2020.03.06
[ufw]  (0) 2018.09.18
[service] ubuntu service 등록 관리  (0) 2018.09.18