Implement ZFS Support

This provides ZFS support, to go with the sys-fs/zfs package.

Signed-off-by: Robin H. Johnson <robbat2@gentoo.org> (cleanups)
cleanup-cruft
Richard Yao 13 years ago committed by Robin H. Johnson
parent 5f4d31dfd0
commit fc98fa9d89

@ -5,6 +5,16 @@
# 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.

@ -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"

@ -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"

@ -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"

@ -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"

@ -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"

@ -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"

@ -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"

@ -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"

@ -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"

@ -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"

@ -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"

@ -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"

@ -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"

@ -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

@ -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() {

@ -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

@ -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"

@ -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 <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

@ -90,6 +90,8 @@ longusage() {
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"
@ -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 ]

@ -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"

@ -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}"

@ -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=<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'

Loading…
Cancel
Save