diff options
author | Richard Yao <ryao@gentoo.org> | 2015-09-20 09:41:35 -0400 |
---|---|---|
committer | Richard Yao <ryao@gentoo.org> | 2015-09-20 10:09:37 -0400 |
commit | 69d703093a5a6560988d077e57ddf69303d08906 (patch) | |
tree | 50af057d141352ce075503d650fe839c2b008b67 | |
parent | Read zpool.cache file from pool (diff) | |
download | genkernel-69d703093a5a6560988d077e57ddf69303d08906.tar.gz genkernel-69d703093a5a6560988d077e57ddf69303d08906.tar.bz2 genkernel-69d703093a5a6560988d077e57ddf69303d08906.zip |
Improve upon patch to read zpool.cache from the root pool at boot
Signed-off-by: Richard Yao <ryao@gentoo.org>
-rw-r--r-- | defaults/initrd.scripts | 30 | ||||
-rwxr-xr-x | gen_initramfs.sh | 12 |
2 files changed, 22 insertions, 20 deletions
diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts index 55b7f57..9c0c290 100644 --- a/defaults/initrd.scripts +++ b/defaults/initrd.scripts @@ -1034,21 +1034,33 @@ startVolumes() { elif [ -z "${ZFS_POOL}" ] then bad_msg "Please boot with root=ZFS=\$DATASET" - else + elif /sbin/zpool import -f -N -o readonly=on "${ZFS_POOL}" 2>&1 >/dev/null + then mkdir -p /tmp/zfs - /sbin/zpool import -f -N -o readonly=on "${ZFS_POOL}" mount -o ro,zfsutil -t zfs "${REAL_ROOT#*=}" /tmp/zfs - if [ -e /tmp/zfs/etc/zfs/zpool.cache ] + + # Copy important files to /etc/zfs + for i in zpool.cache zdev.conf + do + if [ -f /tmp/zfs/etc/zfs/${i} ] + then + good_msg "Reading ${i} from ${REAL_ROOT#*=}." + cp "/tmp/zfs/etc/zfs/${i}" "/etc/zfs/${i}" + fi + done + + umount /tmp/zfs + /sbin/zpool export -F "${ZFS_POOL}" + + if [ -f /etc/zfs/zpool.cache ] then - cp /tmp/zfs/etc/zfs/zpool.cache /tmp/zpool.cache - umount /tmp/zfs - /sbin/zpool export "${ZFS_POOL}" - /sbin/zpool import -c /tmp/zpool.cache -aN + /sbin/zpool import -c /etc/zfs/zpool.cache -aN else - umount /tmp/zfs - /sbin/zpool export "${ZFS_POOL}" bad_msg "No /etc/zfs/zpool.cache in ${REAL_ROOT#*=}" + fi + else + bad_msg "Failed to import ${ZFS_POOL}." fi fi } diff --git a/gen_initramfs.sh b/gen_initramfs.sh index 1b4afe6..bf1b495 100755 --- a/gen_initramfs.sh +++ b/gen_initramfs.sh @@ -442,19 +442,9 @@ append_zfs(){ rm -r "${TEMP}/initramfs-zfs-temp" fi + # Populated during boot mkdir -p "${TEMP}/initramfs-zfs-temp/etc/zfs" - # Copy files to /etc/zfs - for i in zdev.conf - do - if [ -f /etc/zfs/${i} ] - then - print_info 1 " >> Including ${i}" - cp -a "/etc/zfs/${i}" "${TEMP}/initramfs-zfs-temp/etc/zfs" 2> /dev/null \ - || gen_die "Could not copy file ${i} for ZFS" - fi - done - # Copy binaries copy_binaries "${TEMP}/initramfs-zfs-temp" /sbin/{mount.zfs,zdb,zfs,zpool} |