> Aha, it's a real disklabel, not fictitious one, and 'a' works as a
> fallback partition, right? With MBR it will not work, will it?

It works with MBR:
---
# fdisk wd0
 :

Partition table:
0: NetBSD (sysid 169)
    start 32, size 2097120 (1024 MB, Cyls 0/0/33-520/8/8), Active
1: <UNUSED>
2: <UNUSED>
3: <UNUSED>
 :
---

- Kernel and Bootloader search NetBSD partition in MBR.
- If NetBSD partition is found, kernel checks NetBSD disklabel
  at LABELSECTOR in the NetBSD partition.
  (in sys/kern/disk_subr_mbr.c, but this is machine dependent)
- The first pbr.S in bootxx is loaded by master MBR or BIOS
- pbr.S loads the first 16 sectors in the NetBSD partition.
- The rest of bootxx (boot1.c) check NetBSD disklabel at LABELSECTOR
  and load secondary /boot in partition a:.


> Also 'e' is 0 - 0 and 'a' is 0 - 1819, so they overlap. Why 'a' is not
> overwritten by bootxx then? Sorry, I'm not familiar with disklabels.

They are (calculated) cylinder numbers and they are not
actually used by bootloaders (if LBA is supported by BIOS).
Check sector numbers instead:

On usual UFS:
>> a:   1833552        63     4.2BSD
>> c:   2097089        63     unused
>> d:   2097152         0     unused

sector 63:    pbr.S (first 512 bytes bootxx_ffsvN)
sector 64:    NetBSD disklabel (installboot(8) skips here)
sector 65-78: rest of bootxx_ffsvN
sector 79-:   UFS superblock
 :

In my Ext2fs case:
>> a:   1833457       128 Linux Ext2
>> c:   2097120        32     unused
>> d:   2097152         0     unused
>> e:        96        32       boot

sector 32:   pbr.S (first 512 bytes bootxx_ext2fs
sector 33:   NetBSD disklabel
sector 34-:  rest of bootxx_ext2fs
 :
sector 128:  blank (first sector of Ext2fs root partition)
sector 129:  blank (space for disklabel if a: has no offset)
sector 130-: Ext2fs superblock
 :

i.e.
- Primary MBR loads sector 32 (pbr.S) per MBR settings
- pbr.S loads sectors 32-47 (bootxx_ext2fs) where MBR_PTYPE_NETBSD in MBR
- bootxx_ext2fs loads /boot in partition a: at 128- per NetBSD disklabel
  at LABELSECTOR in MBR_PTYPE_NETBSD partition
so bootxx_ext2fs magically works with the above MBR and disklabel.

(I could be wrong, but x86/PC gurus will correct me :-)
---
Izumi Tsutsui

Reply via email to