From: "Vladimir 'φ-coder/phcoder' Serbinenko" <phcoder@gmail.com>
To: grub-devel@gnu.org
Subject: Re: [Patch] Enable libzfs detection on Linux
Date: Thu, 18 Aug 2011 18:49:44 +0200 [thread overview]
Message-ID: <4E4D42A8.4000503@gmail.com> (raw)
In-Reply-To: <37B025F9-45D9-4424-8458-6B40D2D5A249@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 3472 bytes --]
On 09.08.2011 19:48, Zachary Bedell wrote:
> Attached is a patch which allows Grub to detect and use libzfs on Linux as provided by the ZfsOnLinux project.
>
> Most of this work was originally done by Darik Horn (dajhorn on GitHub) against the Grub 1.99 releases as patched by Ubuntu. I've forward ported the patches to trunk and separated some of the Ubuntu-specific stuff. These apply against trunk independent of the other ZFS work I've been doing.
>
> Changes include:
>
> configure.ac:
> * Add check for libspl to bring in Solaris Porting Library for Linux support.
> * Include reference to Linux ZFS's config header to get necessary defines for other ZFS headers on Linux.
> * Add checks for libavl, libefi, libunicode, libzpool -- Linux decomposes these libraries which are lumped into libzfs on other platforms.
>
> getroot.c:
> * Add ref to mnttab.h from libspl to allow getextmntent to work on Linux.
> * Change the order of the grub_find_root_device_from_mountinfo vs find_root_device_from_libzfs calls so that libzfs runs first, falling down to mountinfo if zfs isn't detected.
> * Scan /proc/mounts and /etc/mtab in addition to /etc/mnttab to discover mounted filesystems in grub_find_zpool_from_dir.
>
/etc/mtab is just a regular file and in many cases is out-of-sync with real state of affairs. Should be ignored altogether. Use of /etc/mnttab is unfortunate but I know of no other way on other platforms (since I haven't looked into it).
> These patches have been in use by a number of folks using ZfsOnLinux for some time, and they've been robust on those systems. I've tried to ensure the changes won't impact non-Linux platforms, though I'm not sure I trust my knowledge of autoconf enough to be positive there are no side effects.
>
You forget the effect of other code changes (below)
> - FILE *mnttab = fopen ("/etc/mnttab", "r");
> + FILE *mnttab;
> + mnttab = fopen ("/proc/mounts", "r");
/proc on FreeBSD is very different from Linux one. Don't try
/proc/mounts except if you have Linux.
> +
> + if (! mnttab)
> + mnttab = fopen ("/etc/mtab", "r");
> +
> + if (! mnttab)
> + mnttab = fopen ("/etc/mnttab", "r");
> +
> if (! mnttab)
> return;
>
> -if [ "x`${grub_probe} --device ${GRUB_DEVICE} --target=fs 2>/dev/null || true`" = xbtrfs ]; then
> +LINUX_ROOT_FS=`${grub_probe} --device ${GRUB_DEVICE} --target=fs 2>/dev/null || true`
> +LINUX_ROOT_STAT=`stat -f --printf=%T / || true`
> +
> +if [ "x${LINUX_ROOT_FS}" = xbtrfs ] || [ "x${LINUX_ROOT_STAT}" = xbtrfs ]; then
This changes logic for btrfs. I don't think it's necessary or good to
just change it.
> +if [ "x${LINUX_ROOT_FS}" = xzfs ]; then
> + GRUB_CMDLINE_LINUX="boot=zfs \$bootfs ${GRUB_CMDLINE_LINUX}"
> +fi
> +
> fi
> + if [ "x${LINUX_ROOT_FS}" = xzfs ]; then
> + cat << EOF
> + insmod zfsinfo
> + zfs-bootfs (\$root) bootfs
> +EOF
In this place $root refers to whereever kernel is. So if /boot is
separate it will be wrong. Moreover you completely forget the possible
subvolumes. One could have e.g.
FreeBSD in /freebsd/@/...
GNU/Linux in /gnu/linux/@
/boot in /boot/@
In this case $bootfs has to take subvolume into account.
Also nothing guarantees that / is accessible from GRUB proper at all.
The ZFS in question may be on e.g. SAN. You need to figure parameters in
10_linux, not on boot time.
--
Regards
Vladimir 'φ-coder/phcoder' Serbinenko
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 294 bytes --]
next prev parent reply other threads:[~2011-08-18 16:50 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-09 17:48 [Patch] Enable libzfs detection on Linux Zachary Bedell
2011-08-18 16:49 ` Vladimir 'φ-coder/phcoder' Serbinenko [this message]
2011-09-14 18:39 ` Zachary Bedell
2011-11-03 14:51 ` Vladimir 'φ-coder/phcoder' Serbinenko
2011-11-10 20:02 ` Robert Millan
2011-11-10 20:38 ` Vladimir 'φ-coder/phcoder' Serbinenko
2011-11-10 20:39 ` Vladimir 'φ-coder/phcoder' Serbinenko
2011-11-15 22:37 ` Seth Goldberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4E4D42A8.4000503@gmail.com \
--to=phcoder@gmail.com \
--cc=grub-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).