投稿者「momo」のアーカイブ

sysupgrade

NetBSD 5.1.2 のシステムがあって、6.1.4 にあげようと思ったわけだ。

ソースからコンパイルするのは時間が掛かるし、インストールDVDを用意してコンソールから作業するのも面倒なので、ちょっと調べてみると、pkgsrc/sysutils/sysupgrade というのが見つかった。

インストール用のバイナリデータを持ってきて、展開してインストールしてくれるらしい。

やってみた。

$ sudo sysupgrade auto
sysupgrade: I: Starting auto-update with stages: fetch modules kernel sets etcupdate postinstall clean
sysupgrade: W: Reusing existing /var/cache/sysupgrade/base.tgz
sysupgrade: W: Reusing existing /var/cache/sysupgrade/comp.tgz
sysupgrade: W: Reusing existing /var/cache/sysupgrade/etc.tgz
sysupgrade: W: Reusing existing /var/cache/sysupgrade/games.tgz
sysupgrade: W: Reusing existing /var/cache/sysupgrade/man.tgz
sysupgrade: W: Reusing existing /var/cache/sysupgrade/misc.tgz
sysupgrade: W: Reusing existing /var/cache/sysupgrade/tests.tgz
sysupgrade: W: Reusing existing /var/cache/sysupgrade/text.tgz
sysupgrade: W: Reusing existing /var/cache/sysupgrade/netbsd-GENERIC.gz
sysupgrade: I: Skipping modules installation (modules not in SETS)
sysupgrade: I: Upgrading kernel using GENERIC in /
sysupgrade: I: Backing up 'netbsd' kernel as 'onetbsd'
sysupgrade: I: Upgrading base system
sysupgrade: I: Extracting base into /
100% |***********************************|   100 MiB  426.04 KiB/s    00:00 ETA
sysupgrade: I: Extracting comp into /
[1]   Bad system call (core dumped) progress -zf "${...
(略)
$ /bin/ls
Bad system call

おおっと。

6.1.4 のバイナリに置き換わった時点でコマンドが使えなくなった。だが 6.1.4 のカーネルのインストールは済んでいるはずなので、再起動すれば動くような気がする。

reboot(8) も動かない状態なのでやむなくリセットボタンによる再起動。

なんとか動くようになったので、もう一度 sysupgrade を実行して 6.1.4 に。

あと、/usr/pkg/etc/sysupgrade.conf で SET=AUTO だと、/etc/mtree/set.modules が無いせいで modules がインストールされていなかったので追加でインストールしておいた。

$ sudo sysupgrade -o SET=modules modules

Apache 2.4 で PHP (mod_php) が動かなくなってた件

先日の件はPHP-FPM に切り替えることで対処。

pkgsrc/www/php-fpm をインストール。
/etc/rc.conf に php_fom=YES を追加して php-fpm を起動。

/usr/pkg/etc/httpd/httpd.conf で以下のモジュールを有効に。

LoadModule proxy_module lib/httpd/mod_proxy.so
LoadModule proxy_fcgi_module lib/httpd/mod_proxy_fcgi.so

php5_module の設定が残っている場合は削除。

Apache の ProxyPassMatch ディレクティブを使ってPHP ファイルへのアクセスを php-fpm へ転送する設定。ProxyPassMatch の第1引数は URL のルートからのパスにマッチする正規表現、第2引数の fcgi://127.0.0.1:9000 以降は対応する PHP ファイルの絶対パスを指定する。

ProxyPassMatch ^/~alice/(.*\.php)$ fcgi://127.0.0.1:9000/home/alice/public_html/$1

…userdir が絡むと面倒だな。

zoneedit と ddclient

zoneedit の dynamic DNS の更新に ddclient (pkgsrc/net/ddcleint) を利用していたのだが、エラーが出て更新できなくなってしまった。

zoneedit のアナウンスとかは見当たらなかったが、どうやら HTTPS でのみ更新が可能なように仕様が変更されたっぽい。

pkgsrc-2014Q1 の ddclient-3.6.6 は SSL が使用できないが、最新版では使用できるらしいとの話を聞きつけて、ddclient-3.8.2 を本家から持ってきて試してみたのだがエラーが出てうまくいかない。

syswrite() on closed filehandle GEN1 at ./ddclient line 1902.
Use of uninitialized value $result in numeric ne (!=) at ./ddclient line 1904.
WARNING:  cannot send to dynamic.zoneedit.com:443 (Bad file descriptor).

デバッグ出力を埋め込んで調べてみると、zoneedit の SSL 証明書の検証ができなくて失敗していることがわかった。

WARNING:  cannot connect to dynamic.zoneedit.com:443 socket: SSL connect attempt failed with unknown error error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed SSL connect attempt failed with unknown error error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

とはいえ、ブラウザはともかく、NetBSD で SSL ルート証明書の管理などしてない。どうしよう。

結局、検証は行わないように ddclient を修正して対処した。

@@ -1881,8 +1880,9 @@
             Proto => 'tcp',
             MultiHomed => 1,
             Timeout => opt('timeout'),
+            SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE(),
         );
-           defined $sd or warning("cannot connect to $peer:$port socket: $@ " . IO::Socket::SSL::errstr());
+           fileno($sd) or warning("cannot connect to $peer:$port socket: $@ " . IO::Socket::SSL::errstr());
     } else {
            $sd = IO::Socket::INET->new(
             PeerAddr => $peer,

SSL_VERYFY_NONE は IO::Socket::SSL 内で定義されている定数だが、他所から明示的に参照したいときはサブルーチンのように記述すれば良いらしい。

あと、IPアドレス取得用の URL も https://dynamic.zoneedit.com/checkip.html のように HTTPS しか受け付けなくなってしまった。上記の修正だけでは HTTP で取得しようとしてしまうのだが、ddclient.conf の web の引数に https:// を付けて記述すればよい。

use=web, web=https://dynamic.zoneedit.com/checkip.html, web-skip='IP Address'

pkgsrc-2014Q1 で Apache 2.4 と PHP 5.5 が動かなくなった

pkgsrc-2014Q1 がリリースされたのでアプリケーションをアップデートしていたところ、表題のように Apache が起動できなくなった。

$ sudo /etc/rc.d/apache start
Starting apache.
[Tue Apr 22 16:57:14.926914 2014] [:crit] [pid 19113:tid 3214934016] Apache is running a threaded MPM, but your PHP Module is not compiled to be threadsafe.  You need to recompile PHP.
AH00013: Pre-configuration failed

tech-pkg 012766 で既に話題には出ていたようだ。

で、対処方法としては AP-PHP の代わりに PHP-FPM を使え ってことなのかな。めんどくさいなあ。

そもそも PHP-FPM って何やねん、というレベルなのだが、ぐぐったら こんなページ が見つかったので、あとで参考にさせてもらうことにしよう。

ということで、まだ壊れて動かないまま。

NetBSD 6.1.3 → 6.1.4

前回のアップデートと同じように更新。

と思ったら、build.sh install を実行すると etcupdate が自動的に実行されてた。前回はどうだったのかな。

$ sudo ./build.sh -O ../obj -T ../tools -U install=/
...
obsolete check:
        Remove obsolete file ///lib/libcrypto.so.8.0
        Remove obsolete link ///usr/lib/libcrypto.so.8.0
        Remove obsolete file ///usr/lib/libdes.so.8.1
        Remove obsolete file ///usr/lib/libssl.so.10.0
ptyfsoldnodes check:
postinstall checks passed: bluetooth ddbonpanic defaults dhcpcd envsys fontconfig gid gpio hosts iscsi makedev motd named pam periodic pf pwd_mkdb rc ssh wscons x11 xkb uid varrwho tcpdumpchroot atf catpages ptyfsoldnodes
postinstall checks failed: mtree obsolete
To fix, run:
    /bin/sh /u5/NetBSD/src/usr.sbin/postinstall/postinstall -s '/u5/NetBSD/src' -d // fix mtree obsolete
Note that this may overwrite local changes.
...

postinstall を手動で実行するところは前回と同じ。/home/NetBSD は /u5/NetBSD へのシンボリックリンクなので実パスが表示されている。

$ sudo /bin/sh /u5/NetBSD/src/usr.sbin/postinstall/postinstall -s '/u5/NetBSD/src' -d // fix mtree obsolete
Source directory: /u5/NetBSD/src
Target directory: //
mtree fix:
        Copied /tmp/_postinstall.7561.0/NetBSD.dist to ///etc/mtree/NetBSD.dist
obsolete fix:
        Removed obsolete file ///lib/libcrypto.so.8.0
        Removed obsolete link ///usr/lib/libcrypto.so.8.0
        Removed obsolete file ///usr/lib/libdes.so.8.1
        Removed obsolete file ///usr/lib/libssl.so.10.0
postinstall fixes passed: mtree obsolete
postinstall fixes failed:
$ 

起動ドライブ (NetBSD) の引っ越し その2

HDD の引越し作業はこんな手順で行おうと思っている。

  1. 新しい HDD を PC につなぐ。デバイスは wd2。
  2. fdisk(8) で MBR を初期化する。
  3. MBR にブートコードを書き込む
  4. disklabel(8) でパーティションを作成する。
  5. 各パーティションにファイルシステムを作成する。
  6. 古いシステムドライブの中身をコピーする。
  7. パーティションテーブルにブートコードを書き込む。

以下は作業の様子。

1. 新しい HDD を PC につなぐ

こんな感じで認識された。

wd2 at atabus1 drive 1
wd2: 
wd2: drive supports 16-sector PIO transfers, LBA48 addressing
wd2: 1863 GB, 3876021 cyl, 16 head, 63 sec, 512 bytes/sect x 3907029168 sectors
wd2: 32-bit data port
wd2: drive supports PIO mode 4, DMA mode 2, Ultra-DMA mode 6 (Ultra/133)

2. fdisk(8) で MBR を初期化する

$ sudo fdisk -u wd2
Disk: /dev/rwd2d
NetBSD disklabel disk geometry:
cylinders: 3876021, heads: 16, sectors/track: 63 (1008 sectors/cylinder)
total sectors: 3907029168

BIOS disk geometry:
cylinders: 1024, heads: 255, sectors/track: 63 (16065 sectors/cylinder)
total sectors: 3907029168

Partitions aligned to 16065 sector boundaries, offset 63

Do you want to change our idea of what BIOS thinks? [n] n

Partition table:
0: 
1: 
2: 
3: 
Bootselector disabled.
No active partition.
Which partition do you want to change?: [none] 0
The data for partition 0 is:

sysid: [0..255 default: 169]
start: [0..243201cyl default: 2048, 0cyl, 1MB]
size: [0..243201cyl default: 3907027120, 243201cyl, 1907728MB]
bootmenu: [] NetBSD

Partition table:
0: NetBSD (sysid 169)
    bootmenu: NetBSD
    start 2048, size 3907027120 (1907728 MB, Cyls 0-243201/80/63)
        PBR is not bootable: All bytes are identical (0x00)
1: 
2: 
3: 
Bootselector disabled.
No active partition.
Which partition do you want to change?: [none] 

Installed bootfile doesn't support required options.
Update the bootcode from /usr/mdec/mbr_bootsel? [n] y

We haven't written the MBR back to disk yet.  This is your last chance.
Partition table:
0: NetBSD (sysid 169)
    bootmenu: NetBSD
    start 2048, size 3907027120 (1907728 MB, Cyls 0-243201/80/63)
        PBR is not bootable: All bytes are identical (0x00)
1: 
2: 
3: 
Bootselector enabled, timeout 10 seconds.
No active partition.
Should we write new partition table? [n] y

ん、オフセットは 63 じゃなくて 2048 なのか。

よくわからんが、最近は 2048 がデフォルトということのようだ。

3. MBR にブートコードを書き込む

2 の途中で MBR に /usr/mdec/mbr_bootsel が書き込むかどうか訊かれてたのでもう必要ない。

fdisk(8) の man によれば、次のようにして mbr_bootsel を書き込めるようだ。

fdisk -c /usr/mdec/mbr_bootsel /dev/rwd0d

ここでアクティパーティションも設定しておこう。

$ sudo fdisk -a wd2
Disk: /dev/rwd2d
NetBSD disklabel disk geometry:
cylinders: 3876021, heads: 16, sectors/track: 63 (1008 sectors/cylinder)
total sectors: 3907029168

BIOS disk geometry:
cylinders: 1024, heads: 255, sectors/track: 63 (16065 sectors/cylinder)
total sectors: 3907029168

Partitions aligned to 16065 sector boundaries, offset 63

Partition table:
0: NetBSD (sysid 169)
    bootmenu: NetBSD
    start 2048, size 3907027120 (1907728 MB, Cyls 0/32/33-243201/80/63)
1: 
2: 
3: 
Bootselector enabled, timeout 10 seconds.
No active partition.
Do you want to change the active partition? [n] y
Choosing 4 will make no partition active.
active partition: [0..4 default: 4] 0
Are you happy with this choice? [n] y

We haven't written the MBR back to disk yet.  This is your last chance.
Should we write new partition table? [n] y
$

4. disklabel(8) でパーティションを作成する

disklabel(8) で BSD パーティションを作成する。

用語が錯綜してわかりにくいが、FDISK のパーティションの中に BSD のパーティション構造が入るという入れ子構造だ。以前 FreeBSD 界隈では FDISK パーティションを「スライス」と読んで区別していたが、BSD と直接関係ない FDISK 関連のドキュメントを読むときには FDISK の方も単に「パーティション」と呼ばれるわけなので、FDISK パーティションに別名をついけたところで混乱が収まるわけでもないと思う。

何はともあれ、2 で作成した FDISK パーティション 0 の中に、BSD パーティション構造を作成するということだ。BSD 界隈では、「ディスクラベル」を作成する、と呼ばれる。この言い回しもわかりにくいような気がする。用いるツールは disklabel(8)。

$ sudo disklabel -i wd2
Enter '?' for help
partition> E
# /dev/rwd2d:
type: ESDI
disk: WDC WD20EFRX-68E
label: fictitious
flags:
bytes/sector: 512
sectors/track: 63
tracks/cylinder: 16
sectors/cylinder: 1008
cylinders: 3876021
total sectors: 3907029168
rpm: 3600
interleave: 1
trackskew: 0
cylinderskew: 0
headswitch: 0           # microseconds
track-to-track seek: 0  # microseconds
drivedata: 0

5 partitions:
#        size    offset     fstype [fsize bsize cpg/sgs]
 c: 3907027120      2048     unused      0     0        # (Cyl.      2*- 3876020)
 d: 3907029168         0     unused      0     0        # (Cyl.      0 - 3876020)
 e: 3907027120      2048     4.2BSD      0     0     0  # (Cyl.      2*- 3876020)
partition> a
Filesystem type [?] [unused]: 4.2bsd
Start offset ('x' to start after partition 'x') [0c, 0s, 0M]: 2048
Partition size ('$' for all remaining) [0c, 0s, 0M]: 4126720
 a:   4126720      2048     4.2BSD      0     0     0  # (Cyl.      2*-   4095)
partition> b
Filesystem type [?] [unused]: swap
Start offset ('x' to start after partition 'x') [0c, 0s, 0M]: a
Partition size ('$' for all remaining) [0c, 0s, 0M]: 16384c
 b:  16515072   4128768       swap                     # (Cyl.   4096 -  20479)
partition> e
Filesystem type [?] [unused]: 4.2bsd
Start offset ('x' to start after partition 'x') [0c, 0s, 0M]: b
Partition size ('$' for all remaining) [0c, 0s, 0M]: 32768c
 e:  33030144  20643840     4.2BSD      0     0     0  # (Cyl.  20480 -  53247)
partition> f
Filesystem type [?] [unused]: 4.2bsd
Start offset ('x' to start after partition 'x') [0c, 0s, 0M]: e
Partition size ('$' for all remaining) [0c, 0s, 0M]: 16384c
 f:  16515072  53673984     4.2BSD      0     0     0  # (Cyl.  53248 -  69631)
partition> g
Filesystem type [?] [unused]: 4.2bsd
Start offset ('x' to start after partition 'x') [0c, 0s, 0M]: f
Partition size ('$' for all remaining) [0c, 0s, 0M]: 16384c
 g:  16515072  70189056     4.2BSD      0     0     0  # (Cyl.  69632 -  86015)
partition> h
Filesystem type [?] [unused]: 4.2bsd
Start offset ('x' to start after partition 'x') [0c, 0s, 0M]: g
Partition size ('$' for all remaining) [0c, 0s, 0M]: 32768c
 h:  33030144  86704128     4.2BSD      0     0     0  # (Cyl.  86016 - 118783)
partition> i
Filesystem type [?] [unused]: 4.2bsd
Start offset ('x' to start after partition 'x') [0c, 0s, 0M]: h
Partition size ('$' for all remaining) [0c, 0s, 0M]: 786432c
 i: 792723456 119734272     4.2BSD      0     0     0  # (Cyl. 118784 - 905215)
partition> j
Filesystem type [?] [unused]: 4.2bsd
Start offset ('x' to start after partition 'x') [0c, 0s, 0M]: i
Partition size ('$' for all remaining) [0c, 0s, 0M]: 131072c
 j: 132120576 912457728     4.2BSD      0     0     0  # (Cyl. 905216 - 1036287)
partition> k
Filesystem type [?] [unused]: 4.2bsd
Start offset ('x' to start after partition 'x') [0c, 0s, 0M]: j
Partition size ('$' for all remaining) [0c, 0s, 0M]: $
 k: 2862450864 1044578304     4.2BSD      0     0     0  # (Cyl. 1036288 - 3876020)
partition> P
11 partitions:
#        size    offset     fstype [fsize bsize cpg/sgs]
 a:   4126720      2048     4.2BSD      0     0     0  # (Cyl.      2*-   4095)
 b:  16515072   4128768       swap                     # (Cyl.   4096 -  20479)
 c: 3907027120      2048     unused      0     0        # (Cyl.      2*- 3876020)
 d: 3907029168         0     unused      0     0        # (Cyl.      0 - 3876020)
 e:  33030144  20643840     4.2BSD      0     0     0  # (Cyl.  20480 -  53247)
 f:  16515072  53673984     4.2BSD      0     0     0  # (Cyl.  53248 -  69631)
 g:  16515072  70189056     4.2BSD      0     0     0  # (Cyl.  69632 -  86015)
 h:  33030144  86704128     4.2BSD      0     0     0  # (Cyl.  86016 - 118783)
 i: 792723456 119734272     4.2BSD      0     0     0  # (Cyl. 118784 - 905215)
 j: 132120576 912457728     4.2BSD      0     0     0  # (Cyl. 905216 - 1036287)
 k: 2862450864 1044578304     4.2BSD      0     0     0  # (Cyl. 1036288 - 3876020)
partition> W
Label disk [n]? y
Label written
partition> Q

5. 各パーティションにファイルシステムを作成する

newfs(8) に -O2 をつけてファイルシステムを作成する。-O2 は FFSv2 を指定するオプション。

newfs -O2 /dev/rwd2a

容量が大きいので時間がかかるかと覚悟していたのだがずいぶん早く終わった。FFSv2 だから?

6. 古いシステムドライブの中身をコピーする

$ sudo mount /dev/wd2a /mnt
$ cd /mnt
$ sudo dump -0 -a -f - /  | sudo restore -rf -

7. パーティションテーブルにブートコードを書き込む

あらかじめ dumpfs でファイルシステムの形式を確認しておく。

$ sudo dumpfs /dev/rwd2a
file system: /dev/rwd2a
format  FFSv2
...

セカンダリブートストラップコード /usr/mdec/boot を /boot (今は /mnt にマウントしてるので /mnt/boot)にコピーする。

$ sudo cp /usr/mdec/boot /mnt/boot

プライマリブートストラップコード /usr/mdec/bootxx_ffsv2 (ファイルシステムが FFSv2 の場合) を installboot(8) を使って書き込む。

$ sudo installboot -v /dev/rwd2a /usr/mdec/bootxx_ffsv2
File system:         /dev/rwd2a
Primary bootstrap:   /usr/mdec/bootxx_ffsv2
Ignoring PBR with invalid magic in sector 0 of `/dev/rwd2a'
Boot options:        timeout 5, flags 0, speed 9600, ioaddr 0, console pc

初めて実行すると “Ignoring PBR with invalid magic …” のメッセージが出るが、2回目以降では出ない。

起動ドライブ (NetBSD) の引っ越し その1

NetBSD の HDD がエラーを出すようになった。

/netbsd: wd0i: error reading fsbn 745561088 of 745561088-745561103 (wd0 bn 1102082687; cn 1093335 tn 15 sn 62), retrying
/netbsd: wd0: (aborted command)
/netbsd: ahcisata0 port 0: device present, speed: 3.0Gb/s
/netbsd: wd0i: error reading fsbn 745561088 of 745561088-745561103 (wd0 bn 1102082687; cn 1093335 tn 15 sn 62), retrying
/netbsd: wd0: (aborted command)
/netbsd: ahcisata0 port 0: device present, speed: 3.0Gb/s
/netbsd: wd0: soft error (corrected)

atactl wd0 smart status でステータスを見るとこんな感じ。数字を見ても危ないのかどうかよくわからないのだけれど、wd1 の方はエラー吐かないので、良くはなさそう。

SMART supported, SMART enabled
id value thresh crit collect reliability description                    raw
  1 200   51     yes online  positive    Raw read error rate            0
  3 195   21     yes online  positive    Spin-up time                   1208
  4 100    0     no  online  positive    Start/stop count               101
  5 200  140     yes online  positive    Reallocated sector count       0
  7 200    0     no  online  positive    Seek error rate                0
  9  93    0     no  online  positive    Power-on hours count           5479
 10 100   51     no  online  positive    Spin retry count               0
 11 100    0     no  online  positive    Calibration retry count        0
 12 100    0     no  online  positive    Device power cycle count       33
192 200    0     no  online  positive    Power-off retract count        67
193  24    0     no  online  positive    Load cycle count               528673
194 119    0     no  online  positive    Temperature                    28
196 200    0     no  online  positive    Reallocated event count        0
197 200    0     no  online  positive    Current pending sector         1
198 100    0     no  offline positive    Offline uncorrectable          0
199 200    0     no  online  positive    Ultra DMA CRC error count      344
200 100   51     no  offline positive    Write error rate               0

ということで、交換用の HDD を購入した。

製品は Western Digital の赤、WD20EFRX (3.5-inch 2TB SATA 6Gb/s 64MB Cache) 。ちなみに wd0 は 2010年に購入 したもので Western Digital WD6400BEVT (2.5-inch 640GB SATA 3Gb/s 8MB Cache 5400RPM)。

もともとサーバに 2.5-inch 入れてたのは省電力を意図していたんだけれど、WD Red の 3.5-inch もなかなかの省電力ということで今回は 3.5-inch にした。

消費電力を比較すると次の通り(WD のスペックシートより)。左から、WD6400BEVT が交換予定の 2.5-inch、WD10EADS が 3.5-inch のデータ用ドライブ (1TB)、WD20WFRX が新しく買った 3.5-inch ドライブだ。

WD6400BEVT WD10EADS WD20WFRX
Read/Write (W) 1.6 5.4 4.1
Idle (W) 0.65 2.8 3.0
Standby/Sleep (W) 0.20 0.4 0.4

2.5-inch には及ばないものの、WD20WFRX は読み書き時 4.1W、アイドル時で 3.0W と、ずいぶん優秀だ。しかし、こうして並べてみると WD10EADS もなかなかいい線いってる。

Dovecot, imapsync の更新

Dovecot 2.2.9, imapsync 1.564 の組合せにしたらエラーが出て接続できなくなった。

Error: user xxx: Initialization failed: namespace configuration error: There can be only one namespace with inbox=yes
Error: Invalid user settings. Refer to server log for more information.

/usr/pkg/etc/dovecot/local.conf にはこう書いてある。

# 略
namespace {
  separator = .
  prefix = INBOX.
  inbox = yes
}

こう修正したら、エラーは出なくなった。

# 略
namespace inbox {
# 略

あと、以前は imapsync の namespace 周りにバグがあって、オプションの –prefix2 と –sep2 で明示的に指定してやる必要があったのだけれど、今見たら必要なくなったみたい。

FreeBSD 9.2 で pkgng へ移行する

今どきの FreeBSD ではサードパーティアプリケーションは pkgng で管理するもののようだ。
というわけで、FreeBSD 9.2 で pkgng への移行作業を行うことにした。

参考:
http://www.freebsd.org/doc/ja/books/handbook/pkgng-intro.html

これまで使ってきた ports のデータベースは変換しないといけないらしい。
ハンドブックにしたがって作業する。

# /usr/sbin/pkg
The package management tool is not yet installed on your system.
Do you want to fetch and install it now? [y/N]: y
...
# pkg2ng
...
#

そして、/etc/make.conf に

WITH_PKGNG=yes

を追加しておく。

さてこれで pkg upgrade でパッケージの更新ができるはずなのだが、
やってみるとやれ設定ファイルがおかしいだの、リポジトリがないだのいわれて
一向に動かない。

pkg: PACKAGESITE in pkg.conf is deprecated. Please create a repository configuration file


pkg No valid repository found.

追加の設定が必要だった。pkg のバージョンが新しくてハンドブックが追いついていない模様。

  • /usr/pkg/local/etc/pkg.conf は削除
  • ディレクトリ /usr/local/etc/pkg/repos を作成
  • 設定ファイル /usr/local/etc/pkg/repos/FreeBSD.conf を作成

# rm /usr/local/etc/pkg.conf
# mkdir -p /usr/local/etc/pkg/repos
# vi /usr/local/etc/pkg/repos/FreeBSD.conf

FreeBSD: {
  url: "pkg+http://pkg.FreeBSD.org/${ABI}/latest",
  mirror_type: "srv",
  enabled: true
}

参考: http://april.fool.jp/blogs/2013/12/pkgng-1-2%E3%81%B8%E3%81%AE%E3%82%A2%E3%83%83%E3%83%97%E3%83%87%E3%83%BC%E3%83%88%E3%81%AB%E4%BC%B4%E3%81%86%E3%81%82%E3%82%8C%E3%81%93%E3%82%8C%E3%80%82/

オフィシャルにはどこに情報出てるんですかね?
pkg help ではわからなかったんですが。

# pkg update

インストールされてる perl が 5.12 と古くて自動で更新できなかった。

たとえば以下のような関連付けを行うと更新できる。

# pkg set -o lang/perl5.12:lang/perl5.16
# pkg upgrade

FreeBSD 9.0 → 9.2

ほったらかしにしてあった FreeBSD 9.0 を 9.2 にアップグレードした。

参考: http://www.freebsd.org/doc/ja/books/handbook/updating-upgrading-freebsdupdate.html

$ sudo freebsd-update -r 9.2-RELEASE upgrade

The following components of FreeBSD do not seem to be installed:
src/src

Does this look reasonable (y/n)? y

The following file could not be merged automatically: /etc/group
Press Enter to edit this file in /usr/bin/vi and resolve the conflicts
manually…

(自動でマージできなかった設定ファイルを手作業で編集)

(自動でマージされたファイルの確認)

To install the downloaded upgrades, run “/usr/sbin/freebsd-update install”.
$ sudo freebsd-update install
Installing updates…
Kernel updates have been installed. Please reboot and run
“/usr/sbin/freebsd-update install” again to finish installing updates.
$ sudo shutdown -r now

(再起動)

$ sudo freebsd-update install

$