NetBSD Problem Report #40258
From email@example.com Tue Dec 23 06:47:41 2008
Received: from mail.netbsd.org (mail.netbsd.org [126.96.36.199])
by narn.NetBSD.org (Postfix) with ESMTP id 036D963B121
for <gnats-bugs@gnats.NetBSD.org>; Tue, 23 Dec 2008 06:47:40 +0000 (UTC)
Date: Mon, 22 Dec 2008 23:47:32 -0700 (MST)
Subject: sysutils/grub does not work with ffs file systems with blocksize > 8K
>Synopsis: sysutils/grub does not work with ffs file systems with blocksize > 8K
>Arrival-Date: Tue Dec 23 06:50:00 +0000 2008
>Last-Modified: Thu Dec 15 05:52:34 +0000 2011
>Originator: Michael L. Hitch
>Release: NetBSD 5.0_BETA
Montana State University
System: NetBSD Pavilion 5.0_BETA NetBSD 5.0_BETA (GENERIC) #0: Fri Dec 19 23:17:57 MST 2008 mhitch@Pavilion:/home/mhitch/netbsd-5/OBJ/amd64/home/mhitch/netbsd-5/src/sys/arch/amd64/compile/GENERIC amd64
Sysutils/grub has a well-known problem of not working with ffs file systems
with a blocksize > 8K. Since NetBSD typically defaults to 16K, that results
in a file system that grub fails to work with. It's sometimes a pain to
rebuild the filesystem, so it would be nice if grub would work with larger
Install grub on a file system with 16K blocksize and watch it (usually) fail.
Not wanting to rebuild a root file system I had, I looked at how grub handles
ffs file systems. After puzzling over it for a while, I finally figured out
there was a rather minor bug in how fsys_ffs.c handles the indirect blocks.
The following patch fixes that bug. It also changes the layout of the file
system buffer area to put the superblock at the end of that buffer to
reduce the likelyhood of it getting overwritten when the directory is
read into the file system buffer. Most root directories are likely to be
less than 24K in size and shouldn't cause any problems. I've been able to
boot from file systems with blocksizes of 64K, as well as with larger partitions
beyond the limit noted in the ffs restrictions I've seen documented.
diff -u work.xxx/grub-0.97/stage2/fsys_ffs.c work/grub-0.97/stage2/fsys_ffs.c
--- work.xxx/grub-0.97/stage2/fsys_ffs.c 2008-07-22 11:06:41.000000000 -0600
+++ work/grub-0.97/stage2/fsys_ffs.c 2008-07-22 11:07:37.000000000 -0600
@@ -71,9 +71,9 @@
static int mapblock_bsize;
/* pointer to superblock */
-#define SUPERBLOCK ((struct fs *) ( FSYS_BUF + 8192 ))
+#define SUPERBLOCK ((struct fs *) ( FSYS_BUF + 24576 ))
#define INODE ((struct icommon *) ( FSYS_BUF + 16384 ))
-#define MAPBUF ( FSYS_BUF + 24576 )
+#define MAPBUF ( FSYS_BUF + 8192 )
#define MAPBUF_LEN 8192
@@ -106,15 +106,16 @@
/* If the blockmap loaded does not include FILE_BLOCK,
load a new blockmap. */
+ offset = ((file_block - NDADDR) % NINDIR (SUPERBLOCK));
if ((bnum = fsbtodb (SUPERBLOCK, INODE->i_ib)) != mapblock
- || (mapblock_offset <= bnum && bnum <= mapblock_offset + mapblock_bsize))
+ || ( offset < mapblock_offset || offset >= mapblock_offset + (MAPBUF_LEN / sizeof(int))))
if (MAPBUF_LEN < SUPERBLOCK->fs_bsize)
offset = ((file_block - NDADDR) % NINDIR (SUPERBLOCK));
bsize = MAPBUF_LEN;
- if (offset + MAPBUF_LEN > SUPERBLOCK->fs_bsize)
+ if (offset * sizeof (int) + MAPBUF_LEN > SUPERBLOCK->fs_bsize)
offset = (SUPERBLOCK->fs_bsize - MAPBUF_LEN) / sizeof (int);
Responsible-Changed-When: Wed, 14 Dec 2011 17:20:28 +0000
I am volunteering to close this if it's appropriate to do so.
State-Changed-When: Wed, 14 Dec 2011 17:20:28 +0000
should be filed upstream, vs pkgsrc.
probably fixed; is 3 years old.
30 day timer to close if not addressed upstream
and confirmed still an issue
From: "Michael L. Hitch" <firstname.lastname@example.org>
Cc: gdt@NetBSD.org, email@example.com
Subject: Re: pkg/40258 (sysutils/grub does not work with ffs file systems
with blocksize > 8K)
Date: Wed, 14 Dec 2011 11:58:46 -0700 (MST)
On Wed, 14 Dec 2011, gdt@NetBSD.org wrote:
> Synopsis: sysutils/grub does not work with ffs file systems with blocksize > 8K
> Responsible-Changed-From-To: pkg-manager->gdt
> Responsible-Changed-By: gdt@NetBSD.org
> Responsible-Changed-When: Wed, 14 Dec 2011 17:20:28 +0000
> I am volunteering to close this if it's appropriate to do so.
> State-Changed-From-To: open->feedback
> State-Changed-By: gdt@NetBSD.org
> State-Changed-When: Wed, 14 Dec 2011 17:20:28 +0000
> should be filed upstream, vs pkgsrc.
> probably fixed; is 3 years old.
> 30 day timer to close if not addressed upstream
> and confirmed still an issue
As best I can tell, the pkgsrc version will still have the same issue.
The pkgsrc version is 0.97, the "Legacy Grub", which is not being
developed. I don't know if Grub2 has addressed this issue.
This hasn't been an issue for me, since I have local patches if I ever
want to use grub again (since NetBSD can now boot xen with the native
bootloader, I don't have much use for grub anymore).
Michael L. Hitch firstname.lastname@example.org
Information Technology Center
Montana State University Bozeman, MT USA
State-Changed-When: Thu, 15 Dec 2011 05:52:34 +0000
1) This seems like a grub bug, not a pkgsrc bug. Please address it
upstream. After there's a bug open and a patch upstream, it's
reasonable for pkgsrc to add a patch.
2) This PR is from 2008. Is this still an issue?
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.