|
|
@ -1,4 +1,4 @@ |
|
|
|
$OpenBSD: INSTALL.linux,v 1.4 1998/09/25 01:58:38 espie Exp $ |
|
|
|
$OpenBSD: INSTALL.linux,v 1.5 1999/01/09 17:18:20 espie Exp $ |
|
|
|
|
|
|
|
Warning: this document is currently being reviewed. It's not yet complete, |
|
|
|
and probably contains loads of errors. As an example, I can't figure out |
|
|
@ -398,179 +398,11 @@ rerun lilo, and voila, OpenBSD was able to boot ! |
|
|
|
|
|
|
|
Linux and OpenBSD partitions |
|
|
|
---------------------------- |
|
|
|
As of 2.0.35/2.1.122, Linux does not support OpenBSD partitions. The way |
|
|
|
the Linux kernel works is reasonably straightforward (code in |
|
|
|
drivers/block/genhd.c): when detecting a BSD partition (type A5), |
|
|
|
it checks and parses the first block for a disklabel, and use that |
|
|
|
information to instantiate some new partitions, |
|
|
|
that will show up in that drive's partition list, exactly like extended |
|
|
|
partitions do show up. Unfortunately, that check is hard coded for a type A5 |
|
|
|
(NetBSD/FreeBSD) partition, and it recognizes 8 partitions disklabels only |
|
|
|
anyway. |
|
|
|
|
|
|
|
Just hacking the Linux code to recognize A6 is not quite enough. You also |
|
|
|
need to trim down the resulting list of partitions, as your ext2fs |
|
|
|
partitions will now show up twice ! |
|
|
|
I'm experimenting with the following patch, which should make it to linux-kernel |
|
|
|
soon: |
|
|
|
-------------------------------------------------------------- |
|
|
|
diff -ur linux.orig/drivers/block/genhd.c linux/drivers/block/genhd.c |
|
|
|
--- linux.orig/drivers/block/genhd.c Mon Aug 4 20:45:35 1997 |
|
|
|
+++ linux/drivers/block/genhd.c Thu Sep 24 18:55:31 1998 |
|
|
|
@@ -205,11 +206,46 @@ |
|
|
|
} |
|
|
|
|
|
|
|
#ifdef CONFIG_BSD_DISKLABEL |
|
|
|
+static void check_and_add_bsd_partition(struct gendisk *hd, struct bsd_partition *bsd_p) |
|
|
|
+{ |
|
|
|
+ struct hd_struct *lin_p; |
|
|
|
+ /* check relative position of partitions. */ |
|
|
|
+ for (lin_p = hd->part + 1; lin_p - hd->part < current_minor; lin_p++) { |
|
|
|
+ /* no relationship -> try again */ |
|
|
|
+ if (lin_p->start_sect + lin_p->nr_sects <= bsd_p->p_offset |
|
|
|
+ || lin_p->start_sect >= bsd_p->p_offset + bsd_p->p_size) |
|
|
|
+ continue; |
|
|
|
+ /* equal -> no need to add */ |
|
|
|
+ if (lin_p->start_sect == bsd_p->p_offset && |
|
|
|
+ lin_p->nr_sects == bsd_p->p_size) |
|
|
|
+ return; |
|
|
|
+ /* bsd living within dos partition */ |
|
|
|
+ if (lin_p->start_sect <= bsd_p->p_offset && lin_p->start_sect |
|
|
|
+ + lin_p->nr_sects >= bsd_p->p_offset + bsd_p->p_size) { |
|
|
|
+#ifdef DEBUG_BSD_DISKLABEL |
|
|
|
+ printk("w: %d %ld+%ld,%d+%d", |
|
|
|
+ lin_p - hd->part, lin_p->start_sect, lin_p->nr_sects, |
|
|
|
+ bsd_p->p_offset, bsd_p->p_size); |
|
|
|
+#endif |
|
|
|
+ break; |
|
|
|
+ } |
|
|
|
+ /* ouch: bsd and linux overlap. Don't even try for that partition */ |
|
|
|
+#ifdef DEBUG_BSD_DISKLABEL |
|
|
|
+ printk("???: %d %ld+%ld,%d+%d", |
|
|
|
+ lin_p - hd->part, lin_p->start_sect, lin_p->nr_sects, |
|
|
|
+ bsd_p->p_offset, bsd_p->p_size); |
|
|
|
+#endif |
|
|
|
+ printk("???"); |
|
|
|
+ return; |
|
|
|
+ } /* if the bsd partition is not described by DOS, we end up there */ |
|
|
|
+ add_partition(hd, current_minor, bsd_p->p_offset, bsd_p->p_size); |
|
|
|
+ current_minor++; |
|
|
|
+} |
|
|
|
/* |
|
|
|
* Create devices for BSD partitions listed in a disklabel, under a |
|
|
|
* dos-like partition. See extended_partition() for more information. |
|
|
|
*/ |
|
|
|
-static void bsd_disklabel_partition(struct gendisk *hd, kdev_t dev) |
|
|
|
+static void bsd_disklabel_partition(struct gendisk *hd, kdev_t dev, int max_partitions) |
|
|
|
{ |
|
|
|
struct buffer_head *bh; |
|
|
|
struct bsd_disklabel *l; |
|
|
|
@@ -225,19 +261,15 @@ |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
- p = &l->d_partitions[0]; |
|
|
|
- while (p - &l->d_partitions[0] <= BSD_MAXPARTITIONS) { |
|
|
|
+ if (l->d_npartitions < max_partitions) |
|
|
|
+ max_partitions = l->d_npartitions; |
|
|
|
+ for (p = l->d_partitions; p - l->d_partitions < max_partitions; p++) { |
|
|
|
if ((current_minor & mask) >= (4 + hd->max_p)) |
|
|
|
break; |
|
|
|
- |
|
|
|
- if (p->p_fstype != BSD_FS_UNUSED) { |
|
|
|
- add_partition(hd, current_minor, p->p_offset, p->p_size); |
|
|
|
- current_minor++; |
|
|
|
- } |
|
|
|
- p++; |
|
|
|
+ if (p->p_fstype != BSD_FS_UNUSED) |
|
|
|
+ check_and_add_bsd_partition(hd, p); |
|
|
|
} |
|
|
|
brelse(bh); |
|
|
|
- |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
@@ -248,6 +280,11 @@ |
|
|
|
struct partition *p; |
|
|
|
unsigned char *data; |
|
|
|
int mask = (1 << hd->minor_shift) - 1; |
|
|
|
+#ifdef CONFIG_BSD_DISKLABEL |
|
|
|
+ /* no bsd disklabel as a default */ |
|
|
|
+ kdev_t bsd_kdev = 0; |
|
|
|
+ int bsd_maxpart; |
|
|
|
+#endif |
|
|
|
#ifdef CONFIG_BLK_DEV_IDE |
|
|
|
int tested_for_xlate = 0; |
|
|
|
|
|
|
|
@@ -365,13 +402,29 @@ |
|
|
|
hd->part[minor].nr_sects = 2; |
|
|
|
} |
|
|
|
#ifdef CONFIG_BSD_DISKLABEL |
|
|
|
+ /* tag first disklabel for late recognition */ |
|
|
|
if (SYS_IND(p) == BSD_PARTITION) { |
|
|
|
- printk(" <"); |
|
|
|
- bsd_disklabel_partition(hd, MKDEV(hd->major, minor)); |
|
|
|
- printk(" >"); |
|
|
|
+ printk("!"); |
|
|
|
+ if (!bsd_kdev) { |
|
|
|
+ bsd_kdev = MKDEV(hd->major, minor); |
|
|
|
+ bsd_maxpart = BSD_MAXPARTITIONS; |
|
|
|
+ } |
|
|
|
+ } else if (SYS_IND(p) == OPENBSD_PARTITION) { |
|
|
|
+ printk("!"); |
|
|
|
+ if (!bsd_kdev) { |
|
|
|
+ bsd_kdev = MKDEV(hd->major, minor); |
|
|
|
+ bsd_maxpart = OPENBSD_MAXPARTITIONS; |
|
|
|
+ } |
|
|
|
} |
|
|
|
#endif |
|
|
|
} |
|
|
|
+#ifdef CONFIG_BSD_DISKLABEL |
|
|
|
+ if (bsd_kdev) { |
|
|
|
+ printk(" <"); |
|
|
|
+ bsd_disklabel_partition(hd, bsd_kdev, bsd_maxpart); |
|
|
|
+ printk(" >"); |
|
|
|
+ } |
|
|
|
+#endif |
|
|
|
/* |
|
|
|
* Check for old-style Disk Manager partition table |
|
|
|
*/ |
|
|
|
diff -ur linux.orig/include/linux/genhd.h linux/include/linux/genhd.h |
|
|
|
--- linux.orig/include/linux/genhd.h Wed Mar 18 20:25:30 1998 |
|
|
|
+++ linux/include/linux/genhd.h Thu Sep 24 18:55:43 1998 |
|
|
|
@@ -69,12 +70,19 @@ |
|
|
|
#ifdef CONFIG_BSD_DISKLABEL |
|
|
|
/* |
|
|
|
* BSD disklabel support by Yossi Gottlieb <yogo@math.tau.ac.il> |
|
|
|
+ * |
|
|
|
+ * updated by Marc Espie <Marc.Espie@openbsd.org> |
|
|
|
*/ |
|
|
|
|
|
|
|
+/* check against BSD src/sys/sys/disklabel.h for consistency */ |
|
|
|
+ |
|
|
|
#define BSD_PARTITION 0xa5 /* Partition ID */ |
|
|
|
+#define OPENBSD_PARTITION 0xa6 |
|
|
|
|
|
|
|
#define BSD_DISKMAGIC (0x82564557UL) /* The disk magic number */ |
|
|
|
#define BSD_MAXPARTITIONS 8 |
|
|
|
+#define OPENBSD_MAXPARTITIONS 16 |
|
|
|
+ |
|
|
|
#define BSD_FS_UNUSED 0 /* disklabel unused partition entry ID */ |
|
|
|
struct bsd_disklabel { |
|
|
|
__u32 d_magic; /* the magic number */ |
|
|
|
---------------------------------------------------------------------- |
|
|
|
It does: |
|
|
|
- trigger the recognition of OpenBSD disklabels, |
|
|
|
- force bsd partitions to appear at the end of the partition list, |
|
|
|
- check the bsd disklabel for redundancy and consistency with the dos |
|
|
|
partition table, so that the same partition does not show up twice. |
|
|
|
|
|
|
|
You also need a working ufs, such as |
|
|
|
<ftp://sunsite.unc.edu/pub/Linux/ALPHA/ufs/u2fs-0.4.3.tar.gz> |
|
|
|
This package yields a new module, plus a small patch to tie the module |
|
|
|
with the rest of the Linux kernel. I would recommend checking that patch |
|
|
|
manually, as Linux module information tends to vary widely, and it is |
|
|
|
pretty trivial to add by hand anyway. |
|
|
|
As of pre4-2.2.0, the up-coming 2.2 linux kernel does incorporate my |
|
|
|
patch to handle OpenBSD partitions, and remove duplicate partitions that |
|
|
|
are referenced in both the disklabel for OpenBSD, and the MBR. |
|
|
|
|
|
|
|
You also need a working ufs, which is also going to be in linux 2.2. |
|
|
|
|
|
|
|
Running Linux binaries under OpenBSD |
|
|
|
------------------------------------ |
|
|
|