PC」カテゴリーアーカイブ

起動ドライブ (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 もなかなかいい線いってる。

PC不調

Windows7 を入れているPCが不調になった。電源ON後、BIOS画面の途中(HDDを識別しているあたり)で、動かなくなったり、稼働中に動かなくなったり突然再起動がかかったり。

その内に、どこかのファイルが壊れたか、Windows Aero が効かなくなった。半透明のはずのタスクバーが不透明のグレーになっている。

起動ディスクを使って修復を試みたが、治らない。

やむを得ず、数日前のバックアップを書き戻してやると、治った模様。

と思ったら、しばらくして、再度同じような展開(不安定→Aero停止)で障害が発生した。

電源が怪しいかも、と思って、Amazon でATX電源(サイズ ショートタイプATX電源 剛力短2プラグイン 500W 80PLUSブロンズ SPGT2-500P)を購入(6,421円)、入替。バックアップを書き戻して様子を見る。

しかし改善しない。障害発生のパターンは同様。

外したかな? と思ったが、交換した電源はずいぶんと古いものだったので、交換時期に達していたとして、必要な出費と自らに言い聞かせる。

次に怪しいのはHDD周り。でも、HDD、マザーボード、ケーブルの3パターンは考えられる。

ここは思い切って、総替えで行くことにした。ツクモでまとめ買い(計56,521円)

CPU Intel Core i7 2600 Box (LGA1155) 23,940円
マザーボード GIGABYTE GA-Z68XP-UD3 2,980円
メモリ Patriot DDR3-1333 4GB×2枚 PSD38G1333K 3,680円
ビデオカード GIGABYTE GV-R645OC-1GI (Radeon HD6450) 4,681円
HDD HITACHI Deskstar 2TB 0S03224 6,780円
DVD multi LG GH24NS70SL 2,480円
HDDケース MARSHAL MAL-1335B/S 1,980円
合計 56,521円

ビデオカードとか直接関係ないけど、今まで使っていたのが古い(nVidia 7600GS)ので、この機会に入れ替えることにした。DVD multi-drive は、今までのがIDEで、今度のマザーボードにIDEはついてないので必然的に入替えることに。メモリはDDR2の頃と比べても劇的に安くなっているなあ。

最初にHDD以外の全てを入れ替えても、症状変わらず。じゃあ、HDDが原因か、ということでHDDを入れ替えて、バックアップを新しいHDDに書き戻すと、2、3日大丈夫だと思ったら、やっぱりその後ダメに。

結局、まるごと新しいシステムに、Windows7を再インストールすることで落ち着いた。バックアップイメージが既に壊れたシステムのバックアップとなっていたようだ。

調子の悪かったHDDは S.M.A.R.T ツールで確認すると幾つかのパラメータが警告状態となっていた。昨年9月の購入だから使用期間は丸1年立つか立たないかくらい。ネットで調べると Wentern Digital の WD20EARS-R は Advanced Format 絡みの性能低下の話を抜きにしてもずいぶんと評判が悪いみたいだ。

当分、Western Digital は購入禁止だな。でも、日立はWDになっちゃうのか。

ATX電源を入れ替えてみた

サーバの消費電力の削減のため、Celeron D 315 で運用している NetBSD サーバの HDD を 3.5インチ IDE から 2.5インチ STA のものに入れ替えた。約10W程度低下。ところが、interface CRC error がしばしば発生し、ハングアップするようになってしまった。

マザーボードが GA-8VM800M と古いものなので STA の HDD だと満足に動かないのかもしれない。AHCI とかないし。(今調べたら VT8237R は SATA2 300MB/s で動かないらしい。HDD 側の設定を変えないといけな場合があるそうだ)

いい機会なので、システムを入れ替えることにした。スペックはそれほど要求されないので省電力を意識して Core i3-530 で組んでみた。マザーボードは ZOTAC H55MAT-A-E。メモリも DDR3 になるので入れ替えだ。

ところが期待するほどの低消費電力になっていない。アイドル時で 62W程度。5W位は減ったのかな。構成は以下のとおり。ネットで見られる事例と比較すると、もっと下がって良いような気がする。

  • ZOTAC H55MAT-A-E
  • Intel Core i3-530
  • CFD ELIXIR W3U1333Q-1G (DDR3 PC3-10600 CL9 1GB x2)
  • Intel Pro/1000 MT Desktop Adapter (32bit PCI 1000BASE-T)
  • Western Digital WD6400BEVT (2.5-inch 640GB SATA 3Gb/s 8MB Cache 5400RPM)
  • Western Digital WD10EADS (3.5-inch 1TB SATA 3Gb/s 32MB Cache 5400RPM)

他に影響しそうなのは電源くらいである。最近は 80PLUS とかいうのがブームらしいので、電源を入れ替えることにした。とはいえ、ショップで見られる 80PLUS の電源は 400W 以上で、500W~800Wくらいが主流のようである。低出力の電源で 80PLUS のはなさそうだし、そもそも店に置いていなかったりする。

そんな状況で、なるべく低出力で、かつ 80PLUS のものを探してみたところ、
Antec の EA-380D Green とかいうのがあった。380W で 80PLUS Bronze。値段はそこそこするが、やむをえない。

入れ替えると 62W→52W という結果。電源だけで結構違う。というか、元の電源はこんなにも効率が悪かったのか。新しい方の効率が仮に 80% とすると古い方は 67% くらい? 電源重要だな。

  • 新 Antec EA-380D Green (380W ATX12V v2.3 80PLUS Bronze)
  • 旧 TORICA SEI3-400 (470W ATX v2.03)