From: Richard Yao Date: Sat, 28 Jan 2012 18:57:11 +0000 (-0500) Subject: Implement ZFS Support X-Git-Tag: v3.4.25~14 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=fc98fa9d89319e7705a393a739b99f994e12420b;p=genkernel.git Implement ZFS Support This provides ZFS support, to go with the sys-fs/zfs package. Signed-off-by: Robin H. Johnson (cleanups) --- diff --git a/ChangeLog b/ChangeLog index 6c2a7d7..d6e4dcf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,16 @@ # Distributed under the GPL v2 # $Id$ + 06 Feb 2012: Richard Yao 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 gen_initramfs.sh: Refactor copy_binaries and multipath slightly for ease of usage and readability. diff --git a/arch/alpha/modules_load b/arch/alpha/modules_load index 2aeb5c1..6d7dfbf 100644 --- a/arch/alpha/modules_load +++ b/arch/alpha/modules_load @@ -24,5 +24,5 @@ MODULES_PCMCIA="pcmcia pcmcia_core yenta_socket pd6729 i82092 i82365 tcic ds ide 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" diff --git a/arch/arm/modules_load b/arch/arm/modules_load index a4c5f51..616caaf 100644 --- a/arch/arm/modules_load +++ b/arch/arm/modules_load @@ -21,5 +21,5 @@ MODULES_PCMCIA="pcmcia pcmcia_core yenta_socket pd6729 i82092 i82365 tcic ds ide 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" diff --git a/arch/ia64/modules_load b/arch/ia64/modules_load index 971484c..aa9ae31 100644 --- a/arch/ia64/modules_load +++ b/arch/ia64/modules_load @@ -24,4 +24,4 @@ MODULES_PCMCIA="pcmcia pcmcia_core yenta_socket pd6729 i82092 i82365 tcic ds ide 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" diff --git a/arch/mips/modules_load b/arch/mips/modules_load index 2aeb5c1..6d7dfbf 100644 --- a/arch/mips/modules_load +++ b/arch/mips/modules_load @@ -24,5 +24,5 @@ MODULES_PCMCIA="pcmcia pcmcia_core yenta_socket pd6729 i82092 i82365 tcic ds ide 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" diff --git a/arch/parisc/modules_load b/arch/parisc/modules_load index 2aeb5c1..6d7dfbf 100644 --- a/arch/parisc/modules_load +++ b/arch/parisc/modules_load @@ -24,5 +24,5 @@ MODULES_PCMCIA="pcmcia pcmcia_core yenta_socket pd6729 i82092 i82365 tcic ds ide 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" diff --git a/arch/parisc64/modules_load b/arch/parisc64/modules_load index 971484c..aa9ae31 100644 --- a/arch/parisc64/modules_load +++ b/arch/parisc64/modules_load @@ -24,4 +24,4 @@ MODULES_PCMCIA="pcmcia pcmcia_core yenta_socket pd6729 i82092 i82365 tcic ds ide 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" diff --git a/arch/ppc/modules_load b/arch/ppc/modules_load index 2aeb5c1..6d7dfbf 100644 --- a/arch/ppc/modules_load +++ b/arch/ppc/modules_load @@ -24,5 +24,5 @@ MODULES_PCMCIA="pcmcia pcmcia_core yenta_socket pd6729 i82092 i82365 tcic ds ide 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" diff --git a/arch/ppc64/modules_load b/arch/ppc64/modules_load index 971484c..aa9ae31 100644 --- a/arch/ppc64/modules_load +++ b/arch/ppc64/modules_load @@ -24,4 +24,4 @@ MODULES_PCMCIA="pcmcia pcmcia_core yenta_socket pd6729 i82092 i82365 tcic ds ide 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" diff --git a/arch/sparc/modules_load b/arch/sparc/modules_load index 2aeb5c1..6d7dfbf 100644 --- a/arch/sparc/modules_load +++ b/arch/sparc/modules_load @@ -24,5 +24,5 @@ MODULES_PCMCIA="pcmcia pcmcia_core yenta_socket pd6729 i82092 i82365 tcic ds ide 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" diff --git a/arch/sparc64/modules_load b/arch/sparc64/modules_load index 971484c..aa9ae31 100644 --- a/arch/sparc64/modules_load +++ b/arch/sparc64/modules_load @@ -24,4 +24,4 @@ MODULES_PCMCIA="pcmcia pcmcia_core yenta_socket pd6729 i82092 i82365 tcic ds ide 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" diff --git a/arch/um/modules_load b/arch/um/modules_load index cf3b19f..d00e495 100644 --- a/arch/um/modules_load +++ b/arch/um/modules_load @@ -24,5 +24,5 @@ MODULES_PCMCIA="pcmcia pcmcia_core yenta_socket pd6729 i82092 i82365 tcic ds ide 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" diff --git a/arch/x86/modules_load b/arch/x86/modules_load index a9383e5..c601927 100644 --- a/arch/x86/modules_load +++ b/arch/x86/modules_load @@ -25,5 +25,5 @@ MODULES_PCMCIA="pcmcia pcmcia_core yenta_socket pd6729 i82092 i82365 tcic ds ide 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" diff --git a/arch/x86_64/modules_load b/arch/x86_64/modules_load index d12f57d..0da1ec3 100644 --- a/arch/x86_64/modules_load +++ b/arch/x86_64/modules_load @@ -24,4 +24,4 @@ MODULES_PCMCIA="pcmcia pcmcia_core yenta_socket pd6729 i82092 i82365 tcic ds ide 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" diff --git a/defaults/busy-config b/defaults/busy-config index 8d69369..2b9a4c4 100644 --- a/defaults/busy-config +++ b/defaults/busy-config @@ -220,7 +220,7 @@ CONFIG_FALSE=y 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 diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts index 609c52f..54e7b80 100755 --- a/defaults/initrd.scripts +++ b/defaults/initrd.scripts @@ -664,6 +664,11 @@ startVolumes() { 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() { diff --git a/defaults/linuxrc b/defaults/linuxrc index 6bdaea1..0a69a6d 100755 --- a/defaults/linuxrc +++ b/defaults/linuxrc @@ -96,6 +96,19 @@ do 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' @@ -444,6 +457,49 @@ do 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}" = '' ] @@ -477,17 +533,24 @@ do 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 diff --git a/defaults/modules_load b/defaults/modules_load index 269a40c..d65f9f9 100644 --- a/defaults/modules_load +++ b/defaults/modules_load @@ -24,5 +24,5 @@ MODULES_PCMCIA="pcmcia pcmcia_core yenta_socket pd6729 i82092 i82365 tcic ds ide 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" diff --git a/doc/genkernel.8.txt b/doc/genkernel.8.txt index 1e02fb7..67edbd9 100644 --- a/doc/genkernel.8.txt +++ b/doc/genkernel.8.txt @@ -260,6 +260,9 @@ INITIALIZATION *--*[*no-*]*dmraid*:: Includes or excludes DMRAID support. +*--*[*no-*]*zfs*:: + Includes or excludes ZFS support. + *--*[*no-*]*multipath*:: Includes or excludes Multipath support @@ -439,6 +442,10 @@ which the ramdisk scripts would recognize. *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. @@ -586,6 +593,7 @@ AUTHORS - NFS Support by Thomas Seiler - GnuPG 1.x integration by dacook - MDADM integration by Matthias Dahl +- ZFS integration by Richard Yao SEE ALSO diff --git a/gen_cmdline.sh b/gen_cmdline.sh index 4c04f94..de56a25 100755 --- a/gen_cmdline.sh +++ b/gen_cmdline.sh @@ -90,6 +90,8 @@ longusage() { echo " --mdadm-config= 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" @@ -296,6 +298,10 @@ parse_cmdline() { 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 ] diff --git a/gen_determineargs.sh b/gen_determineargs.sh index b12efca..e6ed0a3 100755 --- a/gen_determineargs.sh +++ b/gen_determineargs.sh @@ -120,6 +120,7 @@ determine_real_args() { 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" diff --git a/gen_initramfs.sh b/gen_initramfs.sh index 43fd77f..170361b 100755 --- a/gen_initramfs.sh +++ b/gen_initramfs.sh @@ -328,6 +328,31 @@ append_mdadm(){ 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}" ] @@ -642,6 +667,8 @@ create_initramfs() { print_info 1 "initramfs: Not copying modules..." fi + append_data 'zfs' "${ZFS}" + append_data 'blkid' "${DISKLABEL}" append_data 'unionfs_fuse' "${UNIONFS}" diff --git a/genkernel b/genkernel index 19ef657..5883b5d 100755 --- a/genkernel +++ b/genkernel @@ -351,6 +351,8 @@ then [ "${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="' + [ "${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=" to force booting from a specific dataset' [ "${ISCSI}" = '1' ] && print_warning 1 'add at least "iscsi_initiatorname= iscsi_target= and iscsi_address=" 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'