すでにFreeBSDを導入している読者にとっては、
この仕組みは本来、
freebsd-updateによる7.0-RELEASEへのアップグレード
すでにFreeBSDをインストールしている読者ならば、
- /etc, /boot/
loader. conf、 /root など、 / (ルートパーティション) 内で自分が手を加えたファイルを退避 - 古いFreeBSDの上に、
CD-ROMから新しいFreeBSDを上書きインストール。その際disklabelのときに全てのパーティションを 「M」 (Mount point set) キーでもって単にマウントすることにする。 - とはいっても若干気持悪いので、
disklabelのときに 「T」 (toggle newfs) でもって / だけはnewfsしてまっさらにする - インストールが終わったら、
退避しておいた/etcなどの設定ファイルを元に戻す。 - 戻すファイルの代表的なものは/etc/
rc. conf、 /etc/ group (viを立ち上げてマージ)、 /etc/ master. passwd (vipw中で手動でマージ)、 /etc/ ssh/*key* (host keyがかわると面倒)、 /etc/ printcap、 /etc/ resolv. conf、 /boot/ loader. confなど - パッケージは、
暇があるときは全部自分で作り直す (俺的パッケージを作るための、 RUN_ DEPENDSをやたら指定した 「Mitapkgs」 というportsを個人的に持ってメンテナンスしている) が、 暇が無いときはそのまま。 - 古いCライブラリ
(たとえばFreeBSD 6なのに/lib/ libc. so. 5 =FreeBSD 5のlibc)も、 そのまま。
以上のやり方は、
- 更新が必要なファイルは更新してくれ
- 自分で設定したファイルはそのまま、
うまいことマージしてくれ - 古いライブラリは消してくれること
FreeBSD 6.
- 必要な差分を入手
- カーネルを入れ替え
- ライブラリ等新ファイルを追加
- (手動)
パッケージの入れかえ - 旧ライブラリファイルの削除
このうち1、
[手順0]6.3-RELEASEを用意する
今回記事を執筆するにあたり、
[手順1]差分の入手
まずrootとなり、
# freebsd-update -r 7.0-RELEASE upgrade
すると、
Looking up update.FreeBSD.org mirrors... 1 mirrors found. Fetching metadata signature for 6.3-RELEASE from update1.FreeBSD.org... done. Fetching metadata index... done. Fetching 1 metadata patches. done. Applying metadata patches... done. Fetching 2 metadata files... done. Inspecting system... done.
カーネルのコンフィグが違ったり、
WARNING: This system is running a "smp" kernel, which is not a
kernel configuration distributed as part of FreeBSD 7.0-RELEASE.
As part of upgrading to FreeBSD 7.0-RELEASE, this kernel will be
replaced with a "generic" kernel.
Does this look reasonable (y/n)? y
Inspecting system... done.
Fetching files from 6.3-RELEASE for merging... done.
Preparing to download files... done.
Fetching 16721 patches.....10....20....30....40....50....60....70....80....90....100....110..
《途中略》
16710....16720 done.
Applying patches... done.
Fetching 6288 files... done.
Attempting to automatically merge changes in files... done.
次に、
The following changes, which occurred between FreeBSD 6.3-RELEASE and FreeBSD 7.0-RELEASE have been merged into /etc/group: --- current version +++ new version @@ -1,6 +1,6 @@ -# $FreeBSD: src/etc/group,v 1.32.2.1 2006/03/06 22:23:10 rwatson Exp $ +# $FreeBSD: src/etc/group,v 1.35 2007/06/11 18:36:39 ceri Exp $ # wheel:*:0:root,mita,work00,jeux,work01,work02,work03,work04,work05,work06,work07 daemon:*:1: kmem:*:2: sys:*:3: @@ -9,10 +9,11 @@ mail:*:6: bin:*:7: news:*:8: man:*:9: games:*:13: +ftp:*:14: staff:*:20: sshd:*:22: smmsp:*:25: mailnull:*:26: guest:*:31: Does this look reasonable (y/n)? y The following changes, which occurred between FreeBSD 6.3-RELEASE and FreeBSD 7.0-RELEASE have been merged into /etc/nsswitch.conf: --- current version +++ new version @@ -1,7 +1,15 @@ +# +# nsswitch.conf(5) - name service switch configuration file +# $FreeBSD: src/etc/nsswitch.conf,v 1.1 2006/05/03 15:14:47 ume Exp $ +# group: compat group_compat: nis hosts: files dns networks: files passwd: compat passwd_compat: nis shells: files +services: compat +services_compat: nis +protocols: files +rpc: files Does this look reasonable (y/n)? y
アップデートに際して削除される予定のファイル一覧が表示され、
The following files will be removed as part of updating to 7.0-RELEASE-p0:
/boot/kernel/bridge.ko
/boot/kernel/g_md.ko
《途中略》
/var/named/etc/namedb/named.root
/var/yp/Makefile.dist
[手順2]カーネルの入れ替え
今度は以下を入力
# freebsd-update -r 7.0-RELEASE install
で実際にカーネルの入れ換えが行われる。
Installing updates... Kernel updates have been installed. Please reboot and run "/usr/sbin/freebsd-update install" again to finish installing updates.
と言われるとおり、
[手順3]ユーザランドのインストール
再起動で立ち上がった後、
# freebsd-update install
としてライブラリ等のインストールを行う。
Installing updates... Completing this upgrade requires removing old shared object files. Please rebuild all installed 3rd party software (e.g., programs installed from the ports tree) and then run "/usr/sbin/freebsd-update install" again to finish installing updates.
一連の作業中、
[手順4]パッケージの入れ替え(手動)
反省して2回目の7.
- portsnapを使って今日の最新portsを用意した上で
- ネット上に7.
0-RELEASE用のパッケージがあれば、 それを使ってアップグレードする
方法が推奨されているようだが、
筆者がお勧めする入れ替え法は、
- FreeBSDのインストールCDから7.
0-RELEASEのportsを展開した上で - CD-ROMやネット上に7.
0-RELEASE用のパッケージがあれば、 それを使ってアップグレードする (その際ネットから取得したパッケージは/usr/ ports/ packages/ All/に保存される) - また、
portsを使ってインストールするときにはついでにpackageも作る
以下、
- /etc/
make. confの整備 /etc/
make. confに以下の3行を追加する。 BATCH="YES" DEPENDS_
TARGET="package" PACKAGE_ BUILDING="YES" - 古いportsディレクトリの退避
# mv /usr/
ports /usr/ ports. 6.3-RELEASE - FreeBSD 7.
0-RELEASEのdisc1をCD-ROMドライブに挿入 # mount /cdrom
- 7.
0-RELEASEのportsを展開 # cd /usr; tar --unlink -xvzf /cdrom/
7. 0-RELEASE/ ports/ ports. tgz - portupgradeを実行
# env PACKAGEROOT=ftp://
ftp. jp. FreeBSD. org PKG_ PATH=/cdrom/ packages/ All portupgrade -afP --results-file /tmp/ ports. results. txt
上記手順で、
この状態で、
※注
本稿を作成するために、
/var/db/ pkg/ pkgdb. db: unexpected file type or format -- Invalid argument
というエラーである。エラーのログを読むと
回避方法としては、
- portupgrade-2.
3.1,2 - ruby-1.
8.6. 111_ 1,1 - ruby18-bdb-0.
6.2
だけを手動でインストールしなおした後、
# mv /var/db/ # mv /var/pkg/ portupgrade-2. 3.1,2 /root/ db/ # mv /var/pkg/ ruby-1. 8.6. 111_ 1,1 /root/ db/ # pkgdb -upkg/ ruby18-bdb-0. 6.2 /root/
として、portupgrade -afP
を実行する。全てのパッケージ入れ換えが終了した後に、
# mv /root/portupgrade-2. # pkgdb -u3.1,2 /root/ ruby-1. 8.6. 111_ 1,1 /root/ ruby18-bdb-0. 6.2 /var/ db/ pkg/
としてportupgradeの
また、
[手順5]旧ライブラリファイルの削除
パッケージのアップデートが終了したら、
# freebsd-update install
これでめでたく移行は終了である。
おわりに
筆者もfreebsd-updateによるバージョンアップ機能を初めて使ってみたが、