Skip to content

Commit

Permalink
Support building templates with BTRFS as rootfs
Browse files Browse the repository at this point in the history
  • Loading branch information
marmarek committed Feb 27, 2022
1 parent 77703cb commit ddab0f2
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ TEMPLATE_ENV_WHITELIST += \
TEMPLATE_FLAVOR_DIR TEMPLATE_OPTIONS APPMENUS_DIR \
VERBOSE DEBUG PATH BUILDER_DIR SRC_DIR DISCARD_PREPARED_IMAGE \
TEMPLATE_ROOT_WITH_PARTITIONS TEMPLATE_ROOT_SIZE \
TEMPLATE_ROOT_FSTYPE \
USE_QUBES_REPO_VERSION USE_QUBES_REPO_TESTING \
BUILDER_TURBO_MODE REPO_PROXY FEDORA_MIRROR \
CENTOS_MIRROR EPEL_MIRROR QUBES_MIRROR \
Expand Down
26 changes: 24 additions & 2 deletions prepare_image
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ if [ -z "$TEMPLATE_ROOT_SIZE" ]; then
TEMPLATE_ROOT_SIZE=10G
fi

if [ -z "$TEMPLATE_ROOT_FSTYPE" ]; then
TEMPLATE_ROOT_FSTYPE=ext4
fi

# ------------------------------------------------------------------------------
# Make sure INSTALLDIR exists
# ------------------------------------------------------------------------------
Expand Down Expand Up @@ -82,10 +86,28 @@ EOF
udevadm settle --exit-if-exists="$IMG_DEV"

echo "-> Creating filesystem..."
/sbin/mkfs.ext4 -q -F "${IMG_DEV}" || exit 1
case "$TEMPLATE_ROOT_FSTYPE" in
ext4)
/sbin/mkfs.ext4 -q -F "${IMG_DEV}" || exit 1
;;
btrfs)
/sbin/mkfs.btrfs -q -f "${IMG_DEV}" || exit 1
mount "${IMG_DEV}" "${INSTALLDIR}" || exit 1
btrfs subvolume create "${INSTALLDIR}/root" || exit 1
umount "${INSTALLDIR}" || exit 1
;;
*)
echo "Unsupported filesystem $TEMPLATE_ROOT_FSTYPE" >&2
exit 1
;;
esac
fi

mount "${IMG_DEV}" "${INSTALLDIR}" || exit 1
if [ "$TEMPLATE_ROOT_FSTYPE" = "btrfs" ]; then
mount -o subvol=/root "${IMG_DEV}" "${INSTALLDIR}" || exit 1
else
mount "${IMG_DEV}" "${INSTALLDIR}" || exit 1
fi
trap "umount_kill $(readlink -m ${INSTALLDIR})" EXIT
"${SCRIPTSDIR}/01_install_core.sh"

Expand Down
11 changes: 10 additions & 1 deletion qubeize_image
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,23 @@ else
IMG_DEV=${IMG_LOOP}
fi
udevadm settle --exit-if-exists="$IMG_DEV"
mount "$IMG_DEV" mnt || exit 1
if [ "$TEMPLATE_ROOT_FSTYPE" = "btrfs" ]; then
mount -o subvol=/root "${IMG_DEV}" mnt || exit 1
else
mount "${IMG_DEV}" mnt || exit 1
fi
export INSTALLDIR=mnt

# ------------------------------------------------------------------------------
# Run qubeize script
# ------------------------------------------------------------------------------
"$SCRIPTSDIR/04_install_qubes.sh"

if [ "$TEMPLATE_ROOT_FSTYPE" = "btrfs" ]; then
# patch fstab
sed -i -e 's:dmroot.*ext4.*:dmroot / btrfs defaults,discard,noatime,subvol=/root 1 1:' mnt/etc/fstab
fi

# ------------------------------------------------------------------------------
# Create App Menus
# ------------------------------------------------------------------------------
Expand Down

0 comments on commit ddab0f2

Please sign in to comment.