कैसे Debian और Ubuntu में पुरानी अप्रयुक्त गुठली को हटाने के लिए


अपने आखिरी लेख में, हमने बताया कि CentOS/RHEL/फेडोरा में पुरानी अप्रयुक्त गुठली को कैसे हटाया जाए। इस लेख में, हम बताएंगे कि डेबियन और उबंटू सिस्टम में पुरानी अप्रयुक्त गुठली को कैसे हटाया जाए, लेकिन आगे बढ़ने से पहले, आप इसका लाभ उठाने के लिए नवीनतम संस्करण को स्थापित करना चाह सकते हैं: सुरक्षा सुधार, नए कर्नेल फ़ंक्शन, अपडेट किए गए ड्राइवर और इसी तरह बहुत अधिक।

अपने कर्नेल को उबंटू और डेबियन के नवीनतम संस्करण में अपग्रेड करने के लिए, इस गाइड का पालन करें:

  1. How to Upgrade Kernel to Latest Version in Ubuntu

लाल

अपने सिस्टम पर चल रहे लिनक्स कर्नेल के वर्तमान संस्करण का पता लगाने के लिए, निम्न कमांड का उपयोग करें।

$ uname -sr

Linux 4.12.0-041200-generic

अपने सिस्टम पर सभी स्थापित गुठली को सूचीबद्ध करने के लिए, यह कमांड जारी करें।

$ dpkg -l | grep linux-image | awk '{print$2}'

linux-image-4.12.0-041200-generic
linux-image-4.8.0-22-generic
linux-image-extra-4.8.0-22-generic
linux-image-generic

डेबियन और उबंटू पर पुरानी अप्रयुक्त गुठली निकालें

किसी विशेष linux-image को उसकी कॉन्फ़िगरेशन फ़ाइलों के साथ हटाने के लिए नीचे दिए गए आदेश चलाएँ, फिर grub2 कॉन्फ़िगरेशन को अपडेट करें, और सिस्टम को अंतिम रूप से रिबूट करें।

$ sudo apt remove --purge linux-image-4.4.0-21-generic
$ sudo update-grub2
$ sudo reboot

Ubuntu में पुराने कर्नेल को हटाना

[sudo] password for tecmint: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  linux-generic linux-headers-4.8.0-59 linux-headers-4.8.0-59-generic linux-headers-generic linux-image-4.8.0-59-generic linux-image-extra-4.8.0-59-generic linux-image-generic
Suggested packages:
  fdutils linux-doc-4.8.0 | linux-source-4.8.0 linux-tools
Recommended packages:
  thermald
The following packages will be REMOVED:
  linux-image-4.8.0-22-generic* linux-image-extra-4.8.0-22-generic*
The following NEW packages will be installed:
  linux-headers-4.8.0-59 linux-headers-4.8.0-59-generic linux-image-4.8.0-59-generic linux-image-extra-4.8.0-59-generic
The following packages will be upgraded:
  linux-generic linux-headers-generic linux-image-generic
3 upgraded, 4 newly installed, 2 to remove and 182 not upgraded.
Need to get 72.0 MB of archives.
After this operation, 81.7 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://us.archive.ubuntu.com/ubuntu yakkety-updates/main amd64 linux-headers-4.8.0-59 all 4.8.0-59.64 [10.2 MB]
Get:2 http://us.archive.ubuntu.com/ubuntu yakkety-updates/main amd64 linux-headers-4.8.0-59-generic amd64 4.8.0-59.64 [811 kB]                                                               
Get:3 http://us.archive.ubuntu.com/ubuntu yakkety-updates/main amd64 linux-generic amd64 4.8.0.59.72 [1,782 B]                                                                               
Get:4 http://us.archive.ubuntu.com/ubuntu yakkety-updates/main amd64 linux-headers-generic amd64 4.8.0.59.72 [2,320 B]                                                                       
Get:5 http://us.archive.ubuntu.com/ubuntu yakkety-updates/main amd64 linux-image-4.8.0-59-generic amd64 4.8.0-59.64 [23.6 MB]                                                                
Get:6 http://us.archive.ubuntu.com/ubuntu yakkety-updates/main amd64 linux-image-extra-4.8.0-59-generic amd64 4.8.0-59.64 [37.4 MB]                                                          
Get:7 http://us.archive.ubuntu.com/ubuntu yakkety-updates/main amd64 linux-image-generic amd64 4.8.0.59.72 [2,348 B]                                                                         
Fetched 72.0 MB in 7min 12s (167 kB/s)                                                                                                                                                       
Selecting previously unselected package linux-headers-4.8.0-59.
(Reading database ... 104895 files and directories currently installed.)
Preparing to unpack .../0-linux-headers-4.8.0-59_4.8.0-59.64_all.deb ...
Unpacking linux-headers-4.8.0-59 (4.8.0-59.64) ...
Selecting previously unselected package linux-headers-4.8.0-59-generic.
Preparing to unpack .../1-linux-headers-4.8.0-59-generic_4.8.0-59.64_amd64.deb ...
Unpacking linux-headers-4.8.0-59-generic (4.8.0-59.64) ...
Preparing to unpack .../2-linux-generic_4.8.0.59.72_amd64.deb ...
Unpacking linux-generic (4.8.0.59.72) over (4.8.0.22.31) ...
Preparing to unpack .../3-linux-headers-generic_4.8.0.59.72_amd64.deb ...
Unpacking linux-headers-generic (4.8.0.59.72) over (4.8.0.22.31) ...
Selecting previously unselected package linux-image-4.8.0-59-generic.
Preparing to unpack .../4-linux-image-4.8.0-59-generic_4.8.0-59.64_amd64.deb ...
Done.
Removing linux-image-4.8.0-22-generic (4.8.0-22.24) ...
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 4.8.0-22-generic /boot/vmlinuz-4.8.0-22-generic
update-initramfs: Deleting /boot/initrd.img-4.8.0-22-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 4.8.0-22-generic /boot/vmlinuz-4.8.0-22-generic
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.12.0-041200-generic
Found initrd image: /boot/initrd.img-4.12.0-041200-generic
Found linux image: /boot/vmlinuz-4.8.0-59-generic
done
...

हालाँकि यह विधि ठीक काम करती है, लेकिन " ब्योबु " नामक एक आसान स्क्रिप्ट का उपयोग करना अधिक विश्वसनीय और कुशल है, जो उपरोक्त सभी आदेशों को एक कार्यक्रम में उपयोगी विकल्पों के साथ जोड़ती है जैसे कि गुठली की संख्या को रखने के लिए। सिस्टम पर।

बायोबू स्क्रिप्ट पैकेज स्थापित करें जो सिस्टम से पुराने कर्नेल और हेडर पैकेज को हटाने के लिए इस्तेमाल किया जाने वाला एक प्रोग्राम प्रदान करता है जिसे पर्ज-ओल्ड-कर्नेल कहा जाता है।

$ sudo apt install byobu

फिर पुरानी गुठली को ऐसे हटा दें (नीचे दी गई कमांड 2 गुठली को सिस्टम पर रखने की अनुमति देती है)।

$ sudo purge-old-kernels --keep 2

आप लिनक्स कर्नेल पर इन निम्नलिखित संबंधित लेखों को पढ़ना पसंद कर सकते हैं।

  1. How to Load and Unload Kernel Modules in Linux
  2. How to Change Kernel Runtime Parameters in a Persistent and Non-Persistent Way

इस लेख में, हमने वर्णित किया है कि उबंटू और डेबियन सिस्टम पर पुरानी अप्रयुक्त कर्नेल छवियों को कैसे हटाया जाए। आप नीचे दिए गए फीडबैक के माध्यम से कोई भी विचार साझा कर सकते हैं।