ฉันจะลบเมล็ดเก่า / ติดตั้งใหม่ได้อย่างไรเมื่อ / 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-generic ด้วย:

# 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)


ดูคำตอบของฉันเมื่อ autoremove ไม่ทำงานเนื่องจากขาดพื้นที่
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

จากนั้นคุณก็สามารถกำจัดมันได้เช่นกัน

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

หรือเพียงแค่ดำเนินการต่อด้วย rm

คุณควรsudo update-grubเมื่อคุณถูกปรับ


คำสั่งติดตั้งติดตั้งเคอร์เนลเก่าอีกหลายอันทำให้ดิสก์สำหรับบูตเต็ม คำสั่งล้างข้อมูลแก้ปัญหานี้ให้ฉัน
SPRBRN

ฉันทำตามคำตอบนี้sudo apt-get -f installแล้วรีสตาร์ทเพื่อให้แน่ใจว่าทุกอย่างดีและลบส่วนที่เหลือด้วยapt autoremoveตามที่แนะนำในคำสั่งก่อนหน้าเอาท์พุท
บาร์ต 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
การลบอัตโนมัติจะทำงานเฉพาะเมื่อการกระทำ apt ที่จัดคิวไว้ก่อนหน้านี้ดำเนินการอย่างถูกต้อง ระบบตอบกลับอัตโนมัติจะไม่ทำงานหากคุณได้รับข้อผิดพลาด 'ไม่มีที่เหลือในอุปกรณ์' อยู่แล้ว - การกระทำที่อยู่ในคิวก่อนหน้านี้จะล้มเหลวและระบบตอบกลับอัตโนมัติจะไม่ทำงาน กล่าวอีกนัยหนึ่งระบบตอบกลับอัตโนมัติจะทำงาน ... จนกว่าจะไม่
user535733

@ user535733 คุณถูกต้อง ดูคำตอบของฉันเมื่อ autoremove ไม่ทำงานเนื่องจากขาดพื้นที่
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 เพื่อรักษาเคอร์เนลล่าสุดซึ่งอาจยังไม่ได้ใช้ แต่ต้องการ
โรมัน Susi

4
นี่มันอันตรายเพราะมันตรงกับ linux-libc-dev: amd64
Frederick Nord

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 ของคุณคุณสามารถเพิ่มเครื่องหมายอัฒภาคใน regex เพื่อไม่รวม:

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

ตอนนี้ให้แน่ใจว่ามันดูดีและเพิ่ม "การล้าง sudo apt-get -y"


1

สำหรับ Ubuntu 12.04 ลองสิ่งนี้ sudo apt-get purge linux-image-[kernel version]

นี่จะเป็นการลบเคอร์เนลเวอร์ชันใด ๆ หากโฟลเดอร์บูตของคุณมีเมล็ดมากอย่าลืมอัปเดตด้วงและรีบูตระบบของคุณ

อดีต sudo apt-get purge linux-image-3.11.6 *


2
ปัญหาคือว่ามันไม่ทำงานอีกต่อไปเมื่อมีจุดที่มีปัญหาการพึ่งพาเช่นเดียวกับข้างหน้า
Paŭlo Ebermann

มันใช้งานได้สำหรับฉัน!
Daniel

0

คำตอบมากมายบอกว่าจะใช้ "apt autoremove" แต่อาจไม่ทำงานเมื่อ / boot เต็มเพราะ apt พยายามที่จะเพิ่มเมล็ดก่อนที่จะลบ

คำตอบอัตโนมัติต่อไปจะไม่ลบเคอร์เนลใด ๆ ที่กล่าวถึงใน /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 autoremove จะทำงานได้ดี

sudo apt autoremove --purge

ถ้าไม่ใช่คุณควรจะลบเมล็ดเก่าและที่ไม่ได้ใช้ออกจาก / boot ด้วยตนเอง

ขั้นแรกให้ค้นหาว่าเคอร์เนลใดที่คุณใช้อยู่

uname -r

อย่าลบเคอร์เนลปัจจุบันหรือเคอร์เนลก่อนหน้า

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

ตอนนี้คุณควรมีพื้นที่เพียงพอที่จะลองตอบคำถามอัตโนมัติอีกครั้ง ถ้าไม่ใช่ให้ลบเคอร์เนลตัวเก่าออก แน่นอนให้เป็นปัจจุบันและเก่าแก่ที่สุดต่อไป


-2

ฉันหวังว่านี่จะช่วยได้:

ฉันมักจะลบเมล็ดเก่าโดยใช้ ubuntu-tweak janitor, GUI ที่ดีและใช้ง่าย :)

คลิกที่ 'ระบบ' และจะมีรายการของเมล็ดเก่าเพียงแค่คลิกมันและทำความสะอาด


1
มันเป็นเซิร์ฟเวอร์อูบุนตูและฉันเชื่อมต่อผ่านผงสำหรับอุดรู (แต่ฉันยังมีความพร้อมในการใช้ Webmin บนเซิร์ฟเวอร์ด้วย)
Marcel

ฉันจะติดตั้ง janitor ubuntu-tweak นี้ได้อย่างไร
Jenny O'Reilly
โดยการใช้ไซต์ของเรา หมายความว่าคุณได้อ่านและทำความเข้าใจนโยบายคุกกี้และนโยบายความเป็นส่วนตัวของเราแล้ว
Licensed under cc by-sa 3.0 with attribution required.