[1/1] allow to set squashfs block size

Message ID 20200113093152.45326-1-list@eworm.de
State New
Headers show
Series
  • [1/1] allow to set squashfs block size
Related show

Commit Message

Christian Hesse Jan. 13, 2020, 9:31 a.m. UTC
From: Christian Hesse <mail@eworm.de>

This allows to set squashfs block size. Increasing block size may reduce
image size, but add extra I/O and cpu penalty.

Signed-off-by: Christian Hesse <mail@eworm.de>
---
 archiso/mkarchiso | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

Patch

diff --git a/archiso/mkarchiso b/archiso/mkarchiso
index 567a5af..5c7bc4a 100755
--- a/archiso/mkarchiso
+++ b/archiso/mkarchiso
@@ -18,6 +18,7 @@  work_dir="work"
 out_dir="out"
 sfs_mode="sfs"
 sfs_comp="xz"
+sfs_block_size="128K"
 gpg_key=
 
 # Show an INFO message
@@ -95,6 +96,8 @@  _usage ()
     echo "                     Default: ${sfs_mode}"
     echo "    -c <comp_type>   Set SquashFS compression type (gzip, lzma, lzo, xz, zstd)"
     echo "                     Default: '${sfs_comp}'"
+    echo "    -b <block_size>  Set SquashFS block size"
+    echo "                     Default: '${sfs_block_size}'"
     echo "    -v               Enable verbose output"
     echo "    -h               This message"
     echo " commands:"
@@ -223,9 +226,9 @@  _mkairootfs_img () {
     mkdir -p "${work_dir}/iso/${install_dir}/${arch}"
     _msg_info "Creating SquashFS image, this may take some time..."
     if [[ "${quiet}" = "y" ]]; then
-        mksquashfs "${work_dir}/airootfs.img" "${work_dir}/iso/${install_dir}/${arch}/airootfs.sfs" -noappend -comp "${sfs_comp}" -no-progress &> /dev/null
+        mksquashfs "${work_dir}/airootfs.img" "${work_dir}/iso/${install_dir}/${arch}/airootfs.sfs" -noappend -comp "${sfs_comp}" -b "${sfs_block_size}" -no-progress &> /dev/null
     else
-        mksquashfs "${work_dir}/airootfs.img" "${work_dir}/iso/${install_dir}/${arch}/airootfs.sfs" -noappend -comp "${sfs_comp}" -no-progress
+        mksquashfs "${work_dir}/airootfs.img" "${work_dir}/iso/${install_dir}/${arch}/airootfs.sfs" -noappend -comp "${sfs_comp}" -b "${sfs_block_size}" -no-progress
     fi
     _msg_info "Done!"
     rm ${work_dir}/airootfs.img
@@ -240,9 +243,9 @@  _mkairootfs_sfs () {
     mkdir -p "${work_dir}/iso/${install_dir}/${arch}"
     _msg_info "Creating SquashFS image, this may take some time..."
     if [[ "${quiet}" = "y" ]]; then
-        mksquashfs "${work_dir}/airootfs" "${work_dir}/iso/${install_dir}/${arch}/airootfs.sfs" -noappend -comp "${sfs_comp}" -no-progress &> /dev/null
+        mksquashfs "${work_dir}/airootfs" "${work_dir}/iso/${install_dir}/${arch}/airootfs.sfs" -noappend -comp "${sfs_comp}" -b "${sfs_block_size}" -no-progress &> /dev/null
     else
-        mksquashfs "${work_dir}/airootfs" "${work_dir}/iso/${install_dir}/${arch}/airootfs.sfs" -noappend -comp "${sfs_comp}" -no-progress
+        mksquashfs "${work_dir}/airootfs" "${work_dir}/iso/${install_dir}/${arch}/airootfs.sfs" -noappend -comp "${sfs_comp}" -b "${sfs_block_size}" -no-progress
     fi
     _msg_info "Done!"
 }
@@ -369,7 +372,7 @@  fi
 
 umask 0022
 
-while getopts 'p:r:C:L:P:A:D:w:o:s:c:g:vh' arg; do
+while getopts 'p:r:C:L:P:A:D:w:o:s:c:b:g:vh' arg; do
     case "${arg}" in
         p) pkg_list="${pkg_list} ${OPTARG}" ;;
         r) run_cmd="${OPTARG}" ;;
@@ -382,6 +385,7 @@  while getopts 'p:r:C:L:P:A:D:w:o:s:c:g:vh' arg; do
         o) out_dir="${OPTARG}" ;;
         s) sfs_mode="${OPTARG}" ;;
         c) sfs_comp="${OPTARG}" ;;
+        b) sfs_block_size="${OPTARG}" ;;
         g) gpg_key="${OPTARG}" ;;
         v) quiet="n" ;;
         h|?) _usage 0 ;;