mirror of
https://github.com/Kron4ek/Conty
synced 2024-11-16 19:50:06 +01:00
Tweaks for dwarfs
This commit is contained in:
parent
8292d055f0
commit
a34eef062b
2 changed files with 37 additions and 5 deletions
|
@ -43,7 +43,7 @@ mount_point="${working_dir}"/mnt
|
|||
# a problem with mounting the image due to an incorrectly calculated offset.
|
||||
|
||||
# The size of this script
|
||||
scriptsize=21361
|
||||
scriptsize=22365
|
||||
|
||||
# The size of the utils.tar.gz archive
|
||||
# utils.tar.gz contains bwrap, squashfuse and dwarfs binaries
|
||||
|
@ -55,6 +55,9 @@ offset=$((scriptsize+utilssize))
|
|||
# Set to 1 if you are using an image compressed with dwarfs instead of squashfs
|
||||
dwarfs_image=0
|
||||
|
||||
dwarfs_cache_size="128M"
|
||||
dwarfs_num_workers="2"
|
||||
|
||||
if [ "$1" = "--help" ] || [ "$1" = "-h" ] || ([ -z "$1" ] && [ ! -L "${script_literal}" ]); then
|
||||
echo "Usage: ./conty.sh command command_arguments"
|
||||
echo
|
||||
|
@ -126,13 +129,15 @@ elif [ "$1" = "-v" ]; then
|
|||
elif [ "$1" = "-e" ]; then
|
||||
if [ "${dwarfs_image}" = 1 ]; then
|
||||
if command -v dwarfsextract 1>/dev/null; then
|
||||
dwarfsextract -i "${script}" -o "$(basename "${script}")"_files
|
||||
mkdir "$(basename "${script}")"_files
|
||||
|
||||
dwarfsextract -i "${script}" -o "$(basename "${script}")"_files -O ${offset}
|
||||
else
|
||||
echo "To extract the image install dwarfs."
|
||||
fi
|
||||
else
|
||||
if command -v unsquashfs 1>/dev/null; then
|
||||
unsquashfs -o $offset -user-xattrs -d "$(basename "${script}")"_files "${script}"
|
||||
unsquashfs -o ${offset} -user-xattrs -d "$(basename "${script}")"_files "${script}"
|
||||
else
|
||||
echo "To extract the image install squashfs-tools."
|
||||
fi
|
||||
|
@ -185,6 +190,31 @@ if [ "${SUDO_MOUNT}" != 1 ] || [ "${dwarfs_image}" = 1 ]; then
|
|||
fi
|
||||
fi
|
||||
|
||||
# Set the dwarfs block cache size depending on how much RAM is available
|
||||
if [ "${dwarfs_image}" = 1 ]; then
|
||||
if getconf _PHYS_PAGES &>/dev/null && getconf PAGE_SIZE &>/dev/null; then
|
||||
memory_size="$(($(getconf _PHYS_PAGES) * $(getconf PAGE_SIZE) / (1024 * 1024)))"
|
||||
|
||||
if [ "${memory_size}" -ge 23000 ]; then
|
||||
dwarfs_cache_size="2048M"
|
||||
elif [ "${memory_size}" -ge 15000 ]; then
|
||||
dwarfs_cache_size="1024M"
|
||||
elif [ "${memory_size}" -ge 7000 ]; then
|
||||
dwarfs_cache_size="512M"
|
||||
elif [ "${memory_size}" -ge 3000 ]; then
|
||||
dwarfs_cache_size="256M"
|
||||
elif [ "${memory_size}" -ge 1500 ]; then
|
||||
dwarfs_cache_size="128M"
|
||||
else
|
||||
dwarfs_cache_size="64M"
|
||||
fi
|
||||
fi
|
||||
|
||||
if getconf _NPROCESSORS_ONLN &>/dev/null; then
|
||||
dwarfs_num_workers="$(getconf _NPROCESSORS_ONLN)"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Extract utils.tar.gz
|
||||
mkdir -p "${working_dir}"
|
||||
|
||||
|
@ -616,7 +646,8 @@ mkdir -p "${mount_point}"
|
|||
|
||||
if [ "$(ls "${mount_point}" 2>/dev/null)" ] || \
|
||||
( [ "${dwarfs_image}" != 1 ] && launch_wrapper "${mount_tool}" -o offset="${offset}",ro "${script}" "${mount_point}" ) || \
|
||||
launch_wrapper "${mount_tool}" "${script}" "${mount_point}" -o offset="${offset}" -o debuglevel=error; then
|
||||
launch_wrapper "${mount_tool}" "${script}" "${mount_point}" -o offset="${offset}" -o debuglevel=error -o workers="${dwarfs_num_workers}" \
|
||||
-o mlock=try -o no_cache_image -o cache_files -o cachesize="${dwarfs_cache_size}"; then
|
||||
|
||||
echo 1 > "${working_dir}"/running_"${script_id}"
|
||||
|
||||
|
|
|
@ -12,7 +12,8 @@ squashfs_compressor_arguments="-b 256K -comp ${squashfs_compressor} -Xhc"
|
|||
|
||||
# Use dwarfs instead of squashfs
|
||||
dwarfs="false"
|
||||
dwarfs_compressor_arguments="-l7 -C zstd:level=19 --metadata-compression null -S 22"
|
||||
dwarfs_compressor_arguments="-l7 -C zstd:level=19 --metadata-compression null \
|
||||
-S 22 -B 3 --bloom-filter-size 5"
|
||||
|
||||
# Set to true to use an existing image if it exists
|
||||
# Otherwise the script will always create a new image
|
||||
|
|
Loading…
Reference in a new issue