commit: d41ebc4d721a8706d0b0f7c5cd1ed8dab42d667c Author: Niklas Haas <git <AT> nand <DOT> wakku <DOT> to> AuthorDate: Wed Aug 19 19:13:20 2015 +0000 Commit: Richard Farina <zerochaos <AT> gentoo <DOT> org> CommitDate: Wed Aug 19 19:27:25 2015 +0000 URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=d41ebc4d
Support multi-device Btrfs filesystems This requires running `/sbin/btrfs device` scan during boot, which is exposed via the new parameter ``dobtrfs''. defaults/initrd.scripts | 10 ++++++++++ defaults/linuxrc | 3 +++ doc/genkernel.8.txt | 6 ++++++ gen_cmdline.sh | 6 ++++++ gen_determineargs.sh | 1 + gen_initramfs.sh | 21 +++++++++++++++++++++ genkernel | 1 + genkernel.conf | 3 +++ 8 files changed, 51 insertions(+) diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts index e05809c..4724b55 100644 --- a/defaults/initrd.scripts +++ b/defaults/initrd.scripts @@ -997,6 +997,16 @@ startVolumes() { bad_msg "vgscan or vgchange not found: skipping LVM volume group activation!" fi fi + + if [ "${USE_BTRFS}" = '1' ] + then + if [ -x '/sbin/btrfs' ] + then + /sbin/btrfs device scan + else + bad_msg "btrfs not found: skipping btrfs device scanning!" + fi + fi if [ "${USE_ZFS}" = '1' ] then diff --git a/defaults/linuxrc b/defaults/linuxrc index 19b9878..46b2151 100644 --- a/defaults/linuxrc +++ b/defaults/linuxrc @@ -120,6 +120,9 @@ do ZPOOL_FORCE=-f fi ;; + dobtrfs*) + USE_BTRFS=1 + ;; quiet) QUIET=1 ;; diff --git a/doc/genkernel.8.txt b/doc/genkernel.8.txt index f8d7a10..45af60e 100644 --- a/doc/genkernel.8.txt +++ b/doc/genkernel.8.txt @@ -275,6 +275,9 @@ INITIALIZATION *--*[*no-*]*zfs*:: Includes or excludes ZFS support. +*--*[*no-*]*btrfs*:: + Includes or excludes Btrfs support. + *--*[*no-*]*multipath*:: Includes or excludes Multipath support @@ -476,6 +479,9 @@ which the ramdisk & initramfs scripts would recognize. Scan for bootable ZFS pools on bootup. Optionally force import if necessary. +*dobtrfs*:: + Scan for attached Btrfs devices on bootup. + *domultipath*:: Activate Multipath on bootup diff --git a/gen_cmdline.sh b/gen_cmdline.sh index 2678d5d..c4f027a 100755 --- a/gen_cmdline.sh +++ b/gen_cmdline.sh @@ -99,6 +99,8 @@ longusage() { echo " --no-e2fsprogs Exclude e2fsprogs" echo " --zfs Include ZFS support" echo " --no-zfs Exclude ZFS support" + echo " --btrfs Include Btrfs support" + echo " --no-btrfs Exclude Btrfs support" echo " --multipath Include Multipath support" echo " --no-multipath Exclude Multipath support" echo " --iscsi Include iSCSI support" @@ -331,6 +333,10 @@ parse_cmdline() { CMD_ZFS=`parse_optbool "$*"` print_info 2 "CMD_ZFS: ${CMD_ZFS}" ;; + --btrfs|--no-btrfs) + CMD_BTRFS=`parse_optbool "$*"` + print_info 2 "CMD_BTRFS: ${CMD_BTRFS}" + ;; --virtio) CMD_VIRTIO=`parse_optbool "$*"` print_info 2 "CMD_VIRTIO: ${CMD_VIRTIO}" diff --git a/gen_determineargs.sh b/gen_determineargs.sh index 59af78b..cbc88ba 100755 --- a/gen_determineargs.sh +++ b/gen_determineargs.sh @@ -125,6 +125,7 @@ determine_real_args() { set_config_with_override STRING MDADM_CONFIG CMD_MDADM_CONFIG set_config_with_override BOOL E2FSPROGS CMD_E2FSPROGS "no" set_config_with_override BOOL ZFS CMD_ZFS "$(rootfs_type_is zfs)" + set_config_with_override BOOL BTRFS CMD_BTRFS "$(rootfs_type_is btrfs)" set_config_with_override BOOL VIRTIO CMD_VIRTIO "no" set_config_with_override BOOL MULTIPATH CMD_MULTIPATH set_config_with_override BOOL FIRMWARE CMD_FIRMWARE diff --git a/gen_initramfs.sh b/gen_initramfs.sh index e7f72df..99a99c4 100755 --- a/gen_initramfs.sh +++ b/gen_initramfs.sh @@ -462,6 +462,25 @@ append_zfs(){ rm -rf "${TEMP}/initramfs-zfs-temp" > /dev/null } +append_btrfs() { + if [ -d "${TEMP}/initramfs-btrfs-temp" ] + 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}" \ + || gen_die "compressing btrfs cpio" + cd "${TEMP}" + rm -rf "${TEMP}/initramfs-btrfs-temp" > /dev/null +} + append_linker() { if [ -d "${TEMP}/initramfs-linker-temp" ] then @@ -817,6 +836,8 @@ create_initramfs() { append_data 'zfs' "${ZFS}" + append_data 'btrfs' "${BTRFS}" + append_data 'blkid' "${DISKLABEL}" append_data 'unionfs_fuse' "${UNIONFS}" diff --git a/genkernel b/genkernel index 9f3ec9c..15ea11f 100755 --- a/genkernel +++ b/genkernel @@ -370,6 +370,7 @@ then [ "${DMRAID}" = '1' ] && print_warning 1 ' or "dodmraid=<additional options>"' [ "${ZFS}" = '1' ] && print_warning 1 'add "dozfs" for ZFS volume management support' [ "${ZFS}" = '1' ] && print_warning 1 ' and either "root=ZFS" to use bootfs autodetection or "root=ZFS=<dataset>" to force booting from a specific dataset' + [ "${BTRFS}" = '1' ] && print_warning 1 'add "dobtrfs" for Btrfs device scanning support' [ "${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 [[ "$(file --brief --mime-type "${KERNEL_CONFIG}")" == application/x-gzip ]]; then diff --git a/genkernel.conf b/genkernel.conf index a34e6e7..2e38e41 100644 --- a/genkernel.conf +++ b/genkernel.conf @@ -96,6 +96,9 @@ USECOLOR="yes" # Include support for zfs volume management. #ZFS="no" +# Add BTRFS support. +#BTRFS="no" + # Enable copying of firmware into initramfs #FIRMWARE="no" # Specify directory to pull from