2004年10月14日
FreeBSD のインストールと stable の追跡
Pentium4 3.40GHzマシンにFreeBSDをインストールし、FreeBSD 5-stableブランチを追跡するサーバとして仕上げる。CD-ROMからインストールした後、cvsupとportupgradeを使って、OSとportsからインストールされているアプリケーションを最新のものにする。
作業を行ったパソコン構成の詳細はサーバマシンの買い替えを、BIOS設定の詳細はASUSTeK P4C800-E BIOSの設定を、参照のこと。
インストールには、現時点で最新のリリースである FreeBSD 5.2.1-Release を使った。
まず、フロッピィーディスクとFTPサーバを使ったインストールを試みて、失敗した。フロッピーディスクを使ったインストーラのブートが、うまくいかない。おそらく新しいハードウェアに対応したデバイスドライバが組み込まれていないからだ。しかし、ハードウェアの設定ミスや初期不良と区別がつきにくく、ハマった。インストールにCDを使うと、この症状は発生せずにうまくいった。インストールにはCDを使うことを強くお勧めする。CDを準備するには、FTPサイトから5.2.1-RELEASE-i386-miniinst.isoイメージファイルをダウンロードして、CD-Rに焼けばよい。
具体的に今回現れた症状は、FDによるブート時の次のエラーであった。
Fatal trap 9: general protection fault while in kernel mode
(中略)
panic: general protection fault
cpuid = 0;
Uptime: 1s
Automatic reboot in 15 seconds - press a key on the console to abort
インストール作業自体はインストーラのガイダンスにそって進めれば簡単だ。
まず、パーティションの設定は次のようにした。/var はログが蓄積していくので、その他の領域に必要な容量の余りをすべて割り当てた。
Filesystem 容量 マウント位置
/dev/ar0s1a 9.7G /
/dev/ar0s1b 10G swap
/dev/ar0s1e 39G /home
/dev/ar0s1d 19G /usr
/dev/ar0s1f 106G /var
次に、配布ファイルはDeveloperを選んだ。サーバとして使う予定なので、X Window System以外のソース・バイナリなどをインストールする。
そして、CD-ROMからインストールを行う。
FreeBSD 5.2.1-Releaseのインストールが終わったら、5-stableにシステムをアップデートする。
まず、ソースツリーをダウンロードするためのツールcvsupをインストールしておく。
# cd /usr/ports/net/cvsup-without-gui
# make install
そして、cvsupの設定ファイルを準備する。
# cd /usr/share/examples/cvsup
# cp standard-supfile /etc/supfile
# ping cvsupN.jp.FreeBSD.org (Nを整数値で変えてみて、最寄のサーバを探す)
# vi /etc/supfile
最寄のホストを選択
*default host=cvsup3.jp.FreeBSD.org
5-Stableを追うようにする (tag=. なら current を追う)
*default release=cvs tag=RELENG_5
また、portsやdocも更新されるようにする。(portsにstableはない)
# echo ports-all tag=. >> /etc/supfile
# echo doc-all tag=. >> /etc/supfile
cvsup を実行し、最新のカーネルやプログラムのソース、最新のportsスケルトンをダウンロードする。
# cvsup -g -L 2 /etc/supfile
システム専用のカーネル・コンフィグを準備する
# cd /usr/src/sys/i386/conf
# cp GENERIC COMMOORE
(COMMOOREはホスト名、任意の名前でよい)
# vi COMMOORE
# diff GENERIC COMMOORE
25c25
< ident GENERIC
---
> ident COMMOORE
64,68c64,68
< options DDB # Enable the kernel debugger
< options INVARIANTS # Enable calls of extra sanity checking
< options INVARIANT_SUPPORT # Extra sanity checks of internal structures, required by INVARIANTS
< options WITNESS # Enable checks to detect deadlocks and cycles
< options WITNESS_SKIPSPIN # Don't run witness on spinlocks for speed
---
> #options DDB # Enable the kernel debugger
> #options INVARIANTS # Enable calls of extra sanity checking
> #options INVARIANT_SUPPORT # Extra sanity checks of internal structures, required by INVARIANTS
> #options WITNESS # Enable checks to detect deadlocks and cycles
> #options WITNESS_SKIPSPIN # Don't run witness on spinlocks for speed
(注: 5.3-Release が近づいた時点でDDBからWITNESS_SKIPSPINまでのオプションは5-stableから取り除かれた)
パッチを取っておくと,GENERICの更新に対応するための処理に便利
# cp GENERIC COMMOORE.orig
# diff -u COMMOORE.orig COMMOORE > GENERIC2COMMOORE.20040622.patch
システム専用のカーネル・コンフィグを使うように設定する
# echo KERNCONF=COMMOORE >> /etc/make.conf
システム全体の再構築を行う。
# cd /usr/src
# make buildworld
# make buildkernel
# make installkernel
# mergemaster -p
# make installworld
# mergemaster
# shutdown -r now
これで、OSは最新のstableになる。
次にportsで管理されているアプリケーションを最新のものにする。
ports 管理のために portupgrade をインストールする。
# cd /usr/ports/sysutils/portupgrade
# make
# make install
パッケージレジストリデータベースに不整合がないことを確認する.
今後,portupgrade を使っていく上で,たまに確認すべき.
# pkgdb -F
portsインデックスを更新する.
今後,portversion を使っていく上で,事前に実行すべき.
# portsdb -Uu (このコマンドには長い時間がかかる)
アップデートの必要なportsのアプリケーションを確認する.
# portversion -v
cvsup-without-gui-16.1h = up-to-date with port
expat-1.95.6_1 < needs updating (port has 1.95.8)
ezm3-1.1 < needs updating (port has 1.2)
gettext-0.12.1 < needs updating (port has 0.13.1_1)
gmake-3.80_1 < needs updating (port has 3.80_2)
libiconv-1.9.1_3 < needs updating (port has 1.9.2_1)
libtool-1.3.5_1 < needs updating (port has 1.3.5_2)
perl-5.6.1_15 = up-to-date with port
portupgrade-20040529_2 < needs updating (port has 20040701_3)
ruby-1.8.1.2004.05.02 < needs updating (port has 1.8.1.2004.05.02_1)
ruby18-bdb1-0.2.2 = up-to-date with port
実際にportsからインストールされているアプリケーションのアップデートを行う
例:
パッケージがどのバージョンへアップグレードされるか確認するには、
# portupgrade -na (実際に更新は行われない)
portupgrade をバージョンアップするには、
# portupgrade -r portupgrade
libtool をバージョンアップするには、
# portupgrade -r libtool (→ gettext, gmake も依存関係で更新される)
更新する必要のあるものすべてを更新するには、
# portupgrade -ra
これで、OSとportsからインストールされているアプリケーションが最新のものとなる。
portupgrade の参考
1.http://www.fkimura.com/portupgrade1.html
2.usage: portupgrade
-a, --all Do with all the installed packages
-f, --force Force the upgrade of a port even if it is to be a downgrade or just a reinstall, or the port is held
-n, --noexecute Do not upgrade any ports, but just show what would be done
-N, --new Install a new one when a specified package is not installed, after upgrading all the dependent packages (default: off)
-o, --origin=ORIGIN Specify a port to upgrade the following pkg with
-r, --recursive Do with all those depending on the given packages as well
-R, --upward-recursive Do with all those required by the given packages as well / Fetch recursively if -F is specified