R.A. Epigonos et al.

[Debian] Openvpn クライアント側にログインして Wheezy から Jessie にアップグレード

アップグレードしたいコンピュータに ssh でログインしてアップグレード作業。しかし、外のネットワークから入るにはファイヤーウォールががあってこのコンピュータにsshで入ることはできない。中から外に出ることは可能なので、このコンピュータでは Openvpn クライアントが動いていて外に置いた Openvpn サーバに接続している。通常のメンテナンス時は Openvpn ネットワークを使ってsshでログインして作業。この環境下でうまいことアップグレードできるかテスト。

まずはアップグレード前に現在のシステムを更新しておく。とりあえず再起動掛けておく。

# apt-get update && apt-get -y upgrade && apt-get clean
Hit http://ftp.jp.debian.org wheezy Release.gpg
Hit http://ftp.jp.debian.org wheezy Release
Hit http://security.debian.org wheezy/updates Release.gpg
Hit http://ftp.jp.debian.org wheezy/main Sources
Hit http://security.debian.org wheezy/updates Release
Hit http://ftp.jp.debian.org wheezy/main amd64 Packages
Hit http://ftp.jp.debian.org wheezy/main Translation-en
Hit http://security.debian.org wheezy/updates/main Sources
Hit http://security.debian.org wheezy/updates/main amd64 Packages
Hit http://security.debian.org wheezy/updates/main Translation-en
Reading package lists... Done
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages have been kept back:
  xserver-xorg-input-all
The following packages will be upgraded:
  linux-image-3.2.0-4-amd64 linux-libc-dev
2 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
Need to get 24.3 MB of archives.
After this operation, 2545 kB of additional disk space will be used.
Get:1 http://security.debian.org/ wheezy/updates/main linux-image-3.2.0-4-amd64 amd64 3.2.68-1+deb7u1 [23.5 MB]
Get:2 http://security.debian.org/ wheezy/updates/main linux-libc-dev amd64 3.2.68-1+deb7u1 [839 kB]
Fetched 24.3 MB in 2s (9091 kB/s)
Reading changelogs... Done
Preconfiguring packages ...
(Reading database ... 156372 files and directories currently installed.)
Preparing to replace linux-image-3.2.0-4-amd64 3.2.65-1+deb7u2 (using .../linux-image-3.2.0-4-amd64_3.2.68-1+deb7u1_amd64.deb) ...
Unpacking replacement linux-image-3.2.0-4-amd64 ...
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 3.2.0-4-amd64 /boot/vmlinuz-3.2.0-4-amd64
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 3.2.0-4-amd64 /boot/vmlinuz-3.2.0-4-amd64
Preparing to replace linux-libc-dev:amd64 3.2.65-1+deb7u2 (using .../linux-libc-dev_3.2.68-1+deb7u1_amd64.deb) ...
Unpacking replacement linux-libc-dev:amd64 ...
Setting up linux-image-3.2.0-4-amd64 (3.2.68-1+deb7u1) ...
Running depmod.
Examining /etc/kernel/postinst.d.
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 3.2.0-4-amd64 /boot/vmlinuz-3.2.0-4-amd64
update-initramfs: Generating /boot/initrd.img-3.2.0-4-amd64
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 3.2.0-4-amd64 /boot/vmlinuz-3.2.0-4-amd64
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-3.2.0-4-amd64
Found initrd image: /boot/initrd.img-3.2.0-4-amd64
Found linux image: /boot/vmlinuz-2.6.32-5-amd64
Found initrd image: /boot/initrd.img-2.6.32-5-amd64
Found Debian GNU/Linux (6.0.5) on /dev/vda1
done
Setting up linux-libc-dev:amd64 (3.2.68-1+deb7u1) ...
# shutdown -r now

その後再度Openvpnネットワーク経由でsshログイン。セッションが切れても大丈夫なようにscreen起動しておく。

$ ssh -X -l ******** 192.168.40.6
Enter passphrase for key '/****************/.ssh/id_rsa':
$ screen -D -RR

apt の pin 状態を確認

# cat /etc/apt/preferences
cat: /etc/apt/preferences: No such file or directory
# cat /etc/apt/preferences.d/*
cat: /etc/apt/preferences.d/*: No such file or directory

パッケージ状態を保存

# dpkg --get-selections "*" > wheezy-curr-pkgs.txt

パッケージ状態がholdのものを確認。

# dpkg --get-selections | grep 'hold$'

proposed-updates セクションがないことを確認。

# grep proposed-updates /etc/apt/sources.list

パッケージ状態をチェック。再インストールを求められているので再インストール。

# dpkg --audit
The following packages are missing the md5sums control file in the
database, they need to be reinstalled:
 rxvt                 VT102 terminal emulator for the X Window System

# apt-get --reinstall install rxvt
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 1 not upgraded.
Need to get 227 kB of archives.
After this operation, 0 B of additional disk space will be used.
Get:1 http://ftp.jp.debian.org/debian/ wheezy/main rxvt amd64 1:2.6.4-14 [227 kB]
Fetched 227 kB in 0s (996 kB/s)
(Reading database ... 156372 files and directories currently installed.)
Preparing to replace rxvt 1:2.6.4-14 (using .../rxvt_1%3a2.6.4-14_amd64.deb) ...
Unpacking replacement rxvt ...
Processing triggers for man-db ...
Setting up rxvt (1:2.6.4-14) ...
update-alternatives: error: no alternatives for rclock
# dpkg --audit

/etc/apt/sources.list の内容確認。非公式のリポジトリはなさそうなのでそのまま進む。

# grep -v -e "^[ \t]*#" -e "^$" /etc/apt/sources.list
deb http://ftp.jp.debian.org/debian wheezy main
deb-src http://ftp.jp.debian.org/debian wheezy main
deb http://security.debian.org/ wheezy/updates main
deb-src http://security.debian.org/ wheezy/updates main

リポジトリを wheezy から jessie に修正。最終的には以下。

# vi /etc/apt/sources.list
# grep -v -e "^[ \t]*#" -e "^$" /etc/apt/sources.list
deb http://ftp.jp.debian.org/debian jessie main
deb-src http://ftp.jp.debian.org/debian jessie main
deb http://security.debian.org/ jessie/updates main
deb-src http://security.debian.org/ jessie/updates main

/ と /usr がマウントされている場所と、マウント先が rw かを調べる。

# df /usr
Filesystem                                             1K-blocks    Used Available Use% Mounted on
/dev/disk/by-uuid/********-****-****-****-************   9611492 5038120   4085132  56% /
# df /
Filesystem                                             1K-blocks    Used Available Use% Mounted on
/dev/disk/by-uuid/********-****-****-****-************   9611492 5038120   4085132  56% /
# cat /proc/mounts
rootfs / rootfs rw 0 0
(snip)

scriptでセッション内容を記録しておく。

# script -t 2>~/upgrade-jessie.time -a ~/upgrade-jessie.script
Script started, file is /root/upgrade-jessie.script

パッケージリスト更新

# apt-get update
Get:1 http://ftp.jp.debian.org jessie Release.gpg [2390 B]
Get:2 http://ftp.jp.debian.org jessie Release [126 kB]
Get:3 http://security.debian.org jessie/updates Release.gpg [1571 B]
Get:4 http://security.debian.org jessie/updates Release [61.5 kB]
Get:5 http://ftp.jp.debian.org jessie/main Sources [7065 kB]
Get:6 http://security.debian.org jessie/updates/main Sources [21.5 kB]
Get:7 http://security.debian.org jessie/updates/main amd64 Packages [39.1 kB]
Get:8 http://security.debian.org jessie/updates/main Translation-en [20.5 kB]
Get:9 http://ftp.jp.debian.org jessie/main amd64 Packages [6765 kB]
Get:10 http://ftp.jp.debian.org jessie/main Translation-en [4585 kB]
Fetched 18.7 MB in 7s (2666 kB/s)
Reading package lists... Done

アップグレードに必要な空き領域の確認。今回は1617MB程度必要で、/の空き領域が4GB程度あるので大丈夫そう。

# apt-get -o APT::Get::Trivial-Only=true dist-upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages will be REMOVED:
(snip)
The following NEW packages will be installed:
(snip)
922 upgraded, 275 newly installed, 30 to remove and 0 not upgraded.
Need to get 1617 MB of archives.
After this operation, 720 MB of additional disk space will be used.
E: Trivial Only specified but this is not a trivial operation.
# df /
Filesystem                                             1K-blocks    Used Available Use% Mounted on
/dev/disk/by-uuid/********-****-****-****-************   9611492 5038120   4085132  56% /

まずはシステムの最小アップグレード。途中でアップグレードされるパッケージの情報がpagerで表示される、pagerはqを押して終了。

# apt-get upgrade

ディスク領域に余裕がなければこの後にcleanしておく

# apt-get clean

その後システムのアップグレード。sshやopenvpnデーモンの再起動がかかるけれど、接続は自動で回復する。基本的にはパッケージメンテナの設定ファイルを採用する。

# apt-get dist-upgrade

上の作業でパッケージメンテナの設定ファイルを採用したものについては手作業で必要な設定を書き込む。

# vimdiff /etc/fuse.conf /etc/fuse.conf.dpkg-old
# vimdiff /etc/schroot/default/fstab /etc/schroot/default/fstab.dpkg-old

削除されたパッケージを完全消去する。

# dpkg -l | awk '/^rc/ { print $2 }'
defoma
libaudit0
libdrm-nouveau1
libept1
libgcj10
libgs8
libgvc5
libkadm5srv-mit8:amd64
libmagick++3
libmagickcore3
libmagickwand3
libpango1.0-common
libpoppler5
libxmlrpc-c3
portmap
texlive-doc-base
x-ttcidfont-conf
# apt-get purge $(dpkg -l | awk '/^rc/ { print $2 }')

再起動

# shutdown -r now

アップグレードによって大量のパッケージがキャッシュされる。これを削除。下の例では1199個のファイルと1.5GBの領域が使われている。apt-get cleanで削除する。

# ls /var/cache/apt/archives/ | wc
   1199    1199   40652
# du -c /var/cache/apt/archives/
4       /var/cache/apt/archives/partial
1585776 /var/cache/apt/archives/
1585776 total
# apt-get clean
# du -c /var/cache/apt/archives/
4       /var/cache/apt/archives/partial
80      /var/cache/apt/archives/
80      total

忘れられているパッケージを削除し、完全削除する。

# apt-get autoremove
# apt-get purge $(dpkg -l | awk '/^rc/ { print $2 }')

いくつかperlスクリプトが動かなくなったので。検索パスを調べるとやっぱり変わってる。

# perl -le "print foreach @INC;"
/etc/perl
/usr/local/lib/perl/5.14.2
/usr/local/share/perl/5.14.2
/usr/lib/perl5
/usr/share/perl5
/usr/lib/perl/5.14
/usr/share/perl/5.14
/usr/local/lib/site_perl
.

perlモジュールのそれっぽい所を探すと古いディレクトリがたくさん。

# perl -le "print foreach @INC;"
/etc/perl
/usr/local/lib/x86_64-linux-gnu/perl/5.20.2
/usr/local/share/perl/5.20.2
/usr/lib/x86_64-linux-gnu/perl5/5.20
/usr/share/perl5
/usr/lib/x86_64-linux-gnu/perl/5.20
/usr/share/perl/5.20
/usr/local/lib/site_perl
.
# find / -name '*5.14.2*' -type d
/usr/local/lib/perl/5.14.2
/usr/local/share/perl/5.14.2
/usr/lib/perl/5.14.2
# ls -latr -d /usr/local/lib/perl/* /usr/local/share/perl/* /usr/lib/perl/*
drwxr-sr-x 107 root staff 4096 May  4  2013 /usr/local/share/perl/5.10.1
drwxr-sr-x  47 root staff 4096 May  8  2013 /usr/local/lib/perl/5.10.1
drwxr-xr-x   2 root root  4096 May  9  2013 /usr/lib/perl/5.10.1
drwxrwsr-x  55 root staff 4096 Apr 17 18:29 /usr/local/lib/perl/5.14.2
drwxrwsr-x 123 root staff 4096 Apr 20 18:25 /usr/local/share/perl/5.14.2
drwxr-xr-x   2 root root  4096 Apr 27 12:58 /usr/lib/perl/5.14.2
drwxrwsr-x  57 root staff 4096 Apr 27 15:10 /usr/local/share/perl/5.20.2
# du -s /usr/local/lib/perl/* /usr/local/share/perl/* /usr/lib/perl/*
47432   /usr/local/lib/perl/5.10.1
82780   /usr/local/lib/perl/5.14.2
59376   /usr/local/share/perl/5.10.1
57812   /usr/local/share/perl/5.14.2
33536   /usr/local/share/perl/5.20.2
532     /usr/lib/perl/5.10.1
1536    /usr/lib/perl/5.14.2

リファレンス

  1. 第4章 Debian 7 (wheezy) からのアップグレード

ソーシャルブックマーク

  1. はてなブックマーク
  2. Google Bookmarks
  3. del.icio.us

ChangeLog

  1. Posted: 2008-07-16T11:47:58+09:00
  2. Modified: 2008-07-16T11:47:58+09:00
  3. Generated: 2023-08-27T23:09:12+09:00