Ubuntu その8 「/boot の空き容量が減ってきたら・・・」 | 乖離のぶろぐ(*´∀`)吸い込んで応援
■  /boot の空きを増やしたい対処

# ファイルシステムが満杯になったら、まず lsしてみるでしょ。
$ cd /boot
$ ls -l


合計 199409
-rw------- 1 root root 3023265 1月 26 2013 System.map-3.5.0-23-generic
-rw------- 1 root root 3024459 2月 26 2013 System.map-3.5.0-25-generic
-rw------- 1 root root 3018381 3月 12 07:39 System.map-3.5.0-26-generic
-rw------- 1 root root 3020830 4月 25 07:04 System.map-3.5.0-28-generic
-rw------- 1 root root 3020933 5月 18 00:48 System.map-3.5.0-31-generic
-rw------- 1 root root 3020933 5月 30 05:54 System.map-3.5.0-32-generic
-rw------- 1 root root 3021582 6月 8 01:50 System.map-3.5.0-34-generic
-rw------- 1 root root 3021733 6月 21 03:46 System.map-3.5.0-36-generic
-rw-r--r-- 1 root root 848290 1月 26 2013 abi-3.5.0-23-generic
-rw-r--r-- 1 root root 849836 2月 26 2013 abi-3.5.0-25-generic
-rw-r--r-- 1 root root 850088 3月 12 07:39 abi-3.5.0-26-generic
-rw-r--r-- 1 root root 852490 4月 25 07:04 abi-3.5.0-28-generic
-rw-r--r-- 1 root root 852530 5月 18 00:48 abi-3.5.0-31-generic
-rw-r--r-- 1 root root 852530 5月 30 05:54 abi-3.5.0-32-generic
-rw-r--r-- 1 root root 852614 6月 8 01:50 abi-3.5.0-34-generic
-rw-r--r-- 1 root root 852420 6月 21 03:46 abi-3.5.0-36-generic
-rw-r--r-- 1 root root 147880 1月 26 2013 config-3.5.0-23-generic
-rw-r--r-- 1 root root 147953 2月 26 2013 config-3.5.0-25-generic
-rw-r--r-- 1 root root 147953 3月 12 07:39 config-3.5.0-26-generic
-rw-r--r-- 1 root root 148105 4月 25 07:04 config-3.5.0-28-generic
-rw-r--r-- 1 root root 148142 5月 18 00:48 config-3.5.0-31-generic
-rw-r--r-- 1 root root 148142 5月 30 05:54 config-3.5.0-32-generic
-rw-r--r-- 1 root root 148142 6月 8 01:50 config-3.5.0-34-generic
-rw-r--r-- 1 root root 148142 6月 21 03:46 config-3.5.0-36-generic
drwxr-xr-x 3 root root 5120 7月 7 02:01 grub
-rw-r--r-- 1 root root 16107588 3月 8 20:17 initrd.img-3.5.0-23-generic
-rw-r--r-- 1 root root 16123054 3月 9 00:18 initrd.img-3.5.0-25-generic
-rw-r--r-- 1 root root 16149463 3月 25 08:05 initrd.img-3.5.0-26-generic
-rw-r--r-- 1 root root 16187357 5月 6 07:49 initrd.img-3.5.0-28-generic
-rw-r--r-- 1 root root 16187843 5月 31 19:07 initrd.img-3.5.0-31-generic
-rw-r--r-- 1 root root 16188696 5月 31 19:42 initrd.img-3.5.0-32-generic
-rw-r--r-- 1 root root 16185479 6月 19 23:41 initrd.img-3.5.0-34-generic
-rw-r--r-- 1 root root 16184138 7月 18 13:17 initrd.img-3.5.0-36-generic
drwxr-xr-x 2 root root 12288 3月 8 20:02 lost+found
-rw-r--r-- 1 root root 176764 11月 27 2011 memtest86+.bin
-rw-r--r-- 1 root root 178944 11月 27 2011 memtest86+_multiboot.bin
-rw------- 1 root root 5189248 1月 26 2013 vmlinuz-3.5.0-23-generic
-rw------- 1 root root 5191680 2月 26 2013 vmlinuz-3.5.0-25-generic
-rw------- 1 root root 5180064 3月 12 07:39 vmlinuz-3.5.0-26-generic
-rw------- 1 root root 5183296 4月 25 07:04 vmlinuz-3.5.0-28-generic
-rw------- 1 root root 5182464 5月 18 00:48 vmlinuz-3.5.0-31-generic
-rw------- 1 root root 5182144 5月 30 05:54 vmlinuz-3.5.0-32-generic
-rw------- 1 root root 5182912 6月 8 01:50 vmlinuz-3.5.0-34-generic
-rw------- 1 root root 5183904 6月 21 03:46 vmlinuz-3.5.0-36-generic

# ファイルがいっぱいだ。 23~36番が意味をもっているようだ。
# ファイルを消すには手順がある。

#----------------------------------------------------
# 古いカーネルの消し方は、
# カーネルイメージは何があるのか確認する。
#----------------------------------------------------
$ dpkg --get-selections | grep image

genisoimage install
libcupsimage2 install
linux-image-3.5.0-23-generic install
linux-image-3.5.0-25-generic install
linux-image-3.5.0-26-generic install
linux-image-3.5.0-28-generic install
linux-image-3.5.0-31-generic install
linux-image-3.5.0-32-generic install
linux-image-3.5.0-34-generic install
linux-image-3.5.0-36-generic install

linux-image-generic-lts-quantal install
screensaver-default-images install

#----------------------------------------------------
# linux-image-3.5.0-23-genericから、
# linux-image-3.5.0-36-genericが、カーネルイメージ。
#----------------------------------------------------

#----------------------------------------------------
# いま動いているイメージを確認する
#----------------------------------------------------
$ uname -a
Linux ubuntu64 3.5.0-36-generic #57~precise1-Ubuntu SMP Thu Jun 20 18:21:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

#------------------------------------------------------------------------
# 36と34は残して、23番から32番までは消す。
# 1つ前のイメージは、もしもの為に置いておきたい
#------------------------------------------------------------------------
$ sudo apt-get remove linux-image-3.5.0-23-generic
[sudo] password for ユーザー名:
E: ロック /var/lib/dpkg/lock が取得できませんでした - open (11: リソースが一時的に利用できません)
E: 管理用ディレクトリ (/var/lib/dpkg/) をロックできません。これを使う別のプロセスが動いていませんか?

#-------------------------------------------------------------
# Synapticパッケージマネージャが起動していると、互いにロックしあう。
# Synapticパッケージマネージャは使わないから終了させる。
#-------------------------------------------------------------

$ sudo apt-get remove linux-image-3.5.0-23-generic
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています
状態情報を読み取っています... 完了
以下のパッケージは「削除」されます:
linux-image-3.5.0-23-generic
アップグレード: 0 個、新規インストール: 0 個、削除: 1 個、保留: 101 個。
この操作後に 156 MB のディスク容量が解放されます。
続行しますか [Y/n]? Y
(データベースを読み込んでいます ... 現在 388451 個のファイルとディレクトリがインストールされています。)
linux-image-3.5.0-23-generic を削除しています ...
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 3.5.0-23-generic /boot/vmlinuz-3.5.0-23-generic
update-initramfs: Deleting /boot/initrd.img-3.5.0-23-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 3.5.0-23-generic /boot/vmlinuz-3.5.0-23-generic
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-3.5.0-36-generic
Found initrd image: /boot/initrd.img-3.5.0-36-generic
Found linux image: /boot/vmlinuz-3.5.0-34-generic
Found initrd image: /boot/initrd.img-3.5.0-34-generic
Found linux image: /boot/vmlinuz-3.5.0-32-generic
Found initrd image: /boot/initrd.img-3.5.0-32-generic
Found linux image: /boot/vmlinuz-3.5.0-31-generic
Found initrd image: /boot/initrd.img-3.5.0-31-generic
Found linux image: /boot/vmlinuz-3.5.0-28-generic
Found initrd image: /boot/initrd.img-3.5.0-28-generic
Found linux image: /boot/vmlinuz-3.5.0-26-generic
Found initrd image: /boot/initrd.img-3.5.0-26-generic
Found linux image: /boot/vmlinuz-3.5.0-25-generic
Found initrd image: /boot/initrd.img-3.5.0-25-generic
Found memtest86+ image: /memtest86+.bin
done

#----------------------------------------------------
# 消された番号は、deinstall となっている。
#----------------------------------------------------
$ dpkg --get-selections | grep image

genisoimage install
libcupsimage2 install
linux-image-3.5.0-23-generic deinstall
linux-image-3.5.0-25-generic install
linux-image-3.5.0-26-generic install
linux-image-3.5.0-28-generic install
linux-image-3.5.0-31-generic install
linux-image-3.5.0-32-generic install
linux-image-3.5.0-34-generic install
linux-image-3.5.0-36-generic install

linux-image-generic-lts-quantal install
screensaver-default-images install


#----------------------------------------------------
# 下記のようになるまで、 sudo apt-get remove を繰り返す。
#----------------------------------------------------
$ dpkg --get-selections | grep image

genisoimage install
libcupsimage2 install
linux-image-3.5.0-23-generic deinstall
linux-image-3.5.0-25-generic deinstall
linux-image-3.5.0-26-generic deinstall
linux-image-3.5.0-28-generic deinstall
linux-image-3.5.0-31-generic deinstall
linux-image-3.5.0-32-generic deinstall
linux-image-3.5.0-34-generic install
linux-image-3.5.0-36-generic install
linux-image-generic-lts-quantal install
screensaver-default-images install


#----------------------------------------------------
# deinstall された後の /boot
#----------------------------------------------------
$ ls -ltr
合計 50168
-rw-r--r-- 1 root root 178944 11月 27 2011 memtest86+_multiboot.bin
-rw-r--r-- 1 root root 176764 11月 27 2011 memtest86+.bin
drwxr-xr-x 2 root root 12288 3月 8 20:02 lost+found
-rw------- 1 root root 5182912 6月 8 01:50 vmlinuz-3.5.0-34-generic
-rw-r--r-- 1 root root 148142 6月 8 01:50 config-3.5.0-34-generic
-rw-r--r-- 1 root root 852614 6月 8 01:50 abi-3.5.0-34-generic
-rw------- 1 root root 3021582 6月 8 01:50 System.map-3.5.0-34-generic
-rw-r--r-- 1 root root 16185479 6月 19 23:41 initrd.img-3.5.0-34-generic
-rw------- 1 root root 5183904 6月 21 03:46 vmlinuz-3.5.0-36-generic
-rw-r--r-- 1 root root 148142 6月 21 03:46 config-3.5.0-36-generic
-rw-r--r-- 1 root root 852420 6月 21 03:46 abi-3.5.0-36-generic
-rw------- 1 root root 3021733 6月 21 03:46 System.map-3.5.0-36-generic
-rw-r--r-- 1 root root 16184138 7月 18 13:17 initrd.img-3.5.0-36-generic
drwxr-xr-x 3 root root 5120 9月 6 03:01 grub


参考URL
http://tatuas.hatenablog.com/entry/2013/08/22/015141
http://osser.jp/blogspot/ubuntu-boot-partition-100