From cac66e09707752906215511e69ef1141d56bd2c4 Mon Sep 17 00:00:00 2001 From: craig Date: Fri, 21 Nov 2008 22:46:36 +0100 Subject: [PATCH] iSCSI patch for genkernel --- arch/alpha/modules_load | 3 +++ arch/ia64/modules_load | 3 +++ arch/mips/modules_load | 3 +++ arch/parisc/modules_load | 3 +++ arch/parisc64/modules_load | 3 +++ arch/ppc/modules_load | 3 +++ arch/ppc64/modules_load | 3 +++ arch/sparc/modules_load | 3 +++ arch/sparc64/modules_load | 3 +++ arch/um/modules_load | 3 +++ arch/x86/modules_load | 3 +++ arch/x86_64/modules_load | 3 +++ defaults/initrd.defaults | 2 +- defaults/initrd.scripts | 11 ++++++++++ defaults/linuxrc | 14 +++++++++++++ defaults/modules_load | 3 +++ gen_cmdline.sh | 4 ++++ gen_compile.sh | 42 ++++++++++++++++++++++++++++++++++++++ gen_configkernel.sh | 9 ++++++++ gen_determineargs.sh | 3 +++ gen_funcs.sh | 2 +- gen_initramfs.sh | 18 ++++++++++++++++ genkernel | 1 + genkernel.conf | 5 +++++ 24 files changed, 148 insertions(+), 2 deletions(-) diff --git a/arch/alpha/modules_load b/arch/alpha/modules_load index 2e93dce..f54dd7b 100644 --- a/arch/alpha/modules_load +++ b/arch/alpha/modules_load @@ -16,6 +16,9 @@ MODULES_WAITSCAN="scsi_wait_scan" # Hardware (Network) MODULES_NET="e1000 tg3" +# iSCSI support +MODULES_ISCSI="scsi_transport_iscsi libiscsi iscsi_tcp" + # Hardware (Pluggable) MODULES_FIREWIRE="ieee1394 ohci1394 sbp2" MODULES_PCMCIA="pcmcia pcmcia_core yenta_socket pd6729 i82092 i82365 tcic ds ide-cs firmware_class" diff --git a/arch/ia64/modules_load b/arch/ia64/modules_load index 67b9a48..d38cd40 100644 --- a/arch/ia64/modules_load +++ b/arch/ia64/modules_load @@ -16,6 +16,9 @@ MODULES_WAITSCAN="scsi_wait_scan" # Hardware (Network) MODULES_NET="e1000 tg3" +# iSCSI support +MODULES_ISCSI="scsi_transport_iscsi libiscsi iscsi_tcp" + # Hardware (Pluggable) MODULES_FIREWIRE="ieee1394 ohci1394 sbp2" MODULES_PCMCIA="pcmcia pcmcia_core yenta_socket pd6729 i82092 i82365 tcic ds ide-cs firmware_class" diff --git a/arch/mips/modules_load b/arch/mips/modules_load index 2e93dce..f54dd7b 100644 --- a/arch/mips/modules_load +++ b/arch/mips/modules_load @@ -16,6 +16,9 @@ MODULES_WAITSCAN="scsi_wait_scan" # Hardware (Network) MODULES_NET="e1000 tg3" +# iSCSI support +MODULES_ISCSI="scsi_transport_iscsi libiscsi iscsi_tcp" + # Hardware (Pluggable) MODULES_FIREWIRE="ieee1394 ohci1394 sbp2" MODULES_PCMCIA="pcmcia pcmcia_core yenta_socket pd6729 i82092 i82365 tcic ds ide-cs firmware_class" diff --git a/arch/parisc/modules_load b/arch/parisc/modules_load index 2e93dce..f54dd7b 100644 --- a/arch/parisc/modules_load +++ b/arch/parisc/modules_load @@ -16,6 +16,9 @@ MODULES_WAITSCAN="scsi_wait_scan" # Hardware (Network) MODULES_NET="e1000 tg3" +# iSCSI support +MODULES_ISCSI="scsi_transport_iscsi libiscsi iscsi_tcp" + # Hardware (Pluggable) MODULES_FIREWIRE="ieee1394 ohci1394 sbp2" MODULES_PCMCIA="pcmcia pcmcia_core yenta_socket pd6729 i82092 i82365 tcic ds ide-cs firmware_class" diff --git a/arch/parisc64/modules_load b/arch/parisc64/modules_load index 67b9a48..d38cd40 100644 --- a/arch/parisc64/modules_load +++ b/arch/parisc64/modules_load @@ -16,6 +16,9 @@ MODULES_WAITSCAN="scsi_wait_scan" # Hardware (Network) MODULES_NET="e1000 tg3" +# iSCSI support +MODULES_ISCSI="scsi_transport_iscsi libiscsi iscsi_tcp" + # Hardware (Pluggable) MODULES_FIREWIRE="ieee1394 ohci1394 sbp2" MODULES_PCMCIA="pcmcia pcmcia_core yenta_socket pd6729 i82092 i82365 tcic ds ide-cs firmware_class" diff --git a/arch/ppc/modules_load b/arch/ppc/modules_load index 2e93dce..f54dd7b 100644 --- a/arch/ppc/modules_load +++ b/arch/ppc/modules_load @@ -16,6 +16,9 @@ MODULES_WAITSCAN="scsi_wait_scan" # Hardware (Network) MODULES_NET="e1000 tg3" +# iSCSI support +MODULES_ISCSI="scsi_transport_iscsi libiscsi iscsi_tcp" + # Hardware (Pluggable) MODULES_FIREWIRE="ieee1394 ohci1394 sbp2" MODULES_PCMCIA="pcmcia pcmcia_core yenta_socket pd6729 i82092 i82365 tcic ds ide-cs firmware_class" diff --git a/arch/ppc64/modules_load b/arch/ppc64/modules_load index 67b9a48..d38cd40 100644 --- a/arch/ppc64/modules_load +++ b/arch/ppc64/modules_load @@ -16,6 +16,9 @@ MODULES_WAITSCAN="scsi_wait_scan" # Hardware (Network) MODULES_NET="e1000 tg3" +# iSCSI support +MODULES_ISCSI="scsi_transport_iscsi libiscsi iscsi_tcp" + # Hardware (Pluggable) MODULES_FIREWIRE="ieee1394 ohci1394 sbp2" MODULES_PCMCIA="pcmcia pcmcia_core yenta_socket pd6729 i82092 i82365 tcic ds ide-cs firmware_class" diff --git a/arch/sparc/modules_load b/arch/sparc/modules_load index 2e93dce..f54dd7b 100644 --- a/arch/sparc/modules_load +++ b/arch/sparc/modules_load @@ -16,6 +16,9 @@ MODULES_WAITSCAN="scsi_wait_scan" # Hardware (Network) MODULES_NET="e1000 tg3" +# iSCSI support +MODULES_ISCSI="scsi_transport_iscsi libiscsi iscsi_tcp" + # Hardware (Pluggable) MODULES_FIREWIRE="ieee1394 ohci1394 sbp2" MODULES_PCMCIA="pcmcia pcmcia_core yenta_socket pd6729 i82092 i82365 tcic ds ide-cs firmware_class" diff --git a/arch/sparc64/modules_load b/arch/sparc64/modules_load index 67b9a48..d38cd40 100644 --- a/arch/sparc64/modules_load +++ b/arch/sparc64/modules_load @@ -16,6 +16,9 @@ MODULES_WAITSCAN="scsi_wait_scan" # Hardware (Network) MODULES_NET="e1000 tg3" +# iSCSI support +MODULES_ISCSI="scsi_transport_iscsi libiscsi iscsi_tcp" + # Hardware (Pluggable) MODULES_FIREWIRE="ieee1394 ohci1394 sbp2" MODULES_PCMCIA="pcmcia pcmcia_core yenta_socket pd6729 i82092 i82365 tcic ds ide-cs firmware_class" diff --git a/arch/um/modules_load b/arch/um/modules_load index 309421d..38e8f71 100644 --- a/arch/um/modules_load +++ b/arch/um/modules_load @@ -16,6 +16,9 @@ MODULES_WAITSCAN="scsi_wait_scan" # Hardware (Network) MODULES_NET="e1000 tg3" +# iSCSI support +MODULES_ISCSI="scsi_transport_iscsi libiscsi iscsi_tcp" + # Hardware (Pluggable) MODULES_FIREWIRE="ieee1394 ohci1394 sbp2" MODULES_PCMCIA="pcmcia pcmcia_core yenta_socket pd6729 i82092 i82365 tcic ds ide-cs firmware_class" diff --git a/arch/x86/modules_load b/arch/x86/modules_load index e480050..6f420ef 100644 --- a/arch/x86/modules_load +++ b/arch/x86/modules_load @@ -17,6 +17,9 @@ MODULES_WAITSCAN="scsi_wait_scan" # Hardware (Network) MODULES_NET="e1000 tg3" +# iSCSI support +MODULES_ISCSI="scsi_transport_iscsi libiscsi iscsi_tcp" + # Hardware (Pluggable) MODULES_FIREWIRE="ieee1394 ohci1394 sbp2" MODULES_PCMCIA="pcmcia pcmcia_core yenta_socket pd6729 i82092 i82365 tcic ds ide-cs firmware_class" diff --git a/arch/x86_64/modules_load b/arch/x86_64/modules_load index 9009ac3..7f8f69a 100644 --- a/arch/x86_64/modules_load +++ b/arch/x86_64/modules_load @@ -16,6 +16,9 @@ MODULES_WAITSCAN="scsi_wait_scan" # Hardware (Network) MODULES_NET="e1000 tg3" +# iSCSI support +MODULES_ISCSI="scsi_transport_iscsi libiscsi iscsi_tcp" + # Hardware (Pluggable) MODULES_FIREWIRE="ieee1394 ohci1394 sbp2" MODULES_PCMCIA="pcmcia pcmcia_core yenta_socket pd6729 i82092 i82365 tcic ds ide-cs firmware_class" diff --git a/defaults/initrd.defaults b/defaults/initrd.defaults index a417144..db5cb25 100755 --- a/defaults/initrd.defaults +++ b/defaults/initrd.defaults @@ -78,4 +78,4 @@ LOOPS='/livecd.loop /zisofs /livecd.squashfs /image.squashfs /livecd.gcloop' # Only sections that are in by default or those that # are not module groups need to be defined here... HWOPTS='keymap cache modules pata sata scsi usb firewire waitscan slowusb evms lvm dmraid mdadm fs net' -MY_HWOPTS='modules pata sata scsi usb firewire waitscan dmraid mdadm fs net' +MY_HWOPTS='modules pata sata scsi usb firewire waitscan dmraid mdadm fs net iscsi' diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts index b63568d..1ccab59 100755 --- a/defaults/initrd.scripts +++ b/defaults/initrd.scripts @@ -628,6 +628,17 @@ startVolumes() { fi } +startiscsi() { + + if [ -n "${ISCSI_I}" ] && [ -n "${ISCSI_T}" ] && [ -n "${ISCSI_A}" ] + then + good_msg "Activating ISCSI" + iscsistart -i "${ISCSI_I}" -t "${ISCSI_T}" -g 1 -a ${ISCSI_A} + fi + +} + + # Open a LUKS device # It is either the root or a swap, other devices are supported in the scripts provided with sys-fs/cryptsetup-luks # $1 - root/swap diff --git a/defaults/linuxrc b/defaults/linuxrc index 3fac6ad..c3d5239 100755 --- a/defaults/linuxrc +++ b/defaults/linuxrc @@ -149,6 +149,17 @@ do nfsroot\=*) NFSROOT=`parse_opt "${x}"` ;; + # ISCSI + iscsi_i\=*) + ISCSI_I=`parse_opt "${x}"` + ;; + iscsi_t\=*) + ISCSI_T=`parse_opt "${x}"` + ;; + iscsi_a\=*) + ISCSI_A=`parse_opt "${x}"` + ;; + # Crypto crypt_root\=*) CRYPT_ROOT=`parse_opt "${x}"` ;; @@ -263,6 +274,9 @@ setup_md_device # Scan volumes startVolumes +# Start ISCSI +startiscsi + setup_keymap # Initialize LUKS root device except for livecd's diff --git a/defaults/modules_load b/defaults/modules_load index 2e93dce..f54dd7b 100644 --- a/defaults/modules_load +++ b/defaults/modules_load @@ -16,6 +16,9 @@ MODULES_WAITSCAN="scsi_wait_scan" # Hardware (Network) MODULES_NET="e1000 tg3" +# iSCSI support +MODULES_ISCSI="scsi_transport_iscsi libiscsi iscsi_tcp" + # Hardware (Pluggable) MODULES_FIREWIRE="ieee1394 ohci1394 sbp2" MODULES_PCMCIA="pcmcia pcmcia_core yenta_socket pd6729 i82092 i82365 tcic ds ide-cs firmware_class" diff --git a/gen_cmdline.sh b/gen_cmdline.sh index fd1dd56..cdaf44e 100755 --- a/gen_cmdline.sh +++ b/gen_cmdline.sh @@ -84,6 +84,7 @@ longusage() { echo " --mdadm Copy /etc/mdadm.conf to initramfs" echo " --dmraid Include DMRAID support" echo " --multipath Include Multipath support" + echo " --iscsi Include ISCSI support" echo " --slowusb Enables extra pauses for slow USB CD boots" echo " --bootloader=grub Add new kernel to GRUB configuration" echo " --linuxrc= Specifies a user created linuxrc" @@ -289,6 +290,9 @@ parse_cmdline() { --bootloader=*) CMD_BOOTLOADER=`parse_opt "$*"` print_info 2 "CMD_BOOTLOADER: ${CMD_BOOTLOADER}" + --iscsi) + CMD_ISCSI=1 + print_info 2 "CMD_ISCSI: ${CMD_ISCSI}" ;; --loglevel=*) CMD_LOGLEVEL=`parse_opt "$*"` diff --git a/gen_compile.sh b/gen_compile.sh index 3379b61..6256662 100755 --- a/gen_compile.sh +++ b/gen_compile.sh @@ -619,3 +619,45 @@ compile_unionfs_fuse() { rm -rf "${UNIONFS_FUSE_DIR}" > /dev/null fi } + +compile_iscsi() { + if [ ! -f "${ISCSI_BINCACHE}" ] + then + [ ! -f "${ISCSI_SRCTAR}" ] && + gen_die "Could not find ISCSI source tarball: ${ISCSI_SRCTAR}. Please place it there, or place another version, changing /etc/genkernel.conf as necessary!" + cd "${TEMP}" + rm -rf "${ISCSI_DIR}" + tar -zxpf "${ISCSI_SRCTAR}" + [ ! -d "${ISCSI_DIR}" ] && + gen_die "ISCSI directory ${ISCSI_DIR} invalid" + print_info 1 'ISCSI: >> Compiling...' + cd "${TEMP}/${ISCSI_DIR}/utils/fwparam_ibft" + MAKE=${UTILS_MAKE} compile_generic "" "" + cd "${TEMP}/${ISCSI_DIR}/usr" + MAKE=${UTILS_MAKE} compile_generic "" "" + cd "${TEMP}/${ISCSI_DIR}/kernel" + + # Find out target kernel Version, make modules for that version + RELEASE=$(head -n 4 ${CMD_KERNEL_DIR}/Makefile | sed -r -e 's/^VERSION = (.*)/\1./g' -e 's/PATCHLEVEL = (.*)/\1./g' -e 's/SUBLEVEL = (.*)/\1/g' -e 's/EXTRAVERSION = (.*)/\1/g' | tr -d '\n') + KERNELRELEASE=${RELEASE} MAKE=${UTILS_MAKE} compile_generic "" "" + + # copy kernel modules to initramfs + mkdir -p "${TEMP}/initramfs-iscsi-temp/lib/modules/${RELEASE}/kernel/drivers/scsi/" + cp *.ko "${TEMP}/initramfs-iscsi-temp/lib/modules/${RELEASE}/kernel/drivers/scsi/" + + cd "${TEMP}/initramfs-iscsi-temp/" + print_info 1 'iscsistart: >> Copying to cache...' + [ -f "${TEMP}/${ISCSI_DIR}/usr/iscsistart" ] || + gen_die 'iscsistart executable does not exist!' + strip "${TEMP}/${ISCSI_DIR}/usr/iscsistart" || + gen_die 'Could not strip iscsistart binary!' + bzip2 "${TEMP}/${ISCSI_DIR}/usr/iscsistart" || + gen_die 'bzip2 compression of iscsistart failed!' + mv "${TEMP}/${ISCSI_DIR}/usr/iscsistart.bz2" "${ISCSI_BINCACHE}" || + gen_die 'Could not copy the iscsistart binary to the package directory, does the directory exist?' + + cd "${TEMP}" + rm -rf "${ISCSI_DIR}" > /dev/null + fi +} + diff --git a/gen_configkernel.sh b/gen_configkernel.sh index 053bd4a..9296793 100755 --- a/gen_configkernel.sh +++ b/gen_configkernel.sh @@ -100,6 +100,15 @@ config_kernel() { sed -i ${KERNEL_DIR}/.config -e 's/#\? \?CONFIG_BLK_DEV_DM is.*/CONFIG_BLK_DEV_DM=m/g' fi + # Make sure the iscsi modules are off if --iscsi + # CONFIG_SCSI_ISCSI_ATTRS + # CONFIG_ISCSI_TCP + if isTrue ${CMD_ISCSI} + then + sed -i ${KERNEL_DIR}/.config -e 's/^CONFIG_SCSI_ISCSI_ATTRS=\(.*\)/\# CONFIG_SCSI_ISCSI_ATTRS is not set/g' + sed -i ${KERNEL_DIR}/.config -e 's/^CONFIG_ISCSI_TCP=\(.*\)/\# CONFIG_ISCSI_TCP is not set/g' + fi + if isTrue ${SPLASH} then sed -i ${KERNEL_DIR}/.config -e 's/#\? \?CONFIG_FB_SPLASH is.*/CONFIG_FB_SPLASH=y/g' diff --git a/gen_determineargs.sh b/gen_determineargs.sh index f6c45a1..c853a43 100755 --- a/gen_determineargs.sh +++ b/gen_determineargs.sh @@ -102,6 +102,7 @@ determine_real_args() { set_config_with_override 1 LVM CMD_LVM set_config_with_override 1 EVMS CMD_EVMS set_config_with_override 1 DMRAID CMD_DMRAID + set_config_with_override 1 ISCSI CMD_ISCSI set_config_with_override 1 BUSYBOX CMD_BUSYBOX "yes" set_config_with_override 1 UNIONFS CMD_UNIONFS set_config_with_override 1 NETBOOT CMD_NETBOOT @@ -127,6 +128,7 @@ determine_real_args() { DEVICE_MAPPER_BINCACHE=`cache_replace "${DEVICE_MAPPER_BINCACHE}"` LVM_BINCACHE=`cache_replace "${LVM_BINCACHE}"` DMRAID_BINCACHE=`cache_replace "${DMRAID_BINCACHE}"` + ISCSI_BINCACHE=`cache_replace "${ISCSI_BINCACHE}"` BLKID_BINCACHE=`cache_replace "${BLKID_BINCACHE}"` FUSE_BINCACHE=`cache_replace "${FUSE_BINCACHE}"` UNIONFS_FUSE_BINCACHE=`cache_replace "${UNIONFS_FUSE_BINCACHE}"` @@ -137,6 +139,7 @@ determine_real_args() { DEVICE_MAPPER_BINCACHE=`arch_replace "${DEVICE_MAPPER_BINCACHE}"` LVM_BINCACHE=`arch_replace "${LVM_BINCACHE}"` DMRAID_BINCACHE=`arch_replace "${DMRAID_BINCACHE}"` + ISCSI_BINCACHE=`arch_replace "${ISCSI_BINCACHE}"` BLKID_BINCACHE=`arch_replace "${BLKID_BINCACHE}"` FUSE_BINCACHE=`arch_replace "${FUSE_BINCACHE}"` UNIONFS_FUSE_BINCACHE=`arch_replace "${UNIONFS_FUSE_BINCACHE}"` diff --git a/gen_funcs.sh b/gen_funcs.sh index 0041665..3a5f492 100755 --- a/gen_funcs.sh +++ b/gen_funcs.sh @@ -516,7 +516,7 @@ set_config_with_override() { } check_distfiles() { - for i in $BUSYBOX_SRCTAR $DEVICE_MAPPER_SRCTAR $MULTIPATH_SRCTAR $LVM_SRCTAR $DMRAID_SRCTAR $E2FSPROGS_SRCTAR + for i in $BUSYBOX_SRCTAR $DEVICE_MAPPER_SRCTAR $MULTIPATH_SRCTAR $LVM_SRCTAR $DMRAID_SRCTAR $E2FSPROGS_SRCTAR $ISCSI_SRCTAR do if [ ! -f "${i}" ] then diff --git a/gen_initramfs.sh b/gen_initramfs.sh index 111b6cc..979994a 100755 --- a/gen_initramfs.sh +++ b/gen_initramfs.sh @@ -192,6 +192,23 @@ append_dmraid(){ rm -r "${TEMP}/initramfs-dmraid-temp/" } +append_iscsi(){ + if [ -d "${TEMP}/initramfs-iscsi-temp" ] + then + rm -r "${TEMP}/initramfs-iscsi-temp/" + fi + print_info 1 'ISCSI: Adding support (compiling binaries)...' + compile_iscsi + cd ${TEMP} + mkdir -p "${TEMP}/initramfs-iscsi-temp/bin/" + /bin/bzip2 -dc "${ISCSI_BINCACHE}" > "${TEMP}/initramfs-iscsi-temp/bin/iscsistart" || + gen_die "Could not extract iscsi binary cache!" + chmod a+x "${TEMP}/initramfs-iscsi-temp/bin/iscsistart" + cd "${TEMP}/initramfs-iscsi-temp/" + find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}" + rm -rf "${TEMP}/initramfs-iscsi-temp" > /dev/null +} + append_lvm(){ if [ -d "${TEMP}/initramfs-lvm-temp" ] then @@ -578,6 +595,7 @@ create_initramfs() { append_data 'busybox' "${BUSYBOX}" append_data 'lvm' "${LVM}" append_data 'dmraid' "${DMRAID}" + append_data 'iscsi' "${ISCSI}" append_data 'evms' "${EVMS}" append_data 'mdadm' "${MDADM}" append_data 'luks' "${LUKS}" diff --git a/genkernel b/genkernel index a28f6e1..0da2a56 100755 --- a/genkernel +++ b/genkernel @@ -364,6 +364,7 @@ then [ "${EVMS}" -eq '1' ] && print_info 1 'add "doevms" for evms support' [ "${DMRAID}" -eq '1' ] && print_info 1 'add "dodmraid" for dmraid support' [ "${DMRAID}" -eq '1' ] && print_info 1 ' or "dodmraid="' + [ "${ISCSI}" -eq '1' ] && print_info 1 'add "iscsi_i= iscsi_t= iscsi_a=" for iscsi support' fi [ "${BOOTRW}" != '' ] && mount -o remount,ro ${BOOTDIR} diff --git a/genkernel.conf b/genkernel.conf index 50052b7..0cb6a46 100644 --- a/genkernel.conf +++ b/genkernel.conf @@ -160,6 +160,11 @@ DMRAID_DIR="dmraid/${DMRAID_VER}" DMRAID_SRCTAR="${DISTDIR}/dmraid-${DMRAID_VER}.tar.bz2" DMRAID_BINCACHE="%%CACHE%%/dmraid-${DMRAID_VER}-%%ARCH%%.tar.bz2" +ISCSI_VER="VERSION_ISCSI" +ISCSI_DIR="open-iscsi-${ISCSI_VER}" +ISCSI_SRCTAR="${DISTDIR}/open-iscsi-${ISCSI_VER}.tar.gz" +ISCSI_BINCACHE="%%CACHE%%/iscsi-${ISCSI_VER}-%%ARCH%%.bz2" + E2FSPROGS_VER="VERSION_E2FSPROGS" E2FSPROGS_DIR="e2fsprogs-${E2FSPROGS_VER}" E2FSPROGS_SRCTAR="${DISTDIR}/e2fsprogs-${E2FSPROGS_VER}.tar.gz" -- 2.26.2