Bug#923253: grub-pc: Calculates wrong partition offset for EBR partitions on FreeBSD

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Bug#923253: grub-pc: Calculates wrong partition offset for EBR partitions on FreeBSD

James Clarke-2
Package: grub-pc
Version: ...
Tags: upstream patch

Hi,
On FreeBSD, grub uses the "start" rather than the "offset" config
property to calculate the starting sector for partitions, which gives
the wrong value for EBR partitions:

> root@lemon:/home/jrtc27/src/grub2/grub2-2.02+dfsg1# geom part list
> (output trimmed and annotated)
> Geom name: ada0
> scheme: MBR
> Providers:
> 1. Name: ada0s1
>    offset: 1048576 # ie 2048 sectors
>    start: 2048
> 2. Name: ada0s2
>    offset: 64000883712 # ie 125001726 sectors
>    start: 125001726
>
> Geom name: ada0s2
> scheme: EBR
> Providers:
> 1. Name: ada0s5
>    offset: 1024 # ie 2 sectors; add 125001726 from ada0s2 to get 125001728
>    start: 0
> 2. Name: ada0s6
>    offset: 183628727296 # ie 358649858 sectors; add 125001726 from ada0s2 to get 483651584
>    start: 358647810 # add 125001726 from ada0s2 to get 483649536
> root@lemon:~# fdisk -l /dev/ada0
> Disk /dev/ada0: 238.5 GiB, 256060514304 bytes, 500118192 sectors
> Units: sectors of 1 * 512 = 512 bytes
> Sector size (logical/physical): 512 bytes / 512 bytes
> I/O size (minimum/optimal): 512 bytes / 512 bytes
> Disklabel type: dos
> Disk identifier: 0x20b8cc40
>
> Device      Boot     Start       End   Sectors   Size Id Type
> /dev/ada0p1 *         2048 124999679 124997632  59.6G 83 Linux
> /dev/ada0p2      125001726 500117503 375115778 178.9G  5 Extended
> /dev/ada0p5      125001728 483649535 358647808   171G a5 FreeBSD
> /dev/ada0p6      483651584 500117503  16465920   7.9G 82 Linux swap / Solaris
This clearly shows that the "start" field is wrong and "offset" should
be used instead. The attached patch does this and has been tested on the
above system (consider it Signed-off-by: James Clarke
<[hidden email]> if forwarding upstream).

Thanks,
James

freebsd-ebr-partition-offset.patch (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Bug#923253: grub-pc: Calculates wrong partition offset for EBR partitions on FreeBSD

Colin Watson
On Mon, Feb 25, 2019 at 02:29:16PM +0000, James Clarke wrote:
> On FreeBSD, grub uses the "start" rather than the "offset" config
> property to calculate the starting sector for partitions, which gives
> the wrong value for EBR partitions:
[...]
> This clearly shows that the "start" field is wrong and "offset" should
> be used instead. The attached patch does this and has been tested on the
> above system (consider it Signed-off-by: James Clarke
> <[hidden email]> if forwarding upstream).

Thanks.  I forwarded this upstream for you
(https://lists.gnu.org/archive/html/grub-devel/2019-02/msg00123.html and
thread) and have committed it for my next Debian upload.

--
Colin Watson                                       [[hidden email]]