Don't try installboot(8) if offset of PART_A is not zero.

As man page says, installboot(8) is required only OpenFirmware 1 and 2
machines and even on such machines the root partition has to be at the
beginning of the disk to make installboot(8) work.

On OpenFirmware version 3 machines, the strategy provided by
installboot(8) doesn't work, and they need to have an extra
native partition (HFS or FAT16) which can be recognized by
the newer firmware to put a loadable bootloader.
If PART_A has some offset, we can assume the disk is partitioned
for a machine with OF3, which does't require installboot(8).

Eventually, we should provide an independent partitioning method
for OpenFirmware 3 machines (fdisk MBR partition + FAT16 partition
for ofwboot.xcf as OpenBSD does), but it may require some new API
to get OF version in sysinst.
This commit is contained in:
tsutsui 2009-11-23 13:25:02 +00:00
parent f8d9830a1a
commit 64dbdb6579
1 changed files with 26 additions and 1 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: md.c,v 1.41 2009/09/19 14:57:29 abs Exp $ */
/* $NetBSD: md.c,v 1.42 2009/11/23 13:25:02 tsutsui Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -154,6 +154,31 @@ md_post_newfs(void)
{
const char *bootfile = "/boot";
/*
* XXX
* Only OpenFirmware version 1 and 2 machines need installboot(8)
* and it uses a faked Apple partition map with the primary bootxx.
* installboot(8) assumes that root partition is at the beginning of
* the disk and put a faked Apple partition map at the top of
* the partition, so it won't work if root partition has some
* offset from physical block 0 where the Apple driver descriptor
* map resides on.
*
* On OpenFirmware version 3 machines, the strategy used on OF1/2
* machines doesn't work (they don't recognize boot code info
* in Apple partition map entries) and they need to have
* an extra native partition (HFS or MSDOSFS) which can be
* recognized by the newer firmware to put a loadable bootloader.
* installboot(8) against partition `a' on such machines might
* corrupt existing disklabel or a valid Apple partition map.
*
* Currently there is no way to see OF version on running machine
* yet, so assume partition a has some offset on OF3 machines
* and don't try installboot(8) in that case.
*/
if (bsdlabel[PART_A].pi_offset != 0)
return 0;
printf (msg_string(MSG_dobootblks), diskdev);
cp_to_target("/usr/mdec/ofwboot", bootfile);
sync();