Install GRUB for ZFS

·
1 min read
notes
#zfs #jessie #debian

For every ZoL git pull, add ./autogen.sh

Debian Jessie failed to get ZFS root in grub-probe. It would ended up like this:

Terminal window
$ sudo grub-probe /
grub-probe: error: failed to get canonical path of `/dev/scsi-3600605b008b089301eb25768126fbaa6'.

Luckily, Someone at askubuntu suggested to set an env:

Terminal window
ZPOOL_VDEV_NAME_PATH=1

In order to make GRUB recognize the env, we have to have newer version of GRUB. Since GRUB is a static application that sits on our boot time, why not compile it.

For the sake of completeness, don’t forget to install the necessary packages:

Terminal window
sudo apt-get build-dep grub-efi-amd64

To compile:

Terminal window
git clone git://git.savannah.gnu.org/grub.git
cd grub
./autgen.sh
./configure --prefix=/usr --sbindir=/sbin --sysconfdir=/etc --with-platform=efi
make -j$(nproc)
sudo make install

Oh, don’t forget to install efibootmgr so that GRUB can register EFI.

Terminal window
sudo apt install efibootmgr

The Commands

Now we can run everything well:

Terminal window
$ sudo ZPOOL_VDEV_NAME_PATH=1 grub-probe /
zfs

Install GRUB:

Terminal window
$ sudo ZPOOL_VDEV_NAME_PATH=1 grub-install /dev/sda

Done.