aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOleg Vinichenko <oleg@funtoo.org>2018-02-16 16:37:02 +0000
committerOleg Vinichenko <oleg@funtoo.org>2018-02-16 16:37:02 +0000
commit6ff398611ce23511853c35b8e36955d5c96703e9 (patch)
treedf7070be8dfa64ab50fc3bcc724332b61d613b86
parentremove slash typo (diff)
downloadgenkernel-3.4.40.21-funtoo.tar.gz
genkernel-3.4.40.21-funtoo.tar.bz2
genkernel-3.4.40.21-funtoo.zip
FL-4772: some work in zfs pool cache imports. WIP. may break thingsv3.4.40.21-funtoo
-rwxr-xr-xdefaults/initrd.scripts13
-rwxr-xr-xgen_initramfs.sh80
-rwxr-xr-xgenkernel2
3 files changed, 57 insertions, 38 deletions
diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index 806512da..37034a1e 100755
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -712,9 +712,16 @@ startVolumes() {
/sbin/zpool import -N ${ZPOOL_FORCE} "${ZFS_POOL}"
fi
else
- good_msg "Importing ZFS pool ${ZFS_POOL}"
-
- /sbin/zpool import -N ${ZPOOL_FORCE} "${ZFS_POOL}"
+ ZFS_POOL_CACHEFILE="/etc/zfs/zpool-${ZFS_POOL}.cache"
+ if [ -r ${ZFS_POOL_CACHEFILE} ]
+ then
+ good_msg "Importing ZFS pool '${ZFS_POOL}' using cachefile '${ZFS_POOL_CACHEFILE}'"
+ /sbin/zpool import -N ${ZFS_POOL} -c ${ZFS_POOL_CACHEFILE}
+ else
+ bad_msg "Failed to locate ZFS pool '{ZFS_POOL}' cachefile at '${ZFS_POOL_CACHEFILE}'!"
+ good_msg "Importing ZFS pool '${ZFS_POOL}' (this may take awhile)"
+ /sbin/zpool import -N ${ZPOOL_FORCE} "${ZFS_POOL}"
+ fi
if [ "$?" = '0' ]
then
diff --git a/gen_initramfs.sh b/gen_initramfs.sh
index 0fb76b22..d7fb8a65 100755
--- a/gen_initramfs.sh
+++ b/gen_initramfs.sh
@@ -14,7 +14,7 @@ CPIO_ARGS="--quiet -o -H newc"
# CC0 are compatible with the GNU GPL."
# (from https://www.gnu.org/licenses/license-list.html#CC0)
#
-# Written by:
+# Written by:
# - Sebastian Pipping <sebastian@pipping.org> (error checking)
# - Robin H. Johnson <robbat2@gentoo.org> (complete rewrite)
# - Richard Yao <ryao@cs.stonybrook.edu> (original concept)
@@ -299,6 +299,7 @@ append_lvm(){
cd "${TEMP}"
rm -r "${TEMP}/initramfs-lvm-temp/"
}
+
append_mdadm(){
if [ -d "${TEMP}/initramfs-mdadm-temp" ]
then
@@ -340,30 +341,41 @@ append_mdadm(){
}
append_zfs(){
- if [ -d "${TEMP}/initramfs-zfs-temp" ]
- then
- rm -r "${TEMP}/initramfs-zfs-temp"
- fi
+ if [ -d "${TEMP}/initramfs-zfs-temp" ]
+ then
+ rm -r "${TEMP}/initramfs-zfs-temp"
+ fi
- mkdir -p "${TEMP}/initramfs-zfs-temp/etc/zfs"
+ mkdir -p "${TEMP}/initramfs-zfs-temp/etc/zfs"
- # Copy files to /etc/zfs
- for i in zdev.conf zpool.cache
- 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 cachefiles for each pool, if they exist
+ for pool in $(zpool list -H|cut -f1)
+ do
+ # determine cachefile
+ pool_cachefile=$(zpool get -H cachefile ${pool}|cut -f3)
+ if [ ${pool_cachefile} == "-" ]
+ then
+ # no cachefile - warn about long startup delays
+ print_warning 1 "------------------------ WARNING ------------------------"
+ print_warning 1 " No cachefile set on ZFS pool '${pool}'!"
+ print_warning 1 " Startup times will be VERY SLOW as a result."
+ print_warning 1 " To set a cachefile, run a command like this:"
+ print_warning 1 " zpool set cachefile=/etc/zfs/zpool-${pool}.cache ${pool}"
+ print_warning 1 " ... then re-run genkernel."
+ print_warning 1 "---------------------------------------------------------"
+ else
+ # cachefile set, copy to normalized location
+ cp -a "${pool_cachefile}" "${TEMP}/initramfs-zfs-temp/etc/zfs/zpool-${pool}.cache" 2>/dev/null \
+ || gen_dir "Could not copy file ${pool_cachefile} for ZFS"
+ fi
+ done
- # Copy binaries
- # Include libgcc_s.so.1 to workaround zfsonlinux/zfs#4749
+ # Copy binaries
+ # Include libgcc_s.so.1 to workaround zfsonlinux/zfs#4749
local libgccpath
- if type gcc-config 2>&1 1>/dev/null; then
+ if type gcc-config 2>&1 1>/dev/null; then
libgccpath="/usr/lib/gcc/$(s=$(gcc-config -c); echo ${s%-*}/${s##*-})/libgcc_s.so.1"
- fi
+ fi
if [[ ! -f ${libgccpath} ]]; then
libgccpath="/usr/lib/gcc/*/*/libgcc_s.so.1"
fi
@@ -372,12 +384,12 @@ append_zfs(){
cd "${TEMP}/initramfs-zfs-temp/lib64"
ln -s "..${libgccpath}"
- cd "${TEMP}/initramfs-zfs-temp/"
- log_future_cpio_content
- find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
- || gen_die "compressing zfs cpio"
- cd "${TEMP}"
- rm -rf "${TEMP}/initramfs-zfs-temp" > /dev/null
+ cd "${TEMP}/initramfs-zfs-temp/"
+ log_future_cpio_content
+ find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
+ || gen_die "compressing zfs cpio"
+ cd "${TEMP}"
+ rm -rf "${TEMP}/initramfs-zfs-temp" > /dev/null
}
append_btrfs() {
@@ -385,12 +397,12 @@ append_btrfs() {
then
rm -r "${TEMP}/initramfs-btrfs-temp"
fi
-
+
mkdir -p "${TEMP}/initramfs-btrfs-temp"
-
+
# Copy binaries
copy_binaries "${TEMP}/initramfs-btrfs-temp" /sbin/btrfs
-
+
cd "${TEMP}/initramfs-btrfs-temp/"
log_future_cpio_content
find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
@@ -487,7 +499,7 @@ append_dropbear(){
/usr/bin/dropbearkey -t rsa -f /etc/dropbear/dropbear_rsa_host_key -s 4096 > /dev/null
fi
fi
-
+
if [ ! -e /etc/dropbear/dropbear_dss_host_key ]
then
/usr/bin/dropbearkey -t dss -f /etc/dropbear/dropbear_dss_host_key > /dev/null
@@ -513,7 +525,7 @@ append_dropbear(){
mkdir -p ${TEMP}/initramfs-dropbear-temp/lib
cp -L /lib/libnss_files.so.2 ${TEMP}/initramfs-dropbear-temp/lib/
fi
-
+
sed "s/compat/files/g" /etc/nsswitch.conf > ${TEMP}/initramfs-dropbear-temp/etc/nsswitch.conf
echo "root:x:0:0:root:/root:/bin/login-remote.sh" > ${TEMP}/initramfs-dropbear-temp/etc/passwd
echo "/bin/login-remote.sh" > ${TEMP}/initramfs-dropbear-temp/etc/shells
@@ -528,10 +540,10 @@ append_dropbear(){
chmod 0644 ${TEMP}/initramfs-dropbear-temp/etc/group
mkfifo ${TEMP}/initramfs-dropbear-temp/etc/dropbear/fifo_root
mkfifo ${TEMP}/initramfs-dropbear-temp/etc/dropbear/fifo_swap
-
+
copy_binaries "${TEMP}"/initramfs-dropbear-temp/ /usr/sbin/dropbear \
/bin/login /usr/bin/passwd
-
+
log_future_cpio_content
cd "${TEMP}"/initramfs-dropbear-temp \
|| gen_die "cd '${TEMP}/initramfs-dropbear-temp' failed"
@@ -915,7 +927,7 @@ create_initramfs() {
gzip) compress_ext='.gz' compress_cmd="${cmd_gzip} -f -9" ;;
lzop) compress_ext='.lzo' compress_cmd="${cmd_lzop} -f -9" ;;
esac
-
+
if [ -n "${compression}" ]; then
print_info 1 " >> Compressing cpio data (${compress_ext})..."
${compress_cmd} "${CPIO}" || gen_die "Compression (${compress_cmd}) failed"
diff --git a/genkernel b/genkernel
index 8937d9d4..61c03774 100755
--- a/genkernel
+++ b/genkernel
@@ -2,7 +2,7 @@
# $Id$
PATH="${PATH}:/sbin:/usr/sbin"
-GK_V='3.4.40.19-funtoo'
+GK_V='3.4.40.21-funtoo'
# Set the default for TMPDIR. May be modified by genkernel.conf or the
# --tempdir command line option.