diff --git a/doc/molior-deploy.8.txt b/doc/molior-deploy.8.txt index 447ec4a..c51b6ca 100644 --- a/doc/molior-deploy.8.txt +++ b/doc/molior-deploy.8.txt @@ -73,7 +73,7 @@ FILESYSTEM PARAMETERS Up to 16 partitions / logical volumes are currently supported, and 1 physical volume or a full disk for LVM. SFDISK Input for sfdisk partitioning - PART#_FS Filesystem of partition # (ext4, ... or 'lvm' for LVM physical volume) + PART#_FS Filesystem of partition # (ext4, btrfs, ... or 'lvm' for LVM physical volume) PART#_MNT Mountpoint of partition # PART#_OPTS fstab options (i.e. "defaults,noatime") PART#_MKFSOPTS Options for mkfs (i.e. "-O ^64bit,^metadata_csum") @@ -92,6 +92,9 @@ FILESYSTEM PARAMETERS BIND_MOUNTS Space (' ') separated list of target:source[:mountopts] bind mount pairs which will be mounted before installation and added to the fstab EXTRA_BIND_MOUNTS Space (' ') separated list of target:source[:mountopts] bind mount pairs which will be added to the fstab + BTRFS_SUBVOL#_PATH btrfs subvolume to be created on specified path (for example /opt) + BTRFS_SUBVOL#_LIMIT btrfs subvolume quota limit (postfixed by M,G,...) + RAID PARAMETERS Software RAID via the 'mdadm' may be created by defining the following parameters. @@ -188,6 +191,49 @@ EXAMPLE LVM_LV3_SIZE=16G LVM_LV3_FS="ext4" + Example deployment configuration (VirtualBox with EFI boot, GUID partition table, btrfs and guest utils): + + $ cat deploy/vbox-btrfs.conf + # vim: syntax=sh + + DEPLOYMENT_TYPE=vbox + ARCH=amd64 + TARGET_HOSTNAME=$PROJECT-demo + LINUX_CMDLINE="biosdevname=0 net.ifnames=0 init=/lib/systemd/systemd nomodeset systemd.show_status=0 loglevel=0" + INSTALL_PACKAGE=vbox-demo + + MINIMIZE=1 # do not install docs and manpages + + VMSIZE=24576 # 24MB + VMRAM=2048 + VMVRAM=128 + + APT_SOURCES_EXTRA="deb http://debrepo/mirrors/stretch-backports stretch-backports main contrib non-free" + APT_INSTALL_EXTRA="virtualbox-guest-dkms virtualbox-guest-utils virtualbox-guest-x11" + + TARGET_BOOTTYPE=efi + + SFDISK="unit: sectors + label: gpt + efi: type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, size=512M, + swap: type=0657FD6D-A4AB-43C4-84E5-0933C84B4F4F, size=512M, + btrfs: type=0FC63DAF-8483-4772-8E79-3D69D8477DE4" + + PART1_FS=vfat + PART1_MNT=/boot/efi + + PART2_FS=swap + + PART3_FS=btrfs + PART3_MNT=/ + PART3_OPTS=defaults,noatime + + BTRFS_SUBVOL1_PATH=/ + BTRFS_SUBVOL1_LIMIT=4G + + BTRFS_SUBVOL2_PATH=/opt + BTRFS_SUBVOL2_LIMIT=5G + AUTHORS Please see the AUTHORS file in the source repositories. diff --git a/molior-deploy.sh.inc b/molior-deploy.sh.inc index fb08e5b..2391711 100644 --- a/molior-deploy.sh.inc +++ b/molior-deploy.sh.inc @@ -6,6 +6,7 @@ fs_has_partitions=0 fs_has_lvm=0 fs_has_luks=0 fs_on_raid=0 +fs_has_btrfs=0 exit_on_error() { @@ -339,6 +340,11 @@ make_fs() elif [ "$s" = "luks" ]; then create_luks $part $name + elif [ "$s" = "btrfs" ]; then + log "mkfs $part" + eval mkfs -t btrfs -f $opts $part >/dev/null + exit_on_error "Error formatting partition $part as $s" + else # normal filesystems log "mkfs $part" eval mkfs -t $s $opts $part >/dev/null @@ -426,7 +432,11 @@ get_fsinfo() set -x fs_has_luks=1 set +x - break + fi + if [ "$s" = "btrfs" ]; then + set -x + fs_has_btrfs=1 + set +x fi done set -x @@ -492,6 +502,33 @@ mount_fs() set -x fi + set +x + for p in `seq 1 $MAXPART` + do + eval subvol_path=\$BTRFS_SUBVOL${p}_PATH + if [ -z "$subvol_path" ]; then + continue + fi + subvol=$target$subvol_path + if [ ! -e $subvol ]; then + dir=${subvol%${subvol##*/}} + if [ ! -e $dir ]; then + mkdir -p $dir + fi + set -x + btrfs subvolume create $subvol + set +x + fi + eval subvol_limit=\$BTRFS_SUBVOL${p}_LIMIT + if [ -n "$subvol_limit" ]; then + set -x + btrfs quota enable $subvol + btrfs qgroup limit $subvol_limit $subvol + set +x + fi + done + set -x + if [ -n "$LVM_VG" ]; then set +x for p in `seq 1 $MAXPART` @@ -731,6 +768,11 @@ get_deploy_config() test -n "$s" && echovar LVM_LV${p}_SIZE "$s" eval s=\$LVM_LV${p}_MKFSOPTS test -n "$s" && echovar LVM_LV${p}_MKFSOPTS "$s" + + eval s=\$BTRFS_SUBVOL${p}_PATH + test -n "$s" && echovar BTRFS_SUBVOL${p}_PATH "$s" + eval s=\$BTRFS_SUBVOL${p}_LIMIT + test -n "$s" && echovar BTRFS_SUBVOL${p}_LIMIT "$s" done echovar BIND_MOUNTS echovar EXTRA_BIND_MOUNTS diff --git a/plugins/installer.plugin b/plugins/installer.plugin index eecd7db..5237593 100644 --- a/plugins/installer.plugin +++ b/plugins/installer.plugin @@ -129,6 +129,9 @@ prepare_initrd_deployment() if [ "$fs_on_raid" -eq 1 ]; then INSTALLER_EXTRA_PACKAGES="$INSTALLER_EXTRA_PACKAGES mdadm" fi + if [ "$fs_has_btrfs" -eq 1 ]; then + INSTALLER_EXTRA_PACKAGES="$INSTALLER_EXTRA_PACKAGES btrfs-progs" + fi if [ ! -d $WORK_DIR/instroot ]; then # in case of using a base roots, there is no instroot debootstrap left, @@ -137,6 +140,11 @@ prepare_initrd_deployment() chroot $WORK_DIR/instroot apt-get update >&2 fi + if [ "$fs_has_btrfs" -eq 1 ]; then + echo "copy_exec /sbin/mkfs.btrfs /sbin" >> $initrd/hooks/installer + echo btrfs >> $initrd/modules + fi + DEBIAN_FRONTEND=noninteractive chroot $WORK_DIR/instroot apt-get install --no-install-recommends --yes \ $INSTALLER_EXTRA_PACKAGES $LINUX_IMAGE_NAME \ busybox initramfs-tools isolinux syslinux-common \