From 184482a7fea2b03fea347c451f73378adb015738 Mon Sep 17 00:00:00 2001 From: Kron4ek Date: Wed, 31 May 2023 16:30:13 +0500 Subject: [PATCH] Replace fuse-overlayfs with unionfs-fuse In my testing, unionfs-fuse works significantly faster than fuse-overlayfs. And it supports both fuse2 and fuse3, which is also an advantage over fuse-overlayfs. --- conty-start.sh | 36 +++++++++++++++--------------------- create-utils.sh | 25 ++++++++++++++++--------- utils.tar.gz | 4 ++-- utils_dwarfs.tar.gz | 4 ++-- 4 files changed, 35 insertions(+), 34 deletions(-) diff --git a/conty-start.sh b/conty-start.sh index 8edde2d..72ba1d4 100755 --- a/conty-start.sh +++ b/conty-start.sh @@ -24,9 +24,9 @@ script_version="1.24.1" # size to 0 init_size=40000 bash_size=1339208 -script_size=35959 +script_size=35698 busybox_size=1161112 -utils_size=4049807 +utils_size=4101345 # Full path to the script if [ -n "${BASH_SOURCE[0]}" ]; then @@ -158,10 +158,9 @@ Environment variables: isolates X11 server with Xephyr. The default is 1. - USE_OVERLAYFS Mounts a writable fuse-overlayfs filesystem on top + USE_OVERLAYFS Mounts a writable unionfs-fuse filesystem on top of the read-only squashfs/dwarfs image, allowing to - modify files inside it. Fuse3 is required for this - feature. + modify files inside it. Overlays are stored in ~/.local/share/Conty. If you want to undo any changes, delete the entire directory from there. @@ -171,7 +170,7 @@ Environment variables: if you are using an Nvidia GPU, the proprietary driver and encountering issues running graphical applications. At least 2 GB of free disk space is - required. And fuse3 is required for this feature. + required. This function is enabled by default. USE_SYS_UTILS Tells the script to use squashfuse/dwarfs and bwrap installed on the system instead of the builtin ones. @@ -347,15 +346,10 @@ mount_overlayfs () { mkdir -p "${overlayfs_dir}"/merged if [ ! "$(ls "${overlayfs_dir}"/merged 2>/dev/null)" ]; then - if command -v "${fuse_overlayfs}" 1>/dev/null; then - if [ -n "${fuse_version}" ]; then - "${fuse_overlayfs}" -o noatime,squash_to_uid="$(id -u)",squash_to_gid="$(id -g)",lowerdir="${mount_point}",upperdir="${overlayfs_dir}"/up,workdir="${overlayfs_dir}"/work "${overlayfs_dir}"/merged - else - echo "Fuse3 is required for fuse-overlayfs" - return 1 - fi + if command -v "${unionfs_fuse}" 1>/dev/null; then + "${unionfs_fuse}" -o relaxed_permissions,cow,noatime "${overlayfs_dir}"/up=RW:"${mount_point}"=RO "${overlayfs_dir}"/merged else - echo "fuse-overlayfs not found" + echo "unionfs-fuse not found" return 1 fi fi @@ -547,7 +541,7 @@ if ([ "${USE_SYS_UTILS}" != 1 ] && [ "${utils_size}" -gt 0 ]) || [ "$1" = "-u" ] fi bwrap="${working_dir}"/utils/bwrap - fuse_overlayfs="${working_dir}"/utils/fuse-overlayfs + unionfs_fuse="${working_dir}"/utils/unionfs"${fuse_version}" if [ ! -f "${mount_tool}" ] || [ ! -f "${bwrap}" ]; then tail -c +$((init_size+bash_size+script_size+busybox_size+1)) "${script}" | head -c "${utils_size}" | tar -C "${working_dir}" -zxf - @@ -563,7 +557,7 @@ if ([ "${USE_SYS_UTILS}" != 1 ] && [ "${utils_size}" -gt 0 ]) || [ "$1" = "-u" ] chmod +x "${mount_tool}" 2>/dev/null chmod +x "${bwrap}" 2>/dev/null chmod +x "${extraction_tool}" 2>/dev/null - chmod +x "${fuse_overlayfs}" 2>/dev/null + chmod +x "${unionfs_fuse}" 2>/dev/null chmod +x "${compression_tool}" 2>/dev/null fi else @@ -575,7 +569,7 @@ else fi bwrap=bwrap - fuse_overlayfs=fuse-overlayfs + unionfs_fuse=unionfs if [ "${dwarfs_image}" = 1 ]; then if ! command -v dwarfs 1>/dev/null && ! command -v dwarfs2 1>/dev/null; then @@ -1046,7 +1040,7 @@ if [ "$(ls "${mount_point}" 2>/dev/null)" ] || \ echo "directory or in your HOME." fi else - echo "Failed to mount overlayfs" + echo "Failed to mount unionfs" echo "Cannot update Conty" fi @@ -1055,9 +1049,9 @@ if [ "$(ls "${mount_point}" 2>/dev/null)" ] || \ if [ "${USE_OVERLAYFS}" = 1 ]; then if mount_overlayfs; then - show_msg "Using overlayfs" + show_msg "Using unionfs" else - echo "Failed to mount overlayfs" + echo "Failed to mount unionfs" unset USE_OVERLAYFS fi fi @@ -1080,7 +1074,7 @@ if [ "$(ls "${mount_point}" 2>/dev/null)" ] || \ --bind "${nvidia_drivers_dir}" "${nvidia_drivers_dir}" \ bash -c nvidia_driver_handler else - echo "Nvidia driver handler disabled due to overlayfs errors" + echo "Nvidia driver handler disabled due to unionfs errors" unset NVIDIA_HANDLER fi else diff --git a/create-utils.sh b/create-utils.sh index 18605ab..4d5eea2 100755 --- a/create-utils.sh +++ b/create-utils.sh @@ -20,7 +20,7 @@ bwrap_version="0.8.0" lz4_version="1.9.4" zstd_version="1.5.5" squashfs_tools_version="4.6.1" -fuse_overlayfs_version="1.12" +unionfs_fuse_version="3.3" busybox_version="1.36.1" bash_version="5.2.15" @@ -37,7 +37,7 @@ cd "${script_dir}"/build-utils || exit 1 curl -#Lo lz4.tar.gz https://github.com/lz4/lz4/archive/refs/tags/v${lz4_version}.tar.gz curl -#Lo zstd.tar.gz https://github.com/facebook/zstd/archive/refs/tags/v${zstd_version}.tar.gz curl -#Lo bwrap.tar.gz https://github.com/containers/bubblewrap/archive/refs/tags/v${bwrap_version}.tar.gz -curl -#Lo fuse-overlayfs.tar.gz https://github.com/containers/fuse-overlayfs/archive/refs/tags/v${fuse_overlayfs_version}.tar.gz +curl -#Lo unionfs-fuse.tar.gz https://github.com/rpodgorny/unionfs-fuse/archive/refs/tags/v${unionfs_fuse_version}.tar.gz curl -#Lo busybox.tar.bz2 https://busybox.net/downloads/busybox-${busybox_version}.tar.bz2 curl -#Lo bash.tar.gz https://ftp.gnu.org/gnu/bash/bash-${bash_version}.tar.gz cp "${script_dir}"/init.c init.c @@ -45,7 +45,7 @@ cp "${script_dir}"/init.c init.c tar xf lz4.tar.gz tar xf zstd.tar.gz tar xf bwrap.tar.gz -tar xf fuse-overlayfs.tar.gz +tar xf unionfs-fuse.tar.gz tar xf busybox.tar.bz2 tar xf bash.tar.gz @@ -62,12 +62,18 @@ cd bubblewrap-"${bwrap_version}" || exit 1 ./configure --disable-selinux --disable-man make -j"$(nproc)" DESTDIR="${script_dir}"/build-utils/bin install -cd ../fuse-overlayfs-"${fuse_overlayfs_version}" || exit 1 -./autogen.sh -./configure +cd ../unionfs-fuse-"${unionfs_fuse_version}" || exit 1 +mkdir build-fuse3 +cd build-fuse3 +cmake ../ -DCMAKE_BUILD_TYPE=Release +make -j"$(nproc)" DESTDIR="${script_dir}"/build-utils/bin install +mv "${script_dir}"/build-utils/bin/usr/local/bin/unionfs "${script_dir}"/build-utils/bin/usr/local/bin/unionfs3 +mkdir ../build-fuse2 +cd ../build-fuse2 +cmake ../ -DCMAKE_BUILD_TYPE=Release -DWITH_LIBFUSE3=FALSE make -j"$(nproc)" DESTDIR="${script_dir}"/build-utils/bin install -cd ../lz4-"${lz4_version}" || exit 1 +cd ../../lz4-"${lz4_version}" || exit 1 make -j"$(nproc)" DESTDIR="${script_dir}"/build-utils/bin install cd ../zstd-"${zstd_version}" || exit 1 @@ -105,7 +111,8 @@ mv bin/usr/local/bin/squashfuse utils mv bin/usr/local/bin/squashfuse_ll utils mv bin/usr/local/bin/mksquashfs utils mv bin/usr/local/bin/unsquashfs utils -mv bin/usr/local/bin/fuse-overlayfs utils +mv bin/usr/local/bin/unionfs3 utils +mv bin/usr/local/bin/unionfs utils mv bin/usr/local/lib/liblz4.so."${lz4_version}" utils/liblz4.so.1 mv bin/usr/local/lib/libzstd.so."${zstd_version}" utils/libzstd.so.1 mv bin/usr/local/lib/libfuseprivate.so.0.0.0 utils/libfuseprivate.so.0 @@ -192,7 +199,7 @@ mv init utils cat < utils/info bubblewrap ${bwrap_version} -fuse-overlayfs ${fuse_overlayfs_version} +unionfs-fuse ${unionfs_fuse_version} busybox ${busybox_version} bash ${bash_version} lz4 ${lz4_version} diff --git a/utils.tar.gz b/utils.tar.gz index 9dd9b74..5a65e9f 100644 --- a/utils.tar.gz +++ b/utils.tar.gz @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:eefb9b12b71605d0cc2925c497f2447b2eaf383540522d4967ccd8e2053b29c5 -size 4049807 +oid sha256:4d2324d40f8cd6bc678113974e118578c23f9d540bcedfec7cb9543cec5b8b9b +size 4101345 diff --git a/utils_dwarfs.tar.gz b/utils_dwarfs.tar.gz index 7372112..8f6f328 100644 --- a/utils_dwarfs.tar.gz +++ b/utils_dwarfs.tar.gz @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bb6d97c95baab37870c80f73e190de4dbb4a29327054c8d24e3ecf7122b10ed2 -size 10917484 +oid sha256:287e670ce14ef0cf4fb4d218b75ce1dcabaf81a867774af81a147f0c266852fe +size 10969966