zfsonlinux / pkg-zfs

Native ZFS packaging for Debian and Ubuntu
https://launchpad.net/~zfs-native/+archive/daily
308 stars 55 forks source link

kernel/postinst.d script to handle device names? #113

Closed wrouesnel closed 8 years ago

wrouesnel commented 10 years ago

There are a couple of persistent issues with grub in how it searches for ZFS devices on Ubuntu which seem related to the distro-grub searching in the wrong location (/dev).

Putting a script like the following in /etc/kernel/postinst.d fixes the problem in a seamless way, and makes running with a ZFS root less fragile when doing kernal upgrades.

#!/bin/bash
# Make symlinks in /dev to allow kernel upgrades to succeed.

ZPOOL=$(which zpool)

if [ -z $ZPOOL ]; then
    exit 0
fi

$ZPOOL status | grep -P '\t  ' | tr -s ' ' | tr -d '\t' | cut -d' ' -f2 | while read line
do
    if [ ! -e /dev/$line ]; then
        ln -s /dev/disk/by-id/$line /dev/$line
    fi
done

Something like this should probably be included in the Ubuntu ZFS packages until upstream grub learns how to properly find ZFS boot disks on these systems to make it easier for desktop users.

dajhorn commented 9 years ago

@wrouesnel, I was going through some old tickets and noticed this one. Thanks for the submission.

I don't currently integrate GRUB for recent Ubuntu releases, but this fix can be added if somebody gives it a rundown and puts it into a PR for the zfs-initramfs package.

Note, however, that creating device links in postinst.d/ instead of something like a udev rule could be a DPM violation.

Clete2 commented 8 years ago

@dajhorn I have used the method described above and it works, but I am now very scared to update my system as it is remote (12 hours driving distance) from where I live.

It would make installation easier if GRUB could be fixed to recognize the real zpool output. I haven't tried the latest version of zfs-grub to see if it works due to what I mentioned above.

I found (or maybe I made, I can't recall) a small initramfs hook to replace the above fake zpool executable with the real zpool executable:

#
# Add ZoL filesystem capabilities to an initrd, usually for a native ZFS root.
#

# This hook installs udev rules for ZoL.
PREREQ="zfs"

RC=0

case $1 in
prereqs)
        echo "$PREREQ"
        exit 0
        ;;
esac

cp -p "/sbin/zpool_true" "$DESTDIR/sbin/zpool"
dajhorn commented 8 years ago

@Clete2, this GRUB solution is now fully deprecated. The zfs-grub packages will not be updated in the near term except for security issues.

ZoL was imported to Ubuntu and could become a first-class component in the Ubuntu 16.04 LTS release. You should track the Xenial series and decide on an upgrade strategy when the alpha happens in January.

dajhorn commented 8 years ago

ZoL is a first-class package in distro as of the Ubuntu 16.04 LTS release, so I will close this ticket.