【訳】Remove Old Kernels in Ubuntu Ubuntu古いカーネルを手動で削除


I've written a new post that shows a bash one-liner command that will remove the old kernels from your system in one step. You can check it out here . 私は文章を書いて、1行のbashコマンドを表示して、あなたのシステムの古いカーネルを削除することを教えます.ここを見てもいいです.
 
If you've been using Ubuntu Linux for a while, then you probably have a number of Linux kernel updates that have been installed on your system. (I've got a total of 3 kernels in my Karmic system already.) In all likelihood, these updates get installed and you boot into the latest kernel, never to use the older kernels again. But these old kernels are still hanging around on your system, cluttering up your grub boot screen and taking up space on your hard drive.Ubuntu Linuxをしばらく使用している場合は、更新時にシステムにいくつかのLinuxカーネルがインストールされている可能性があります(私のKarmicバージョンには全部で3つのカーネルバージョンがあります).これらの更新されたLinux版のカーネルは、あなたのパソコンにインストールされてから、古いカーネルを使うことはありません.しかし、これらの古いカーネルは依然としてあなたのシステムをうろうろしていて、grubの起動画面を混乱させ、ハードディスクドライブのスペースを占有しています.There have been attempts made to create an automatic tool to clean these up for you along with much discussion on the Ubuntu Forums , but so far there's nothing officially in the repositories. 現在Ubuntuフォーラムでは、これらを清掃するための自動ツールの作成を検討していますが、まだ正式な倉庫はありません.
 
In the past, I've gone into Synaptic and searched for the older kernels and related packages and manually marked them for removal. This method works fine, but the search process is a little slow in Synaptic and you have to run a few searches to catch all of the packages to remove. I decided to come up with a way to do this from the terminal and hopefully save some time. The commands I'm going to use can be a bit daunting, so just copy and paste. 以前は、古いカーネルと関連するパッケージを削除するために手動でマークされた新しい検索に入りました.この方法は効果的ですが、検索プロセスは長いプロセスです.少量の検索を実行し、すべてのパッケージの削除をキャプチャする必要があります.私はこのことをする方法を考え出して、少し時間を節約したいと思っています.私が使っているこれらのコマンドは少し怖いかもしれませんので、コピーして貼り付けるだけでいいです.
Warning
Don't follow this process unless you're sure you don't need to boot into the older kernels. If you're not sure, just leave things alone. Also, it is possible to remove all of the kernels from your system and make it unbootable. I suggest leaving the latest kernel and one version previous to that. 古いカーネルを起動する必要がないと確信しない限り、そうしないでください.よく分からない場合は、次の操作もしないほうがいいです.また、すべてのカーネルをシステムから削除して起動できません.最新バージョンのカーネルと最新バージョンの前のバージョンを維持することを強くお勧めします.下のコマンドでパソコンのカーネルのバージョン情報を見つけることができます
uname -r

Find and remove old kernels
The first step is to figure out what kernels are installed. The following command will do the job.
最初のステップは、どのカーネルをインストールする必要があるかを構成し、下のコマンドを実行することです.
ls /boot | grep vmlinuz | cut -d'-' -f2,3

Your result should look something like this.
実行後の結果はこうかもしれません
2.6.28-15
2.6.28-16
2.6.28-17

This is the list of kernels installed on your system. Now you want to find out which packages are installed relative to the kernel you want to remove. For my example I'm going to remove the oldest one, 2.6.28-15.
このリストには、あなたのシステムにインストールされている横長がリストされています.削除したいカーネルの関連パッケージを見つける必要があります.例えば、最も古いバージョン2.6.28-15を削除したいです.
dpkg -l | grep ^ii | grep 2.6.28-15 | awk -F' ' '{ print $2 }'

On my system, (Jaunty) the resulting list is:
私のシステムでは、このような結果が出ています.
linux-headers-2.6.28-15
linux-headers-2.6.28-15-generic
linux-image-2.6.28-15-gener
linux-restricted-modules-2.6.28-15-generic

Now that we know what packages to remove we can remove them with dpkg, apt-get or aptitude.
私たちが出すパッケージを知っていて、コマンドdpkg、apt-get、またはaptitudeを使っています.
sudo aptitude remove linux-headers-2.6.28-15 linux-headers-2.6.28-15-generic linux-image-2.6.28-15-generic linux-restricted-modules-2.6.28-15-generic

That's it. You've removed an old kernel and related packages. Now you can keep your system as clean as it is right after you install Ubuntu. The commands are a bit complex, so maybe I'll write up a bash script when I have some time. Proceed with caution!
このようにして、あなたはすでに古いカーネルと関連するパッケージリソースを削除して、今あなたはあなたのきれいなシステムを維持することができて、それはあなたが唯一のUbuntuをインストールするためです.このコマンドは少し複雑なので、時間があればbashスクリプトを書くかもしれません.慎重に行動せよ!
 
下はカーネルを削除するshell文字です
txlong@txlong-K40AB:~$ sudo -s
[sudo] password for txlong: 
root@txlong-K40AB:~# aptitude remove linux-image-2.6.35-22-generic
       “  ”:           
 linux-image-2.6.35-22-generic 
0        ,    0  , 1      ,    0      。
     0B    。        107MB。
(        ...          129056       。)
     linux-image-2.6.35-22-generic ...
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 2.6.35-22-generic /boot/vmlinuz-2.6.35-22-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 2.6.35-22-generic /boot/vmlinuz-2.6.35-22-generic
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-2.6.35-28-generic
Found initrd image: /boot/initrd.img-2.6.35-28-generic
Found memtest86+ image: /boot/memtest86+.bin
Found Windows 7 (loader) on /dev/sda2
done
The link /vmlinuz.old is a damaged link
Removing symbolic link vmlinuz.old 
 you may need to re-run your boot loader[grub]
The link /initrd.img.old is a damaged link
Removing symbolic link initrd.img.old 
 you may need to re-run your boot loader[grub]

root@txlong-K40AB:~# 

 
Ubuntuをしばらく使用すると、自動アップグレードのため、システムに多くのカーネルがインストールされていることに気づきます.私のように、意外にも下のように多くインストールされていて、これは長い起動リストをもたらしました.使わないものを削除しなければなりません.まず、以下のコマンドを使用して、インストールされているすべてのカーネルをリストします.次の表では、image付きのカーネルファイルを示します.からアンインストールするパッケージを選択しapt-getでアンインストール
[tc@ibm:~]$ dpkg --get-selections|grep linux
libselinux1 install
linux-386 install
linux-image-2.6.15-23-386 install
linux-image-2.6.15-27-386 install
linux-image-2.6.15-27-686 install
linux-image-2.6.15-28-386 install
linux-image-2.6.15-28-686 deinstall
linux-image-386 install
linux-kernel-headers install
linux-restricted-modules-2.6.15-23-386 install
linux-restricted-modules-2.6.15-27-386 install
linux-restricted-modules-2.6.15-27-686 install
linux-restricted-modules-2.6.15-28-386 install
linux-restricted-modules-2.6.15-28-686 deinstall
linux-restricted-modules-386 install
linux-restricted-modules-common install
linux-sound-base install
util-linux install 

具体的なアンインストール方法は
sudo apt-get remove linux-image-2.6.15-23-386 

これにより、カーネルファイルを自動的に削除したり、ディスク領域を解放したりすることができます.
また、コマンドも記録します.
uname -a 

このコマンドを使用して、現在のシステムで使用されているカーネルを表示します.