[gentoo-commits] proj/genkernel:zfs commit in: defaults/

2016-01-20 Thread Richard Yao
commit: 255d1f34ef55ee9c83983fec1057c1dde156ea26
Author: Richard Yao  gentoo  org>
AuthorDate: Wed Jan 20 18:54:33 2016 +
Commit: Richard Yao  gentoo  org>
CommitDate: Wed Jan 20 18:54:33 2016 +
URL:https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=255d1f34

busybox mount takes -o move instead of --move

Our attempt to move /dev into /newroot/dev fails because busybox's mount
does not understand --move. Instead it requires `-o move`. ZFS /dev/zd*
devices to be lost during the boot process.

At present, there is no nothing in userland that knows how to recreate
them from `/sys/devices/virtual/block`.

Signed-off-by: Richard Yao  gentoo.org>

 defaults/linuxrc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/defaults/linuxrc b/defaults/linuxrc
index dc129ce..66efda8 100644
--- a/defaults/linuxrc
+++ b/defaults/linuxrc
@@ -998,7 +998,7 @@ for fs in /dev /sys /proc
 do
if grep -qs "$fs" /proc/mounts
then
-   if ! mount --move $fs "${CHROOT}"$fs
+   if ! mount -o move $fs "${CHROOT}"$fs
then
umount $fs || \
bad_msg "Failed to move and unmount the ramdisk $fs!"



[gentoo-commits] proj/genkernel:zfs commit in: defaults/

2015-09-21 Thread Richard Yao
commit: d6663b5493579e33f311340b80da5a1fb0d7f6ed
Author: Richard Yao  gentoo  org>
AuthorDate: Mon Sep 21 13:13:08 2015 +
Commit: Richard Yao  gentoo  org>
CommitDate: Mon Sep 21 13:13:30 2015 +
URL:https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=d6663b54

Fix missing `then` keyword

Signed-off-by: Richard Yao  gentoo.org>

 defaults/initrd.scripts | 1 +
 1 file changed, 1 insertion(+)

diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index d1bb0bc..d1c3873 100644
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -1047,6 +1047,7 @@ startVolumes() {
mkdir -p /tmp/zfs
/sbin/mount.zfs -o ro,zfsutil "${REAL_ROOT#*=}" 
/tmp/zfs 2>&1 >/dev/null
if [ $? -ne 0 ]
+   then
bad_msg "Failed to mount ${REAL_ROOT#*=}"
return 1
fi



[gentoo-commits] proj/genkernel:zfs commit in: defaults/

2015-09-21 Thread Richard Yao
commit: 6b3e3dfbc265ef47c2c2e008ad31ae79041225b6
Author: Richard Yao  gentoo  org>
AuthorDate: Mon Sep 21 01:44:36 2015 +
Commit: Richard Yao  gentoo  org>
CommitDate: Mon Sep 21 13:13:30 2015 +
URL:https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=6b3e3dfb

Cleanup logic to find rootfs on ZFS

We no longer support root=ZFS. Only root=ZFS=$dataset is supported.
GRUB2 never used that syntax and users never liked it, so that should be
okay.

We also handle the case where the root pool is missing from the
cachefile or the cachefile itself is missing by informing users of how
to repair the system. We inform them rather than do it ourselves because
a step is required after the pool is imported and while we can do it for
them, the heuristics are unlikely to be right 100% of the time and we
really should not be making changes to the rootfs from the initramfs.

Signed-off-by: Richard Yao  gentoo.org>

 defaults/linuxrc | 48 +++-
 1 file changed, 23 insertions(+), 25 deletions(-)

diff --git a/defaults/linuxrc b/defaults/linuxrc
index 877d845..dc129ce 100644
--- a/defaults/linuxrc
+++ b/defaults/linuxrc
@@ -523,11 +523,27 @@ do
fi
;;
ZFS*)
-   if [ "${USE_ZFS}" = '0' ]; then
+   zpool list -H -o name | grep -q "${ZFS_POOL}"
+   if [ $? -ne 0 ]
+   then
+   if [ ! -e /etc/zfs/zpool.cache ]
+   then
+   bad_msg "${ZFS_POOL} not 
imported due to missing zpool.cache file."
+
+   else
+   bad_msg "${ZFS_POOL} absent 
from zpool.cache file."
+   fi
+   bad_msg "Provided that ${ZFS_POOL} 
exists, you can correct this by:"
+   bad_msg
+   bad_msg "1. Dropping to a shell."
+   bad_msg "2. Running \`zpool import -d 
/dev/disk/by-id -N ${ZFS_POOL}\`"
+   bad_msg "3. Pressing Cntl+D to exit."
+   bad_msg "4. Running \`zpool set 
cachefile= ${ZFS_POOL}\` (space after equal sign)"
+   bad_msg "   as root after system 
has booted."
prompt_user "REAL_ROOT" "root block 
device"
+   got_good_root=0
continue
fi
-   
ROOT_DEV="${REAL_ROOT#*=}"
if [ "${ROOT_DEV}" != 'ZFS' ] 
then
@@ -543,29 +559,11 @@ do
continue
fi
else
-   BOOTFS=$(/sbin/zpool list -H -o bootfs)
-   if [ "${BOOTFS}" != '-' ]
-   then
-
-   for i in ${BOOTFS}
-   do
-
-   zfs get type ${i} > 
/dev/null
-   retval=$?
-
-   if [ ${retval} -eq 0 ]; 
then
-   got_good_root=1
-   REAL_ROOT=${i}
-   ROOTFSTYPE=zfs
-   break
-   fi  
-   
-   done;
-
-   else
-   got_good_root=0
-   fi
-
+   bad_msg "root=ZFS is no longer 
supported."
+   bad_msg "Please specify 
root=ZFS=\$DATASET:"
+   prompt_user "REAL_ROOT" "root block 
device"
+   got_good_root=0
+   continue
fi
 
if [ ${got_good_root} -ne 1 ]; then



[gentoo-commits] proj/genkernel:zfs commit in: defaults/

2015-09-21 Thread Richard Yao
commit: 3ff0e784021281b01e7a005e81fef4506d0192cb
Author: Richard Yao  gentoo  org>
AuthorDate: Mon Sep 21 01:22:36 2015 +
Commit: Richard Yao  gentoo  org>
CommitDate: Mon Sep 21 13:13:30 2015 +
URL:https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=3ff0e784

Reimplement dozfs=force support

Signed-off-by: Richard Yao  gentoo.org>

 defaults/initrd.scripts | 8 
 1 file changed, 8 insertions(+)

diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index d1c3873..b7c8cc3 100644
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -1042,6 +1042,14 @@ startVolumes() {
elif [ -f /etc/zfs/zpool.cache ]
then
:
+   # Depreciated support for dozfs=force
+   elif [ -n "${ZPOOL_FORCE}" ]
+   then
+   /sbin/zpool import -f -N "${ZFS_POOL}" 2>&1 >/dev/null
+   if [ $? -ne 0 ]
+   then
+   bad_msg "Failed to force import ${ZFS_POOL}"
+   fi
elif /sbin/zpool import -f -N -o readonly=on "${ZFS_POOL}" 2>&1 
>/dev/null
then
mkdir -p /tmp/zfs



[gentoo-commits] proj/genkernel:zfs commit in: defaults/

2015-09-20 Thread Richard Yao
commit: 7b805055ce3b1f211ae64905d2ee7d8898e880fd
Author: Richard Yao  gentoo  org>
AuthorDate: Sun Sep 20 19:29:35 2015 +
Commit: Richard Yao  gentoo  org>
CommitDate: Sun Sep 20 19:29:35 2015 +
URL:https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=7b805055

Further ZFS boot improvements

Signed-off-by: Richard Yao  gentoo.org>

 defaults/initrd.scripts | 14 +-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index 9c0c290..d1bb0bc 100644
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -1034,10 +1034,22 @@ startVolumes() {
elif [ -z "${ZFS_POOL}" ]
then
bad_msg "Please boot with root=ZFS=\$DATASET"
+   # startVolumes is called twice for LUKS assembly.
+   # Devices are not accessed until mount, so become a no-op.
+   # We fall through from the waitForZFS call rather than stopping
+   # sooner so that initramfs archives where the zpool.cache file
+   # has been included are protected against races.
+   elif [ -f /etc/zfs/zpool.cache ]
+   then
+   :
elif /sbin/zpool import -f -N -o readonly=on "${ZFS_POOL}" 2>&1 
>/dev/null
then
mkdir -p /tmp/zfs
-   mount -o ro,zfsutil -t zfs "${REAL_ROOT#*=}" /tmp/zfs
+   /sbin/mount.zfs -o ro,zfsutil "${REAL_ROOT#*=}" 
/tmp/zfs 2>&1 >/dev/null
+   if [ $? -ne 0 ]
+   bad_msg "Failed to mount ${REAL_ROOT#*=}"
+   return 1
+   fi
 
# Copy important files to /etc/zfs
for i in zpool.cache zdev.conf



[gentoo-commits] proj/genkernel:zfs commit in: /, defaults/

2015-09-20 Thread Richard Yao
commit: 69d703093a5a6560988d077e57ddf69303d08906
Author: Richard Yao  gentoo  org>
AuthorDate: Sun Sep 20 13:41:35 2015 +
Commit: Richard Yao  gentoo  org>
CommitDate: Sun Sep 20 14:09:37 2015 +
URL:https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=69d70309

Improve upon patch to read zpool.cache from the root pool at boot

Signed-off-by: Richard Yao  gentoo.org>

 defaults/initrd.scripts | 30 +-
 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}