/ boot가 가득 찼을 때 이전 커널을 제거하거나 새 커널을 설치하려면 어떻게해야합니까?


31

나는이 질문이 여러 번 전에 묻는다는 것을 알고 있지만 나와 함께 생각하는 것은 조금 다릅니다.

# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda3       224G  5.2G  208G   3% /
udev            1.9G  4.0K  1.9G   1% /dev
tmpfs           777M  260K  777M   1% /run
none            5.0M     0  5.0M   0% /run/lock
none            1.9G     0  1.9G   0% /run/shm
/dev/sda2        90M   88M     0 100% /boot
/dev/sda6       1.9G  514M  1.3G  29% /tmp

부팅 파티션이 가득 찼습니다.

현재 커널 :

# uname -r
3.2.0-35-generic

모든 커널 :

# dpkg --list | grep linux-image
ii  linux-image-3.2.0-32-generic    3.2.0-32.51                         Linux kernel image for version 3.2.0 on 64 bit x86 SMP
ii  linux-image-3.2.0-34-generic    3.2.0-34.53                         Linux kernel image for version 3.2.0 on 64 bit x86 SMP
ii  linux-image-3.2.0-35-generic    3.2.0-35.55                         Linux kernel image for version 3.2.0 on 64 bit x86 SMP
iF  linux-image-3.2.0-37-generic    3.2.0-37.58                         Linux kernel image for version 3.2.0 on 64 bit x86 SMP
iF  linux-image-3.2.0-38-generic    3.2.0-38.60                         Linux kernel image for version 3.2.0 on 64 bit x86 SMP
iU  linux-image-generic             3.2.0.37.45                         Generic Linux kernel image

그래서 3.2.0.32-일반 커널을 제거하려고 생각했습니다.

# sudo apt-get purge linux-image-3.2.0-32-generic
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
 linux-generic : Depends: linux-headers-generic (= 3.2.0.37.45) but 3.2.0.38.46 is to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

성공하지 못했습니다.

내가 시도 apt-get -f install하면 실패합니다.

# apt-get -f install
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
  linux-headers-3.2.0-34 linux-headers-3.2.0-35 linux-headers-3.2.0-34-generic linux-headers-3.2.0-35-generic
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  linux-generic linux-image-generic
The following packages will be upgraded:
  linux-generic linux-image-generic
2 upgraded, 0 newly installed, 0 to remove and 9 not upgraded.
5 not fully installed or removed.
Need to get 0 B/4,334 B of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue [Y/n]? y
Setting up initramfs-tools (0.99ubuntu13.1) ...
update-initramfs: deferring update (trigger activated)
Setting up linux-image-3.2.0-37-generic (3.2.0-37.58) ...
Running depmod.
update-initramfs: deferring update (hook will be called later)
The link /initrd.img is a dangling linkto /boot/initrd.img-3.2.0-38-generic
Examining /etc/kernel/postinst.d.
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 3.2.0-37-generic /boot/vmlinuz-3.2.0-37-generic
update-initramfs: Generating /boot/initrd.img-3.2.0-37-generic

gzip: stdout: No space left on device
E: mkinitramfs failure cpio 141 gzip 1
update-initramfs: failed for /boot/initrd.img-3.2.0-37-generic with 1.
run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return code 1
Failed to process /etc/kernel/postinst.d at /var/lib/dpkg/info/linux-image-3.2.0-37-generic.postinst line 1010.
dpkg: error processing linux-image-3.2.0-37-generic (--configure):
 subprocess installed post-installation script returned error exit status 2
Setting up linux-image-3.2.0-38-generic (3.2.0-38.60) ...
Running depmod.
update-initramfs: deferring update (hook will be called later)
The link /initrd.img is a dangling linkto /boot/initrd.img-3.2.0-37-generic
Examining /etc/kernel/postinst.d.
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 3.2.0-38-generic /boot/vmlinuz-3.2.0-38-generic
update-initramfs: Generating /boot/initrd.img-3.2.0-38-generic

gzip: stdout: No space left on device
E: mkinitramfs failure cpio 141 gzip 1
update-initramfs: failed for /boot/initrd.img-3.2.0-38-generic with 1.
run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return code 1
Failed to process /etc/kernel/postinst.d at /var/lib/dpkg/info/linux-image-3.2.0-38-generic.postinst line 1010.
dpkg: error processing linux-image-3.2.0-38-generic (--configure):
 subprocess installed post-installation script returned error exit status 2
dpkg: dependency problems prevent configuration of linux-image-generic:
 linux-image-generic depends on linux-image-3.2.0-37-generic; however:
  Package linux-image-3.2.0-37-generic is not configured yet.
dpkg: error processing linux-image-generic (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of linux-generic:
 linux-generic depends on linux-image-generic (= 3.2.0.37.45); however:
  Package linux-image-generic is not configured yet.
 linux-generic depends on linux-headers-generic (= 3.2.0.37.45); however:
  Version of linux-headers-generic on system is 3.2.0.38.46.
dpkg: error processing linux-generic (--configure):
 dependency problems - leaving unconfigured
Processing triggers for initramfs-tools ...
No apport report written because the error message indicates its a followup error from a previous failure.
No apport report written because MaxReports is reached already
  update-initramfs: Generating /boot/initrd.img-3.2.0-35-generic

gzip: stdout: No space left on device
E: mkinitramfs failure cpio 141 gzip 1
update-initramfs: failed for /boot/initrd.img-3.2.0-35-generic with 1.
dpkg: error processing initramfs-tools (--configure):
 subprocess installed post-installation script returned error exit status 1
No apport report written because MaxReports is reached already
Errors were encountered while processing:
 linux-image-3.2.0-37-generic
 linux-image-3.2.0-38-generic
 linux-image-generic
 linux-generic
 initramfs-tools
E: Sub-process /usr/bin/dpkg returned an error code (1)

어떤 도움이라도 정말로 감사하겠습니다.

업데이트 : 나는 :

sudo rm /boot/*-3.2.0-32-generic /boot/*-3.2.0-34-generic

그 후 다음과 같은 문제가 있습니다 apt-get -f install.

root@localhost:/# apt-get -f install
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following extra packages will be installed:
  linux-generic
The following packages will be upgraded:
  linux-generic
1 upgraded, 0 newly installed, 0 to remove and 9 not upgraded.
1 not fully installed or removed.
Need to get 0 B/1,722 B of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue [Y/n]? y
dpkg: dependency problems prevent configuration of linux-generic:
 linux-generic depends on linux-image-generic (= 3.2.0.37.45); however:
  Version of linux-image-generic on system is 3.2.0.38.46.
 linux-generic depends on linux-headers-generic (= 3.2.0.37.45); however:
  Version of linux-headers-generic on system is 3.2.0.38.46.
dpkg: error processing linux-generic (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error     from a previous failure.
                      Errors were encountered while processing:
 linux-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)


공간 부족으로 인해 자동 제거가 작동하지 않는 경우에 대한 답변을 참조하십시오.
nslntmnx

답변:


22

커널이 오래되면 apt-get을 사용할 수 없습니다.

cd /boot
sudo rm *-2.6.35-6.9-generic
sudo rm *-3.16.0-23-generic

사용하는 ls폴더에 제거 상황을 확인하기 위해 가장 오래된 하나 또는 두 개의 다음

sudo apt-get -f install

그런 다음 apt-get purge를

sudo apt-get purge linux-image-3.2.0-32-generic linux-image-3.2.0-34-generic

또는 rm으로 계속 진행하십시오.

당신은 또한 sudo update-grubfinsihed 해야합니다


install 명령은 많은 이전 커널을 다시 설치하여 전체 부팅 디스크를 생성했습니다. 퍼지 명령으로이 문제가 해결되었습니다.
SPRBRN

이 답변을까지 수행 sudo apt-get -f install한 다음 다시 시작하여 모든 것이 정상인지 확인하고 apt autoremove이전 명령 출력에서 ​​제안한대로 나머지를 제거했습니다 .
Bart C

10

분명히, 이것은 작동합니다 :

sudo apt-get autoremove 

apt-get맨 페이지 에 따르면 :

autoremove는 다른 패키지에 대한 종속성을 충족시키기 위해 자동으로 설치되어 더 이상 필요하지 않은 패키지를 제거하는 데 사용됩니다.

3.16.0-39는 설치하려고했지만 / boot가 가득 차서 실패했습니다. 3.16.0-38이 내 현재 버전입니다. -38을 건너 뛴 것을 알 수 있습니다.

server:~$ uname -r
3.16.0-38-generic
server:~$ sudo apt-get autoremove 
[sudo] password for mikeb: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  linux-headers-3.16.0-30 linux-headers-3.16.0-30-generic
  linux-headers-3.16.0-31 linux-headers-3.16.0-31-generic
  linux-headers-3.16.0-33 linux-headers-3.16.0-33-generic
  linux-headers-3.16.0-34 linux-headers-3.16.0-34-generic
  linux-headers-3.16.0-36 linux-headers-3.16.0-36-generic
  linux-headers-3.16.0-39 linux-headers-3.16.0-39-generic
  linux-image-3.16.0-30-generic linux-image-3.16.0-31-generic
  linux-image-3.16.0-33-generic linux-image-3.16.0-34-generic
  linux-image-3.16.0-36-generic linux-image-3.16.0-39-generic
  linux-image-extra-3.16.0-30-generic linux-image-extra-3.16.0-31-generic
  linux-image-extra-3.16.0-33-generic linux-image-extra-3.16.0-34-generic
  linux-image-extra-3.16.0-36-generic linux-image-extra-3.16.0-39-generic
0 upgraded, 0 newly installed, 24 to remove and 0 not upgraded.

나는이 대답을 좋아하지만 정확히 무엇을 알고 있는지 수동으로 놓친다 autoremove.
s3m3n

1
autoremove는 이전에 대기중인 적절한 작업이 제대로 완료된 경우에만 작동합니다. 이미 '장치에 남은 공간 없음'오류가 발생하면 자동 제거가 작동하지 않습니다. 이전에 대기중인 작업이 실패하고 자동 제거가 실행되지 않습니다. 다시 말해, autoremove는 작동하지 않습니다.
user535733

@ user535733 당신이 맞습니다. 공간 부족으로 인해 자동 제거가 작동하지 않는 경우에 대한 답변을 참조하십시오.
nslntmnx

7

터미널에서 다음 명령을 실행하십시오.

dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get purge

이 명령은 현재 설치된 모든 Linux 커널을 나열한 다음 현재 사용되지 않는 모든 커널을 선택하고 제거합니다.


2
이 명령의 기능을 정확히 설명하고 싶을 것입니다. 다소 복잡해 보입니다. 일반적으로 사람들은 이해하지 못하는 명령을 실행하지 말아야합니다. 특히 시스템에 중요한 것이 있습니다.
mtdevans

@mtdevans : 위의 명령은 현재 설치된 모든 Linux 커널을 나열한 다음 현재 사용되지 않는 모든 커널을 선택한 다음 현재 사용되지 않는 모든 커널을 제거한다고 덧붙였습니다.
Kristian

4
이 명령은 유용합니다. 먼저 "| xargs"전에 부분을 실행하여 삭제할 항목을 확인하십시오. 또한 | grep -v는 아직 사용하지 않았지만 원했던 최신 커널을 보존하기 위해 필요할 수 있습니다.
로마 수시

4
AMD64 : 그것은 또한 리눅스의 libc-dev에 일치로이 위험하다
프레드릭 노르

2
dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get -y purge

"sudo apt-get -y purge"없이 위 명령을 실행하면 linux-libc-dev : amd64와 일치하면 세미콜론을 추가하여 포함시키지 않을 수 있습니다.

dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ :]*\).*/\1/;/[0-9]/!d' | xargs

이제 잘 보이는지 확인하고 "sudo apt-get -y purge"를 추가하십시오.


1

우분투 12.04의 경우 이것을 시도하십시오 sudo apt-get purge linux-image-[kernel version]

커널 버전이 삭제됩니다. 부트 폴더에 많은 커널이 있다면 grub을 업데이트하고 시스템을 재부팅하는 것을 잊지 마십시오

전의. sudo apt-get purge 리눅스 이미지 -3.11.6 *


2
문제는 앞의 것과 같은 의존성 문제가있는 지점이있을 때 더 이상 작동하지 않는다는 것입니다.
Paŭlo Ebermann

이것은 나를 위해 작동합니다!
Daniel

0

많은 답변에서 "apt autoremove"를 사용한다고 말하지만 apt가 제거하기 전에 커널을 추가하려고 시도하기 때문에 / boot가 가득 차면 작동하지 않을 수 있습니다.

다음 apt autoremove는 /etc/apt/apt.conf.d/01autoremove-kernels에 언급 된 커널을 제거하지 않으므로 수정해야합니다.

나를 위해 일한 과정은 다음과 같습니다.

원치 않는 커널 구성 파일을 제거하십시오.

sudo dpkg --purge $ (COLUMNS = 200 dpkg -l | grep "linux-image-extra"| grep "^ rc"| tr -s ''| cut -d ''-f 2)

다음을 실행하여 /etc/apt/apt.conf.d/01autoremove-kernels 업데이트 ...

sudo /etc/kernel/postinst.d/apt-auto-removal

apt 자동 제거가 작동하기를 바랍니다.

sudo apt autoremove-퍼지

그렇지 않으면 / boot에서 아주 오래된 커널과 사용하지 않은 커널을 수동으로 제거 할 수 있습니다.

먼저 어떤 커널을 실행하고 있는지 확인하십시오.

uname -r

현재 커널이나 이전 커널을 제거하지 마십시오.

sudo rm /boot/initrd.img-V.XX.Y-ZZ-generic

이제 apt 자동 제거를 다시 시도하기에 충분한 공간이 있어야합니다. 그렇지 않은 경우 다른 오래된 커널을 제거하십시오. 물론 현재와 다음으로 가장 오래 유지하십시오.


-2

이것이 도움이되기를 바랍니다.

나는 보통 우분투 조정 관리자, 멋진 GUI를 사용하여 오래된 커널을 삭제합니다. :)

'시스템'을 클릭하면 이전 커널 목록이 표시됩니다.


1
우분투 서버이며 퍼티를 통해 연결됩니다. (그러나 서버에서도 Webmin을 사용할 수 있습니다)
Marcel

이 우분투 트 위크 관리인을 어떻게 설치합니까?
Jenny O'Reilly
당사 사이트를 사용함과 동시에 당사의 쿠키 정책개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.