This provides ZFS support, to go with the sys-fs/zfs package.
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org> (cleanups)
# Distributed under the GPL v2
# $Id$
+ 06 Feb 2012: Richard Yao <ryao@cs.stonybrook.edu> arch/alpha/modules_load,
+ arch/arm/modules_load, arch/ia64/modules_load, arch/mips/modules_load,
+ arch/parisc/modules_load, arch/parisc64/modules_load, arch/ppc/modules_load,
+ arch/ppc64/modules_load, arch/sparc/modules_load, arch/sparc64/modules_load,
+ arch/um/modules_load, arch/x86/modules_load, arch/x86_64/modules_load,
+ defaults/busy-config, defaults/initrd.scripts, defaults/linuxrc,
+ defaults/modules_load, doc/genkernel.8.txt, gen_cmdline.sh,
+ gen_determineargs.sh, gen_initramfs.sh, genkernel:
+ This provides ZFS support, to go with the sys-fs/zfs package.
+
06 Feb 2012; Robin H. Johnson <robbat2@gentoo.org> gen_initramfs.sh:
Refactor copy_binaries and multipath slightly for ease of usage and readability.
MODULES_USB="ehci-hcd uhci usb-ohci hid usb-storage uhci-hcd ohci-hcd usbhid sl811-hcd hid-a4tech hid-apple hid-belkin hid-cherry hid-chicony hid-cypress hid-dummy hid-ezkey hid-gyration hid-logitech hid-microsoft hid-monterey hid-petalynx hid-pl hid-samsung hid-sony hid-sunplus"
# Filesystems
-MODULES_FS="ext2 ext3 ext4 btrfs reiserfs jfs nfs xfs fuse"
+MODULES_FS="ext2 ext3 ext4 btrfs reiserfs jfs nfs xfs zfs fuse"
MODULES_USB="ehci-hcd uhci usb-ohci hid usb-storage uhci-hcd ohci-hcd usbhid sl811-hcd hid-a4tech hid-apple hid-belkin hid-cherry hid-chicony hid-cypress hid-dummy hid-ezkey hid-gyration hid-logitech hid-microsoft hid-monterey hid-petalynx hid-pl hid-samsung hid-sony hid-sunplus"
# Filesystems
-MODULES_FS="ext2 ext3 ext4 btrfs reiserfs jfs nfs xfs fuse"
+MODULES_FS="ext2 ext3 ext4 btrfs reiserfs jfs nfs xfs zfs fuse"
MODULES_USB="ehci-hcd uhci usb-ohci hid usb-storage uhci-hcd ohci-hcd usbhid sl811-hcd hid-a4tech hid-apple hid-belkin hid-cherry hid-chicony hid-cypress hid-dummy hid-ezkey hid-gyration hid-logitech hid-microsoft hid-monterey hid-petalynx hid-pl hid-samsung hid-sony hid-sunplus"
# Filesystems
-MODULES_FS="ext2 ext3 ext4 btrfs reiserfs jfs nfs xfs fuse"
+MODULES_FS="ext2 ext3 ext4 btrfs reiserfs jfs nfs xfs zfs fuse"
MODULES_USB="ehci-hcd uhci usb-ohci hid usb-storage uhci-hcd ohci-hcd usbhid sl811-hcd hid-a4tech hid-apple hid-belkin hid-cherry hid-chicony hid-cypress hid-dummy hid-ezkey hid-gyration hid-logitech hid-microsoft hid-monterey hid-petalynx hid-pl hid-samsung hid-sony hid-sunplus"
# Filesystems
-MODULES_FS="ext2 ext3 ext4 btrfs reiserfs jfs nfs xfs fuse"
+MODULES_FS="ext2 ext3 ext4 btrfs reiserfs jfs nfs xfs zfs fuse"
MODULES_USB="ehci-hcd uhci usb-ohci hid usb-storage uhci-hcd ohci-hcd usbhid sl811-hcd hid-a4tech hid-apple hid-belkin hid-cherry hid-chicony hid-cypress hid-dummy hid-ezkey hid-gyration hid-logitech hid-microsoft hid-monterey hid-petalynx hid-pl hid-samsung hid-sony hid-sunplus"
# Filesystems
-MODULES_FS="ext2 ext3 ext4 btrfs reiserfs jfs nfs xfs fuse"
+MODULES_FS="ext2 ext3 ext4 btrfs reiserfs jfs nfs xfs zfs fuse"
MODULES_USB="ehci-hcd uhci usb-ohci hid usb-storage uhci-hcd ohci-hcd usbhid sl811-hcd hid-a4tech hid-apple hid-belkin hid-cherry hid-chicony hid-cypress hid-dummy hid-ezkey hid-gyration hid-logitech hid-microsoft hid-monterey hid-petalynx hid-pl hid-samsung hid-sony hid-sunplus"
# Filesystems
-MODULES_FS="ext2 ext3 ext4 btrfs reiserfs jfs nfs xfs fuse"
+MODULES_FS="ext2 ext3 ext4 btrfs reiserfs jfs nfs xfs zfs fuse"
MODULES_USB="ehci-hcd uhci usb-ohci hid usb-storage uhci-hcd ohci-hcd usbhid sl811-hcd hid-a4tech hid-apple hid-belkin hid-cherry hid-chicony hid-cypress hid-dummy hid-ezkey hid-gyration hid-logitech hid-microsoft hid-monterey hid-petalynx hid-pl hid-samsung hid-sony hid-sunplus"
# Filesystems
-MODULES_FS="ext2 ext3 ext4 btrfs reiserfs jfs nfs xfs fuse"
+MODULES_FS="ext2 ext3 ext4 btrfs reiserfs jfs nfs xfs zfs fuse"
MODULES_USB="ehci-hcd uhci usb-ohci hid usb-storage uhci-hcd ohci-hcd usbhid sl811-hcd hid-a4tech hid-apple hid-belkin hid-cherry hid-chicony hid-cypress hid-dummy hid-ezkey hid-gyration hid-logitech hid-microsoft hid-monterey hid-petalynx hid-pl hid-samsung hid-sony hid-sunplus"
# Filesystems
-MODULES_FS="ext2 ext3 ext4 btrfs reiserfs jfs nfs xfs fuse"
+MODULES_FS="ext2 ext3 ext4 btrfs reiserfs jfs nfs xfs zfs fuse"
MODULES_USB="ehci-hcd uhci usb-ohci hid usb-storage uhci-hcd ohci-hcd usbhid sl811-hcd hid-a4tech hid-apple hid-belkin hid-cherry hid-chicony hid-cypress hid-dummy hid-ezkey hid-gyration hid-logitech hid-microsoft hid-monterey hid-petalynx hid-pl hid-samsung hid-sony hid-sunplus"
# Filesystems
-MODULES_FS="ext2 ext3 ext4 btrfs reiserfs jfs nfs xfs fuse"
+MODULES_FS="ext2 ext3 ext4 btrfs reiserfs jfs nfs xfs zfs fuse"
MODULES_USB="ehci-hcd uhci usb-ohci hid usb-storage uhci-hcd ohci-hcd usbhid sl811-hcd hid-a4tech hid-apple hid-belkin hid-cherry hid-chicony hid-cypress hid-dummy hid-ezkey hid-gyration hid-logitech hid-microsoft hid-monterey hid-petalynx hid-pl hid-samsung hid-sony hid-sunplus"
# Filesystems
-MODULES_FS="ext2 ext3 ext4 btrfs reiserfs jfs nfs xfs fuse"
+MODULES_FS="ext2 ext3 ext4 btrfs reiserfs jfs nfs xfs zfs fuse"
MODULES_USB="ehci-hcd uhci usb-ohci hid usb-storage uhci-hcd ohci-hcd usbhid sl811-hcd hid-a4tech hid-apple hid-belkin hid-cherry hid-chicony hid-cypress hid-dummy hid-ezkey hid-gyration hid-logitech hid-microsoft hid-monterey hid-petalynx hid-pl hid-samsung hid-sony hid-sunplus"
# Filesystems
-MODULES_FS="ext2 ext3 ext4 btrfs reiserfs jfs nfs xfs fuse"
+MODULES_FS="ext2 ext3 ext4 btrfs reiserfs jfs nfs xfs zfs fuse"
MODULES_USB="ehci-hcd uhci usb-ohci hid usb-storage uhci-hcd ohci-hcd usbhid sl811-hcd hid-a4tech hid-apple hid-belkin hid-cherry hid-chicony hid-cypress hid-dummy hid-ezkey hid-gyration hid-logitech hid-microsoft hid-monterey hid-petalynx hid-pl hid-samsung hid-sony hid-sunplus"
# Filesystems
-MODULES_FS="ext2 ext3 ext4 btrfs reiserfs jfs nfs xfs fuse"
+MODULES_FS="ext2 ext3 ext4 btrfs reiserfs jfs nfs xfs zfs fuse"
MODULES_USB="ehci-hcd uhci usb-ohci hid usb-storage uhci-hcd ohci-hcd usbhid sl811-hcd hid-a4tech hid-apple hid-belkin hid-cherry hid-chicony hid-cypress hid-dummy hid-ezkey hid-gyration hid-logitech hid-microsoft hid-monterey hid-petalynx hid-pl hid-samsung hid-sony hid-sunplus"
# Filesystems
-MODULES_FS="ext2 ext3 ext4 btrfs reiserfs jfs nfs xfs fuse"
+MODULES_FS="ext2 ext3 ext4 btrfs reiserfs jfs nfs xfs zfs fuse"
CONFIG_FSYNC=y
CONFIG_HEAD=y
# CONFIG_FEATURE_FANCY_HEAD is not set
-# CONFIG_HOSTID is not set
+CONFIG_HOSTID=y
# CONFIG_INSTALL is not set
# CONFIG_FEATURE_INSTALL_LONG_OPTIONS is not set
CONFIG_LN=y
bad_msg "vgscan or vgchange not found: skipping LVM volume group activation!"
fi
fi
+
+ if [ "${USE_ZFS}" = '1' ]
+ then
+ /sbin/zpool import -N -a ${ZPOOL_FORCE}
+ fi
}
startiscsi() {
DMRAID_OPTS=${x#*=}
USE_DMRAID_NORMAL=1
;;
+ dozfs*)
+ if [ ! -x /sbin/zfs ]; then
+ USE_ZFS=0
+ bad_msg 'zfs binary not found: aborting use of zfs!'
+ else
+ USE_ZFS=1
+ MY_HWOPTS="${MY_HWOPTS} zfs"
+ if [ "${x#*=}" = 'force' ]
+ then
+ ZPOOL_FORCE=-f
+ fi
+ fi
+ ;;
# Debug Options
debug)
DEBUG='yes'
continue
fi
;;
+ ZFS*)
+ ROOT_DEV="${REAL_ROOT#*=}"
+ if [ "${ROOT_DEV}" != 'ZFS' ]
+ then
+ zfs get type ${ROOT_DEV} > /dev/null
+
+ if [ "$?" = '0' ]
+ then
+ got_good_root=1;
+ REAL_ROOT=${ROOT_DEV}
+ ROOTFSTYPE=zfs
+ 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;
+
+ fi
+
+ fi
+
+ if [ ${got_good_root} -ne 1 ]; then
+ prompt_user "REAL_ROOT" "root block device"
+ got_good_root=0
+ fi
+
+ continue
+ ;;
esac
if [ "${REAL_ROOT}" = '' ]
else
good_msg "Mounting root..."
+ if [ "${ROOTFSTYPE}" = 'zfs' ]
+ then
+ MOUNT_STATE=rw
+ else
+ MOUNT_STATE=ro
+ fi
+
# Try to mount the device as ${NEW_ROOT}
if [ "${REAL_ROOT}" = '/dev/nfs' ]; then
findnfsmount
else
# mount ro so fsck doesn't barf later
if [ "${REAL_ROOTFLAGS}" = '' ]; then
- good_msg "Using mount -t ${ROOTFSTYPE} -o ro"
- mount -t ${ROOTFSTYPE} -o ro ${REAL_ROOT} ${NEW_ROOT}
+ good_msg "Using mount -t ${ROOTFSTYPE} -o ${MOUNT_STATE}"
+ mount -t ${ROOTFSTYPE} -o ${MOUNT_STATE} ${REAL_ROOT} ${NEW_ROOT}
else
- good_msg "Using mount -t ${ROOTFSTYPE} -o ro,${REAL_ROOTFLAGS}"
- mount -t ${ROOTFSTYPE} -o ro,${REAL_ROOTFLAGS} ${REAL_ROOT} ${NEW_ROOT}
+ good_msg "Using mount -t ${ROOTFSTYPE} -o ${MOUNT_STATE},${REAL_ROOTFLAGS}"
+ mount -t ${ROOTFSTYPE} -o ${MOUNT_STATE},${REAL_ROOTFLAGS} ${REAL_ROOT} ${NEW_ROOT}
fi
fi
MODULES_USB="ehci-hcd uhci usb-ohci hid usb-storage uhci-hcd ohci-hcd usbhid sl811-hcd"
# Filesystems
-MODULES_FS="ext2 ext3 ext4 btrfs reiserfs jfs nfs xfs fuse"
+MODULES_FS="ext2 ext3 ext4 btrfs reiserfs jfs nfs xfs zfs fuse"
*--*[*no-*]*dmraid*::
Includes or excludes DMRAID support.
+*--*[*no-*]*zfs*::
+ Includes or excludes ZFS support.
+
*--*[*no-*]*multipath*::
Includes or excludes Multipath support
*domdadm*::
Scan for RAID arrays on bootup
+*dozfs*[=force]::
+ Scan for bootable ZFS pools on bootup. Optionally force import if
+ necessary.
+
*doscsi*::
Activate SCSI devices on bootup, necessary when SCSI support is
compiled as modules and you're using SCSI or SATA devices.
- NFS Support by Thomas Seiler <thseiler@gmail.com>
- GnuPG 1.x integration by dacook <schism@subverted.org>
- MDADM integration by Matthias Dahl <ua_bugz_gentoo@mortal-soul.de>
+- ZFS integration by Richard Yao <ryao@cs.stonybrook.edu>
SEE ALSO
echo " --mdadm-config=<file> Use file as mdadm.conf in initramfs"
echo " --dmraid Include DMRAID support"
echo " --no-dmraid Exclude DMRAID support"
+ echo " --zfs Include ZFS support"
+ echo " --no-zfs Exclude ZFS support"
echo " --multipath Include Multipath support"
echo " --no-multipath Exclude Multipath support"
echo " --iscsi Include iSCSI support"
fi
print_info 2 "CMD_DMRAID: ${CMD_DMRAID}"
;;
+ --zfs|--no-zfs)
+ CMD_ZFS=`parse_optbool "$*"`
+ print_info 2 "CMD_ZFS: ${CMD_ZFS}"
+ ;;
--multipath|--no-multipath)
CMD_MULTIPATH=`parse_optbool "$*"`
if [ "$CMD_MULTIPATH" = "1" -a ! -e /usr/include/libdevmapper.h ]
set_config_with_override BOOL GPG CMD_GPG
set_config_with_override BOOL MDADM CMD_MDADM
set_config_with_override STRING MDADM_CONFIG CMD_MDADM_CONFIG
+ set_config_with_override BOOL ZFS CMD_ZFS
set_config_with_override BOOL MULTIPATH CMD_MULTIPATH
set_config_with_override BOOL FIRMWARE CMD_FIRMWARE
set_config_with_override STRING FIRMWARE_DIR CMD_FIRMWARE_DIR "/lib/firmware"
rm -rf "${TEMP}/initramfs-mdadm-temp" > /dev/null
}
+append_zfs(){
+ if [ -d "${TEMP}/initramfs-zfs-temp" ]
+ then
+ rm -r "${TEMP}/initramfs-zfs-temp"
+ fi
+
+ mkdir -p "${TEMP}/initramfs-zfs-temp/etc/zfs/"
+
+ # Copy files to /etc/zfs
+ for i in /etc/zfs/{zdev.conf,zpool.cache}
+ do
+ cp -a "${i}" "${TEMP}/initramfs-zfs-temp/etc/zfs" \
+ || gen_die "Could not copy file ${i} for ZFS"
+ done
+
+ # Copy binaries
+ copy_binaries "${TEMP}/initramfs-zfs-temp" /sbin/{mount.zfs,zfs,zpool}
+
+ cd "${TEMP}/initramfs-zfs-temp/"
+ find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
+ || gen_die "compressing zfs cpio"
+ cd "${TEMP}"
+ rm -rf "${TEMP}/initramfs-zfs-temp" > /dev/null
+}
+
append_splash(){
splash_geninitramfs=`which splash_geninitramfs 2>/dev/null`
if [ -x "${splash_geninitramfs}" ]
print_info 1 "initramfs: Not copying modules..."
fi
+ append_data 'zfs' "${ZFS}"
+
append_data 'blkid' "${DISKLABEL}"
append_data 'unionfs_fuse' "${UNIONFS}"
[ "${DMRAID}" = '1' ] && print_warning 1 'add "dodmraid" for dmraid support'
[ "${MDADM}" = '1' ] && print_warning 1 'add "domdadm" for RAID support'
[ "${DMRAID}" = '1' ] && print_warning 1 ' or "dodmraid=<additional options>"'
+ [ "${ZFS}" = '1' ] && print_warning 1 'add "dozfs" for ZFS support'
+ [ "${ZFS}" = '1' ] && print_warning 1 ' and either "real_root=ZFS" to use bootfs autodetection or "real_root=ZFS=<dataset>" to force booting from a specific dataset'
[ "${ISCSI}" = '1' ] && print_warning 1 'add at least "iscsi_initiatorname=<initiator name> iscsi_target=<target name> and iscsi_address=<target ip>" for iscsi support'
if [ `grep 'CONFIG_EXT[0-9]_FS=' "${KERNEL_DIR}"/.config | wc -l` -ge 2 ]; then
print_warning 1 'With support for several ext* filesystems around it may be needed to'