R.A. Epigonos et al.

[debian] リモートでアップグレードする。lennyからsqueeze。

リモートでlennyからsqueezeへのアップグレードを行う。sshで対象のマシンにログインして作業。

まずはsshでログイン、suでrootになる。

$ ssh -l ** *********
Warning: the RSA host key for '*********' differs from the key for the IP address '************'
Offending key for IP in /home/**/.ssh/known_hosts:6
Matching host key in /home/**/.ssh/known_hosts:15
Are you sure you want to continue connecting (yes/no)? yes
**@*********'s password:
Linux ********* 2.6.26-2-686 #1 SMP Thu Jan 27 00:28:05 UTC 2011 i686

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Fri Feb 18 21:37:18 2011 from ************
**@*********:~$ su -
パスワード:
*********:~#

まずは公式手順に書かれているように、トラブルの元になるパッケージの削除

# apt-get purge splashy
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package splashy is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

aptitudeをビジュアルモードで起動して、gを押す。問題なければ以下の内容が表示される。okボタンを押して、qで終了する。

┌────────────────────────────────────────────────────────────────┐
│No packages are scheduled to be installed, removed, or upgraded.│
│                             [ Ok ]                             │
└────────────────────────────────────────────────────────────────┘

aptのpin情報を参照する。以下のように、/etc/apt/preferencesが存在しない場合は問題なし。

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

dpkgを使って、インストールに問題のあったパッケージを探す。以下のコマンドを打って、何も表示されなければ問題なし。

# dpkg --audit

ホールド状態のパッケージを探す。以下のコマンドを打って、何も表示されなければ問題なし。

# aptitude search "~ahold" | grep "^.h"

/etc/apt/sources.listから、proposed-updatesセクションを探す。以下のコマンドで何も表示されなければ問題なし。

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

/etc/apt/sources.listの内容を確認して、公式以外のaptラインがあるかどうか調べる。ある場合にはこのリポジトリがsqueeze用のリポジトリを提供しているか調べる。以下の例では、debian-multimediaとoperaというdebian公式でないaptラインが含まれている。両方ともsqueeze用のパッケージが用意されている。

# grep -v -e "^[ \t]*#" -e "^$" /etc/apt/sources.list
deb http://ftp.jp.debian.org/debian/ lenny main contrib non-free
deb-src http://ftp.jp.debian.org/debian/ lenny main contrib non-free
deb http://security.debian.org/ lenny/updates main contrib non-free
deb-src http://security.debian.org/ lenny/updates main contrib non-free
deb http://deb.opera.com/opera lenny non-free
deb http://www.debian-multimedia.org lenny main

すべてのaptラインのlennyをsqueezeに置換しておく。operaとdebian-multimediaに関しては、公式ページを参照して、適当なものに変更。最終的に以下のようになった。

# grep -v -e "^[ \t]*#" -e "^$" /etc/apt/sources.list
deb http://ftp.jp.debian.org/debian/ squeeze main contrib non-free
deb-src http://ftp.jp.debian.org/debian/ squeeze main contrib non-free
deb http://security.debian.org/ squeeze/updates main contrib non-free
deb-src http://security.debian.org/ squeeze/updates main contrib non-free
deb http://deb.opera.com/opera squeeze non-free
deb http://www.debian-multimedia.org squeeze main non-free

ここからは、パッケージのアップグレードを行う。まずはscriptでセッション内容を記録しておく。

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

まずは、パッケージリストの更新。以降の作業にはaptitudeではなく、apt-getを使用する。こちらを使用することには公式ページにその旨注意書きがあるのでこれを踏襲する。

# apt-get update
Get:1 http://ftp.jp.debian.org squeeze Release.gpg [1671B]
Get:2 http://ftp.jp.debian.org squeeze Release [69.3kB]
Get:3 http://security.debian.org squeeze/updates Release.gpg [835B]
Get:4 http://ftp.jp.debian.org squeeze/main Packages [6565kB]
Get:5 http://security.debian.org squeeze/updates Release [38.4kB]
Get:6 http://deb.opera.com squeeze Release.gpg [189B]
Hit http://deb.opera.com stable Release.gpg
Get:7 http://deb.opera.com squeeze Release [1066B]
Get:8 http://www.debian-multimedia.org squeeze Release.gpg [198B]
Get:9 http://security.debian.org squeeze/updates/main Packages [23.6kB]
Hit http://deb.opera.com stable Release
Get:10 http://www.debian-multimedia.org squeeze Release [22.2kB]
Get:11 http://security.debian.org squeeze/updates/contrib Packages [14B]
Get:12 http://security.debian.org squeeze/updates/non-free Packages [14B]
Get:13 http://security.debian.org squeeze/updates/main Sources [7497B]
Ign http://deb.opera.com squeeze/non-free Packages
Get:14 http://ftp.jp.debian.org squeeze/contrib Packages [54.1kB]
Get:15 http://ftp.jp.debian.org squeeze/non-free Packages [108kB]
Get:16 http://ftp.jp.debian.org squeeze/main Sources [3720kB]
Ign http://deb.opera.com stable/non-free Packages/DiffIndex
Get:17 http://security.debian.org squeeze/updates/contrib Sources [14B]
Get:18 http://security.debian.org squeeze/updates/non-free Sources [14B]
Get:19 http://deb.opera.com squeeze/non-free Packages [721B]
Get:20 http://www.debian-multimedia.org squeeze/main Packages [75.1kB]
Get:21 http://ftp.jp.debian.org squeeze/contrib Sources [33.9kB]
Get:22 http://ftp.jp.debian.org squeeze/non-free Sources [61.7kB]
Ign http://deb.opera.com stable/non-free Packages
Hit http://deb.opera.com stable/non-free Packages
Get:23 http://www.debian-multimedia.org squeeze/non-free Packages [5544B]
Fetched 10.8MB in 8s (1219kB/s)
Reading package lists... Done

アップグレードに必要なディスク量をチェックする。このマシンの場合、400MB程度の空き容量が必要ということがわかる。dfで空き容量を確認すると、5GB程度あるので問題なし。空き容量を作る方法として、debianの公式ページにはdeborphan等を使うことが書かれている。

# 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:
  gnome-apt libdatrie0 libept0 libxcb-xlib0 xserver-xorg-video-cyrix
...
  xulrunner-1.9
The following NEW packages will be installed:
  acpi-fakekey alsa-base alsa-utils anthy-common apt-utils apt-xapian-index
...
  xserver-common xulrunner-1.9.1 xz-utils zenity
The following packages will be upgraded:
  acpi acpi-support acpi-support-base acpid adduser anacron anthy apmd apt
...
  xutils-dev zlib1g
583 upgraded, 233 newly installed, 9 to remove and 0 not upgraded.
Need to get 426MB of archives.
After this operation, 417MB of additional disk space will be used.
E: Trivial Only specified but this is not a trivial operation.
# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/hda5             7.5G  2.1G  5.1G  29% /
tmpfs                 252M     0  252M   0% /lib/init/rw
udev                   10M  692K  9.4M   7% /dev
tmpfs                 252M     0  252M   0% /dev/shm

最小アップグレードを行う。完全アップグレードとはdist-upgradeすることをさすが、その前にupgradeすることで、パッケージの競合状態を打開することができる。upgradeした場合には、ほかのパッケージに影響のないパッケージだけをアップデートすることになる。また、システムの容量不足でdist-upgradeできない場合でもupgradeしておくだけで有用。Configuring libpam0g というメッセージが出た場合はそのままOK

# apt-get upgrade

カーネルのアップグレードを行う。その前に、インストール済みのカーネルのフレーバーをチェックしておく。以下の例では686ということになる。同じカーネルをここではインストールする。インストール中にConfiguring linux-baseというタイトルで2回聞かれるが、両方ともyesを選択。重要なのは、update-grubが走っているかどうか確認すること。メッセージを確認すると、Running update-grub.という文字列が流れていることがわかる。見落としている可能性もあるので、scriptファイルからgrepで見つけるのもよし。見えなければ手作業で起動する。

# dpkg -l "linux-image*" | grep ^ii
ii  linux-image-2.6-686                  2.6.26+17+lenny1               Linux 2.6 image on PPro/Celeron/PII/PIII/P4
ii  linux-image-2.6.26-2-686             2.6.26-26lenny2                Linux 2.6.26 image on PPro/Celeron/PII/PIII/
# apt-get install linux-image-2.6-686
...
Running update-grub.
...
# grep update-grub upgrade-squeeze.script
Running update-grub.

次に新しいudevを明示的にインストール。Configuring libc6というタイトルでlibcを使っているサービスを聞かれるので、okを押す。

# apt-get install udev

カーネルとudevのアップグレードが終わったら、再起動を行う。再起動中に表示されるgrubの画面で、新しいカーネルが選択されていることがわかる。

# shutdown -h now

Broadcast message from root@********* (pts/1) (Fri Feb 18 22:52:06 2011):

The system is going down for system halt NOW!

再起動したらsshでログインして、完全アップグレードを行う。Configuring dashというタイトルで聞かれるので、okを押す。Configuring sysv-rcというタイトルで聞かれるのでokを押す。Configuring keyboard-configurationというタイトルで聞かれるので、IBM ThinkPad 560Z/600/600E/A22Eを選択(このマシンはThinkPad X32)。問題があれば後からでも変えられるので気にしない。Configuring grub-pcというタイトルで2回聞かれるので、そのままokボタンを押す。さらにConfiguring grubというタイトルで聞かれるのでOKボタンを押す。

# apt-get dist-upgrade

ここまで終わったら一度電源を切る。

# shutdown -h now

Broadcast message from root@********* (pts/0) (Fri Feb 18 23:16:41 2011):

The system is going down for system halt NOW!

時代遅れのパッケージを削除する。まずは自動的に削除。次にaptitudeをビジュアルモードで起動して、"Obsolete and Locally Created Packages"のセクションに移動し、削除マークをつけ(_)、これを実行(g)し、確認画面が出るのでさらに実行(g)する。

# apt-get autoremove

電源ボタンをおしてマシンを起動。grubからgrub2がチェインロードされていることがわかる。ほかのパーティションにインストールされているほかのOSがgrub2から起動できることをチェック。windows XPがインストールされていて、これの起動に成功することを確認。またIBM rescue and recoveryが起動することも確認。デフォルトをgrub2にしても問題なさそうなので、そうしておく。マシンにsshでログイン、rootになる。

まずはチェインロードされるgrub2のインストールされているパーティションを確認。以下のような設定になっているので、チェインロードされたgrubはroot (hd0,4)ということがわかる。つまり/dev/sda5にインストールされているということだ。新しいgrubのインストール先はここではだめということだ。

title           Chainload into GRUB 2
root            (hd0,4)
kernel          /boot/grub/core.img

以下のコマンドからアップグレードを行う。grubをインストールする先のパーティションが選択できるが、先にチェックしておいたパーティションにはインストールしても無駄。別パーティションにインストールを行う。ここではMBRにインストールするようにした。

# upgrade-from-grub-legacy
# upgrade-from-grub-legacy
0

Package configuration
   ┌─────────────────────────────────────────────────────────────────────┤ Configuring grub-pc ├──────────────────────────────────────────────────────────────────────┐
   │ The grub-pc package is being upgraded. This menu allows you to select which devices you'd like grub-install to be automatically run for, if any.                 │
   │                                                                                                                                                                  │
   │ Running grub-install automatically is recommended in most situations, to prevent the installed GRUB core image from getting out of sync with GRUB modules or     │
   │ grub.cfg.                                                                                                                                                        │
   │                                                                                                                                                                  │
   │ If you're unsure which drive is designated as boot drive by your BIOS, it is often a good idea to install GRUB to all of them.                                   │
   │                                                                                                                                                                  │
   │ Note: it is possible to install GRUB to partition boot records as well, and some appropriate partitions are offered here. However, this forces GRUB to use the   │
   │ blocklist mechanism, which makes it less reliable, and therefore is not recommended.                                                                             │
   │                                                                                                                                                                  │
   │ GRUB install devices:                                                                                                                                            │
   │                                                                                                                                                                  │
   │    [*] /dev/sda (40007 MB; HTS541040G9AT00)                                                                                                                      │
   │    [ ] - /dev/sda5 (10459 MB; /)                                                                                                                                  │
   │                                                                                                                                                                  │
   │                                                                                                                                                                  │
   │                                                                              <Ok>                                                                                │
   │                                                                                                                                                                  │
   └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Installation finished. No error reported.
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-2.6.32-5-686
Found initrd image: /boot/initrd.img-2.6.32-5-686
Found Microsoft Windows XP Professional on /dev/sda1
Found Windows NT/2000/XP on /dev/sda4
done

GRUB Legacy has been removed, but its configuration files have been preserved,
since this script cannot determine if they contain valuable information.  If
you would like to remove the configuration files as well, use the following
command:

  rm -f /boot/grub/menu.lst*

シャットダウンして再起動。grubが正しくアップデートされたことがわかる。

# shutdown -h now

Broadcast message from root@x32debian (pts/0) (Sat Feb 19 00:34:31 2011):

The system is going down for system halt NOW!

リファレンス

  1. 第4章 Debian 5.0 (lenny) からのアップグレード
  2. D: Tips - Debian GNU/Linux スレッドテンプレ
  3. deborphan - Google 検索
  4. D: AptGet - Debian GNU/Linux スレッドテンプレ
  5. proposed-updates /etc/apt/sources.list - Google 検索
  6. Debian Multimedia Packages::Home
  7. http://www.debian-multimedia.org squeeze - Google 検索
  8. The Opera .deb Repository
  9. http://deb.opera.com/opera squeeze - Google 検索
  10. grep/正規表現で、設定ファイルのコメント行を削除する - P-SQUARE MIDI Site
  11. grep 削除 - Google 検索
  12. Debian クイックリファレンス - Debian パッケージ管理
  13. Obsolete and Locally Created Packages - Google 検索
  14. GNU GRUB Manual 1.99~rc1

ソーシャルブックマーク

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

ChangeLog

  1. Posted: 2009-10-02T01:06:56+09:00
  2. Modified: 2009-10-02T01:06:56+09:00
  3. Generated: 2023-08-27T23:09:15+09:00