ディスクラベル等の調整
ここまでの作業でVPSのハードディスクには、起動用ディスクイメージを前提としたパーティション情報、すなわち小さなハードディスクを前提とした内容となっています。ここで改めて、実際のデバイスに合わせます。
FDISKパーティションの調整
まず、FDISKパーティションを実際のデバイスに合わせます。これは比較的簡単で、まず既存のNetBSD用のパーティションを一旦削除します。
パーティションの0を選択した後で、パーティションのシステムIDに0を指定するだけです。
# fdisk -au wd0 Disk: /dev/rwd0d NetBSD disklabel disk geometry: cylinders: 41610, heads: 16, sectors/track: 63 (1008 sectors/cylinder) total sectors: 41943040 BIOS disk geometry: cylinders: 1023, heads: 255, sectors/track: 63 (16065 sectors/cylinder) total sectors: 49143040 Partitions aligned to 2048 sector boundaries, offset 32 Do you want to change our idea of what BIOS thinks? [n] Partition table: 0: NetBSD (sysid 169) start 32, size 65504 (32 MB, Cyls 0/0/33-4/20/16), Active 1: <UNUSED> 2: <UNUSED> 3: <UNUSED> Bootselector disabled. First active partition: 0 Which partition do you want to change?: [none] 0 The data for partition 0 is: NetBSD (sysid 169) start 32, size 65504 (32 MB, Cyls 0/0/33-4/20/16), Active sysid: [0..255 default: 169] 0 Partition table: 0: <UNUSED> 1: <UNUSED> 2: <UNUSED> 3: <UNUSED> Bootselector disabled. No active partition. Which partition do you want to change?: [none]
次に、NetBSDのFDISKパーティションを最大のサイズで作成します。
パーティションの0を選択した後は、Returnキーを入力しているだけです。
Which partition do you want to change?: [none] 0 The data for partition 0 is: <UNUSED> sysid: [0..255 default: 169] start: [0..2611cyl default: 63, 0cyl, 0MB] size: [0..2611cyl default: 41942977, 2611cyl, 20480MB] bootmenu: [] Partition table: 0: NetBSD (sysid 169) start 32, size 41942977 (20480 MB, Cyls 0-2610/212/34) 1: <UNUSED> 2: <UNUSED> 3: <UNUSED> Bootselector disabled. No active partition. Which partition do you want to change?: [none]
改めてアクティブパーティションを0に指定して、変更したFDISKパーティションを書き込みます。
Which partition do you want to change?: [none] 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 Update the bootcode from /usr/mdec/mbr? [n] y We haven't written the MBR back to disk yet. This is your last chance. Partition table: 0: NetBSD (sysid 169) start 32, size 41942977 (20480 MB, Cyls 0-2610/212/34), Active 1: <UNUSED> 2: <UNUSED> 3: <UNUSED> Bootselector disabled. First active partition: 0 Should we write new partition table? [n] y #
ディスクラベルの調整
次にNetBSDのディスクラベルを実際のディスクの大きさに合わせて修正します。
disklabel(8)を対話的なモードで起動し、まず内部コマンドの I を使ってディスクラベルの情報を変更します。
# disklabel -ir wd0 Enter '?' for help partition> I # Current values: # /dev/rwd0d: type: vnd disk: vnd label: fictitious flags: bytes/sector: 512 sectors/track: 32 tracks/cylinder: 64 sectors/cylinder: 2048 cylinders: 32 total sectors: 65536 rpm: 7200 interleave: 1 trackskew: 0 cylinderskew: 0 headswitch: 0 # microseconds track-to-track seek: 0 # microseconds drivedata: 0 Disk type [?] [vnd]:
ディスクの情報を実際に合わせて入力します。
Disk type [?] [vnd]: ESDI Disk name [vnd]: QEMU DISK Label name [fictitious]: disk1 Number of partitions [5]: Sector size (bytes) [512]: Number of sectors per track [32]: 16 Number of tracks per cylinder [64]: 63 Number of sectors/cylinder [2048]: 1008 Total number of cylinders [32]: 41610 Total number of sectors [65536]: 41943040 Hardware sectors interleave [1]: Sector 0 skew, per track [0]: Sector 0 skew, per cylinder [0]: Head switch time (usec) [0]: Track seek time (usec) [0]: partition>
そして、起動用ディスクイメージを引き継いでいるパーティション情報を変更します。
- dパーティションをディスク全体を含んだ内容にします。
- cパーティションはFDISKパーティションのNetBSDの部分に合わせます。
aパーティションを残していますが、これはsysinst(8)や手作業で改めてaパーティションにファイルシステムを作成する段階で、パーティションの変更やファイルシステムの再作成を行うことになります。
partition> P 5 partitions: # size offset fstype [fsize bsize cpg/sgs] a: 65504 32 4.2BSD 0 0 0 # (Cyl. 0*- 65*) c: 65504 32 unused 0 0 # (Cyl. 0*- 65*) d: 65536 0 unused 0 0 # (Cyl. 0 - 65*) partition> d Filesystem type [?] [unused]: Start offset ('x' to start after partition 'x') [0.0317460335791110992431640625c, 32s, 0.015625M]: 0 Partition size ('$' for all remaining) [64.98412322998046875c, 65504s, 31.984375M]: $ d: 41943020 0 unused 0 0 # (Cyl. 0- 41610*) partition> c Start offset ('x' to start after partition 'x') [0.0317460335791110992431640625c, 32s, 0.015625M]: 63 Partition size ('$' for all remaining) [64.98412322998046875c, 65504s, 31.984375M]: $ c: 41942977 63 unused 0 0 # (Cyl. 0*- 41610*) partition> P 5 partitions: # size offset fstype [fsize bsize cpg/sgs] a: 65504 32 4.2BSD 0 0 0 # (Cyl. 0*- 65*) c: 41942977 63 unused 0 0 # (Cyl. 0*- 41610*) d: 41943020 0 unused 0 0 # (Cyl. 0- 41610*) partition>
そして、最後に変更したディスクラベルの内容を書き込みます。
partition> W Label disk [n]? y Label written partition> Q #
後はインストール!
後は再度sysinst(8)を起動して通常のNetBSDのインストール作業を続けるか、手作業でNetBSDをインストールすることになります。
手作業で行う場合は、インストールカーネルをうまく保存しておくと良いでしょう。
- 本来のパーティション構成を作成
- aパーティション以外のファイルシステムを先に作成
- aパーティションに残っているファイルシステムを一旦 /mnt にマウント
- 作成したファイルシステムに netbsd と boot.cfg をコピー
- /mnt をアンマウント
- aパーティションをnewfs(8)
- aパーティションを /mnt にマウントして、4.で退避していた netbsd を /mnt/netbsd-install に、boot.cfg はそのまま /mnt/boot.cfg にコピー
こうしておくと、いざというときに netbsd-install を指定してインストールカーネルで起動できます。