以下にあるの作業は誤るとNetBSDが起動しなくなります!
以下の説明では、wd2(3番目のHDD)で説明してますが、実際の作業時にはwd0(1番目のHDD)になると思います。
マスターブートレコードのバックアップ
wd0のマスターブートレコードを/etc/mbrで保管します。
> dd if=/dev/wd0d of=/etc/mbr bs=512 count=1
マスターブートレコードのリストア
/etc/mbrをwd2へ復元します。パテーション情報も一緒に復元されますが、bs=512をbs=446とすればパテーション情報は復元されません。
> dd if=/etc/mbr of=/dev/wd2d bs=512 count=1
マスターブートレコードの削除
中古のハードディスクとか使う場合などに。マスターブートレコードとパテーションブートレコードの削除。
> dd if=/dev/zero of=/dev/wd2d bs=512 count=63
または
> dd if=/dev/zero of=/dev/wd2d bs=512 count=1
> dd if=/dev/zero of=/dev/wd2d bs=512 count=1 seek=63
マスターブートレコードの初期化
ブートレコードをMBRへ書き込みます。
>fdisk -i wd2
Update the bootcode from /usr/mdec/mbr? [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
パテーション設定
> fdisk -u wd2
Disk: /dev/rwd2d
NetBSD disklabel disk geometry:
cylinders: 17753, heads: 15, sectors/track: 63 (945 sectors/cylinder)
total sectors: 16777216
BIOS disk geometry:
cylinders: 962, heads: 255, sectors/track: 63 (16065 sectors/cylinder)
total sectors: 16777216
Partitions aligned to 16065 sector boundaries, offset 63
Do you want to change our idea of what BIOS thinks? [n]
Partition table:
0: <UNUSED>
1: <UNUSED>
2: <UNUSED>
3: <UNUSED>
Bootselector disabled.
No active partition.
Which partition do you want to change?: [none] 0
The data for partition 0 is:
<UNUSED>
sysid: [0..255 default: 169]
start: [0..1044cyl default: 63, 0cyl, 0MB]
size: [0..1044cyl default: 16777153, 1044cyl, 8192MB]
bootmenu: []
Partition table:
0: NetBSD (sysid 169)
start 63, size 16777153 (8192 MB, Cyls 0-1044/85/1)
1: <UNUSED>
2: <UNUSED>
3: <UNUSED>
Bootselector disabled.
No active partition.
Which partition do you want to change?: [none]
We haven't written the MBR back to disk yet. This is your last chance.
Partition table:
0: NetBSD (sysid 169)
start 63, size 16777153 (8192 MB, Cyls 0-1044/85/1)
1: <UNUSED>
2: <UNUSED>
3: <UNUSED>
Bootselector disabled.
No active partition.
Should we write new partition table? [n] y
アクティブパテーションの設定
netbsd# fdisk -a wd2
Disk: /dev/rwd2d
NetBSD disklabel disk geometry:
cylinders: 17753, heads: 15, sectors/track: 63 (945 sectors/cylinder)
total sectors: 16777216
BIOS disk geometry:
cylinders: 962, heads: 255, sectors/track: 63 (16065 sectors/cylinder)
total sectors: 16777216
Partitions aligned to 2048 sector boundaries, offset 63
Partition table:
0: NetBSD (sysid 169)
start 63, size 16777153 (8192 MB, Cyls 0-1044/85/1)
1: <UNUSED>
2: <UNUSED>
3: <UNUSED>
Bootselector disabled.
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
ディスクラベルのバックアップ
wd0のディスクラベルを/etc/disktabへ保管します。
> disklabel -t wd0 >> /etc/disktab
/etc/disktabの中を見ると以下のようになります。wd0のディスクラベルが'VMwae Virtual'という名前で保管されました。
例)
# See disktab(5) for format of this file, and /usr/share/examples/disktab/
# for other examples.
#
floppy|3.5in High Density Floppy:\
:ty=floppy:se#512:nt#2:rm#300:ns#18:nc#80:\
:pa#2880:oa#0:ba#4096:fa#512:ta=4.2BSD:\
:pb#2880:ob#0:\
:pc#2880:oc#0:
VMware Virtual|Automatically generated label:\
:dt=unknown:se#512:ns#63:nt#15:sc#945:nc#17753:\
:su#16777216:\
:pa#16448670:oa#63:ta=4.2BSD:ba#16384:fa#2048:\
:pb#328483:ob#16448733:tb=swap:\
:pc#16777153:oc#63:\
:pd#16777216:od#0:
ディスクラベルのリストア
wd0のディスクラベルをwd2へ復元します。/etc/disktabに記述されている先ほど保管した'VMware Virtual'を使用します。
> disklabel -w wd2 'VMware Virtual'
ディスクラベルの削除
wd2のディスクラベルを削除します。
> disklabel -D wd2
または
> dd if=/dev/zero of=/dev/wd2d bs=512 count=1 seek=64
ブートローダーの設定
シリアルコンソールを使用し、ルートパテーションはFFSv2フォーマットの場合
installboot -v -o timeout=5,console=com0,speed=115200 /dev/wd2a /usr/mdec/bootxx_ffsv2
ディスクのフォーマット
wd2のディスクをFFSv2でフォーマットします。
> newfs -O2 wd2a
ファイルシステムのバックアップ
/mnt/zipは保管先のメディア
> dump -0uf- / | gzip -c > /mnt/zip/root.dump.gzip
ファイルシステムのリストア
/mnt/resは復元先のメディア
> cd /mnt/res
> gzip -dc /mnt/zip/root.dump.gzip | restore -rf-
restoreコマンドは、tmpを使用しますので、tmpを書き込めるメディア上に設定しないと正常に動作ません。
そんな場合には、予め以下にようにしてからリストアを行います。ここでは、/usbは書き込み可能メディアとします。
> mkdir /usb/tmp
> export TMPDIR=/usb/tmp
ファイルシステムのバックアップとリストアはシングルモードで行いましょう。
以上の作業で必要な事を行えば、システム全体を保管して他のハードへ復元できます。もう一台、同じシステムができあがると言うことです。