Skip to content

Instantly share code, notes, and snippets.

@h-yamamo
Last active August 21, 2023 00:10
Show Gist options
  • Save h-yamamo/3556e57415541235f9c7c37a90642079 to your computer and use it in GitHub Desktop.
Save h-yamamo/3556e57415541235f9c7c37a90642079 to your computer and use it in GitHub Desktop.
GRUB Legacy: Support over 2 TiB disk and GPT

GRUB Legacy: Support over 2 TiB disk and GPT for debian grub package

The grub legacy (grub 0.97) supported LBA access, but since it was processing in 32-bit, it could only access up to 2 TiB.

By applying patches of the reference site below, it became accessible with 48-bit LBA and supported disks over 2 TiB. However, it didn't support the 64bit feature of ext4, so it couldn't access the recently created ext4 filesystem.

So I modified those patches based on the latest debian package that supports the 64bit feature of ext4.

How to build

  • Required packages: packaging-dev, lzip / Preparation: sudo apt-get build-dep grub

Debian 13 (trixie/sid)

(# in some directory)
git clone --depth 1 https://gist.github.com/h-yamamo/3556e57415541235f9c7c37a90642079
apt-get -d source grub
tar xf grub_0.97.orig.tar.gz
cd grub-0.97
tar xf ../grub_0.97-81.debian.tar.xz
tar xvf ../3556e57415541235f9c7c37a90642079/debian.tlz
(# you may edit debian/changelog and/or something others)
debuild -uc -us

Package installation

By executing the following command while connected to the Internet, depends packages are also installed. (Specify the deb file name with an absolute path or a relative path.)

For example, run with root privileges like this:

apt-get --no-install-recommends install ./grub-legacy_0.97-81+0~ext1_amd64.deb

If grub2 packages are installed, they will be removed.

Usage

Setup

Just installing the grub-legacy package does not set it up. The easiest way to set it up is to run the following command on the running debian OS.

Run with root privilege:

grub-install '(hd0)'

For GPT disk supported by this extension, it works as follows:

  • Embed stage1 image in the MBR (LBA 0) of the first disk.

  • For stage1_5 image, where to embed is determined by the following priorities.

  1. BIOS boot partition (EF02) found within 2 TiB

  Embed stage1_5 in the beginning of its partition.

  1. First partition start after LBA 72

  Embed stage1_5 after LBA 40.

  1. Other then those above

  Don't use stage1_5.

  • At boot time, /boot/grub/stage2 is finally executed.

References

  (old URL: http://www.geocities.jp/bay3897/grub/

  old old URL: http://www.geocities.co.jp/SiliconValley-Bay/3897/grub/)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment