[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Are BSD partitions not supported?
From: |
Vladimir 'φ-coder/phcoder' Serbinenko |
Subject: |
Re: Are BSD partitions not supported? |
Date: |
Wed, 19 May 2010 00:20:32 +0200 |
User-agent: |
Mozilla-Thunderbird 2.0.0.22 (X11/20091109) |
Vladimir 'φ-coder/phcoder' Serbinenko wrote:
> C. P. Ghost wrote:
>
>> 2010/5/18 Vladimir 'φ-coder/phcoder' Serbinenko <address@hidden>:
>>
>>
>>> C. P. Ghost wrote:
>>>
>>>
>>>> On Sun, May 16, 2010 at 6:24 PM, C. P. Ghost <address@hidden> wrote:
>>>>
>>>>
>>>>
>>>>> is support for BSD partitions (or maybe ufs2) broken in grub2 (1.98)?
>>>>>
>>>>>
>>>>>
>>>> No replies so far? Could a developer *please* have a closer look
>>>> at this?
>>>>
>>>>
>>>>
>>>>
>>> Your mail is quite long and looks like a tech support request. If it is
>>> such it's not right mailing list. Use address@hidden or IRC. If it's
>>> a bug report please supply an image file which triggers bug.
>>> BSD partitions are supported as long as part_msdos and part_bsd (not
>>> necessary in release) are loaded.
>>>
>>>
>> (2nd try, mailer swallowed the attachment)
>>
>> Thank you for replying.
>>
>> Of course, it is a bug report. The steps to create the image are
>> very detailed and should be enough to reproduce the bug on a
>> FreeBSD/amd64 system.
>>
>> Here's a 362k 7z-compressed image of a 25MB disk
>> that contains one slice 's1' with a BSD partition 'a' and
>> a UFS2 filesystem on it:
>>
>> http://www.cordula.ws/tempdir/bsddisk.7z
>>
>> Don't expect it to boot, because grub-install wasn't able
>> to complete the task (grub-probe failed as in the long mail).
>> The file system contains the /boot/grub/* files though: those
>> were properly installed by grub-install. Just not the MBR.
>>
>> If I can provide more help, please do ask. :)
>>
>>
>>
> This bsdlabel has 2 strangenesses. First one is seen in your log:
>
> a: 497936 16 unused 0 0
> In other words for some strange reason it's declared as unused entry slot.
> Second one is that offsets are stored relative to host partition, not
> relative to disk start. While the first can be easily fixed by checking
> length instead of type, second one isproblematic since it would break all
> other images (I've checked with FreeBSD andNetBSD images I had under my
> hand). So we need areliable way to determine which way is used. I found few
> differing bytes between your image and my FreeBSD image (specifically bytes
> 0x(80)30-0x(80)3f) but nothing that would allow a reliable detection. If you
> can find out the reason and a way of detecting this diskrepancy it will help
>
>
My first thought was to use 'c' partition to find this base but I
dismissed it straight ahead because it's only a convention that 'c'
covers the whole disk. But then I played with bsdlabel and found out
that if I move 'c' partition FreeBSD itself is confused too. Since
nobody would consider it a bug if GRUB doesn't recognise properly a
partition not workable in FreeBSD itself I think we should go for
consistent behaviour for the lack of anything better. Try the patch:
=== modified file 'include/grub/bsdlabel.h'
--- include/grub/bsdlabel.h 2010-02-06 17:43:37 +0000
+++ include/grub/bsdlabel.h 2010-05-18 22:05:09 +0000
@@ -63,6 +63,8 @@
#define GRUB_PC_PARTITION_OPENBSD_TYPE_NTFS 18
#define GRUB_PC_PARTITION_OPENBSD_TYPE_RAID 19
+#define GRUB_PC_PARTITION_BSD_LABEL_WHOLE_DISK_PARTITION 2
+
/* The BSD partition entry. */
struct grub_partition_bsd_entry
{
=== modified file 'partmap/bsdlabel.c'
--- partmap/bsdlabel.c 2010-03-26 14:44:13 +0000
+++ partmap/bsdlabel.c 2010-05-18 22:13:37 +0000
@@ -37,9 +37,6 @@
grub_disk_addr_t delta = 0;
unsigned pos;
- /* BSDLabel offsets are absolute even when it's embed inside
partition. */
- delta = grub_partition_get_start (disk->partition);
-
/* Read the BSD label. */
if (grub_disk_read (disk, GRUB_PC_PARTITION_BSD_LABEL_SECTOR,
0, sizeof (label), &label))
@@ -49,15 +46,36 @@
if (label.magic != grub_cpu_to_le32 (GRUB_PC_PARTITION_BSD_LABEL_MAGIC))
return grub_error (GRUB_ERR_BAD_PART_TABLE, "no signature");
+ /* A kludge to determine a base of be.offset. */
+ if (GRUB_PC_PARTITION_BSD_LABEL_WHOLE_DISK_PARTITION
+ < grub_cpu_to_le16 (label.num_partitions))
+ {
+ struct grub_partition_bsd_entry whole_disk_be;
+
+ pos = sizeof (label) + GRUB_PC_PARTITION_BSD_LABEL_SECTOR
+ * GRUB_DISK_SECTOR_SIZE + sizeof (struct grub_partition_bsd_entry)
+ * GRUB_PC_PARTITION_BSD_LABEL_WHOLE_DISK_PARTITION;
+
+ if (grub_disk_read (disk, pos / GRUB_DISK_SECTOR_SIZE,
+ pos % GRUB_DISK_SECTOR_SIZE, sizeof (whole_disk_be),
+ &whole_disk_be))
+ return grub_errno;
+
+ delta = grub_le_to_cpu32 (whole_disk_be.offset);
+ }
+
pos = sizeof (label) + GRUB_PC_PARTITION_BSD_LABEL_SECTOR
* GRUB_DISK_SECTOR_SIZE;
for (p.number = 0;
p.number < grub_cpu_to_le16 (label.num_partitions);
- p.number++)
+ p.number++, pos += sizeof (struct grub_partition_bsd_entry))
{
struct grub_partition_bsd_entry be;
+ if (p.number == GRUB_PC_PARTITION_BSD_LABEL_WHOLE_DISK_PARTITION)
+ continue;
+
p.offset = pos / GRUB_DISK_SECTOR_SIZE;
p.index = pos % GRUB_DISK_SECTOR_SIZE;
@@ -68,11 +86,9 @@
p.len = grub_le_to_cpu32 (be.size);
p.partmap = &grub_bsdlabel_partition_map;
- if (be.fs_type != GRUB_PC_PARTITION_BSD_TYPE_UNUSED)
+ if (p.len != 0)
if (hook (disk, &p))
return grub_errno;
-
- pos += sizeof (struct grub_partition_bsd_entry);
}
return GRUB_ERR_NONE;
--
Regards
Vladimir 'φ-coder/phcoder' Serbinenko
signature.asc
Description: OpenPGP digital signature
- Re: Are BSD partitions not supported?, (continued)
- Re: Are BSD partitions not supported?, Grégoire Sutre, 2010/05/23
- Re: Are BSD partitions not supported?, C. P. Ghost, 2010/05/23
- Re: Are BSD partitions not supported?, Grégoire Sutre, 2010/05/23
- Re: Are BSD partitions not supported?, C. P. Ghost, 2010/05/24
- Re: Are BSD partitions not supported?, Vladimir 'φ-coder/phcoder' Serbinenko, 2010/05/31
- Re: Are BSD partitions not supported?, Vladimir 'φ-coder/phcoder' Serbinenko, 2010/05/19
- Re: Are BSD partitions not supported?,
Vladimir 'φ-coder/phcoder' Serbinenko <=