From a637bdb8574168ab4cddef13d5de7f458650bda5 Mon Sep 17 00:00:00 2001 From: Gerardo Exequiel Pozzi Date: Tue, 27 Jan 2015 14:37:05 -0300 Subject: [archiso] Add optional OverlayFS support This is the first attemp to test overlayfs in archiso. The current dm-snapshot mode is keep and is enabled by default, while the new mode is enabled via "-s sfs" to mkarchiso. No new boot parameters are added, since archiso hooks detects if the .sfs file is for dm-snapshot (airootfs.img inside) or for overlayfs. Persistence is supported in overlayfs mode using the same options (cowlabel or cowdevice), but warning while in dm-snapshot mode, only one file is used (airootfs.cow), in overlayfs mode internal files for workdir/ and upperdir/ are allocated, so you can not use VFAT or NTFS. To test this, you need to enable [testing] in pacman.conf from releng profile and edit build.sh then add "-s sfs" in make_prepare() Look at: setarch ${arch} mkarchiso ${verbose} -w "${work_dir}" -D "${install_dir}" prepare Replace with: setarch ${arch} mkarchiso ${verbose} -w "${work_dir}" -s sfs -D "${install_dir}" prepare The build requires just half of space that the build for dm-snapshot, since there is no ext4 img ;) Just to remember: there is no space gain in .sfs (just about 2M) There is at least one thing during boot with machine-id service: Dec 24 03:31:39 archiso systemd-machine-id-commit[183]: Failed to unmount transient /etc/machine-id file in our private namespace: Invalid argument Signed-off-by: Gerardo Exequiel Pozzi --- archiso/mkarchiso | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) (limited to 'archiso/mkarchiso') diff --git a/archiso/mkarchiso b/archiso/mkarchiso index 5643525..0da02b0 100755 --- a/archiso/mkarchiso +++ b/archiso/mkarchiso @@ -16,6 +16,7 @@ iso_application="Arch Linux Live/Rescue CD" install_dir="arch" work_dir="work" out_dir="out" +sfs_mode="img" sfs_comp="xz" # Show an INFO message @@ -87,6 +88,10 @@ _usage () echo " Default: '${work_dir}'" echo " -o Set the output directory" echo " Default: '${out_dir}'" + echo " -s Set SquashFS image mode (img or sfs)" + echo " img: prepare airootfs.sfs for dm-snapshot usage" + echo " sfs: prepare airootfs.sfs for overlayfs usage" + echo " Default: ${sfs_mode}" echo " -c Set SquashFS compression type (gzip, lzma, lzo, xz)" echo " Default: '${sfs_comp}'" echo " -v Enable verbose output" @@ -193,8 +198,8 @@ _cleanup () { _msg_info "Done!" } -# Makes a filesystem from a source directory. -_mkairootfs () { +# Makes a ext4 filesystem inside a SquashFS from a source directory. +_mkairootfs_img () { if [[ ! -e "${work_dir}/airootfs" ]]; then _msg_error "The path '${work_dir}/airootfs' does not exist" 1 fi @@ -224,6 +229,22 @@ _mkairootfs () { rm ${work_dir}/airootfs.img } +# Makes a SquashFS filesystem from a source directory. +_mkairootfs_sfs () { + if [[ ! -e "${work_dir}/airootfs" ]]; then + _msg_error "The path '${work_dir}/airootfs' does not exist" 1 + fi + + 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 + else + mksquashfs "${work_dir}/airootfs" "${work_dir}/iso/${install_dir}/${arch}/airootfs.sfs" -noappend -comp "${sfs_comp}" -no-progress + fi + _msg_info "Done!" +} + _mkchecksum () { _msg_info "Creating checksum file for self-test..." cd "${work_dir}/iso/${install_dir}/${arch}" @@ -292,7 +313,11 @@ command_prepare () { _show_config prepare _cleanup - _mkairootfs + if [[ ${sfs_mode} == "sfs" ]]; then + _mkairootfs_sfs + else + _mkairootfs_img + fi _mkchecksum } @@ -330,7 +355,7 @@ if [[ ${EUID} -ne 0 ]]; then _msg_error "This script must be run as root." 1 fi -while getopts 'p:r:C:L:P:A:D:w:o:c:vh' arg; do +while getopts 'p:r:C:L:P:A:D:w:o:s:c:vh' arg; do case "${arg}" in p) pkg_list="${pkg_list} ${OPTARG}" ;; r) run_cmd="${OPTARG}" ;; @@ -341,6 +366,7 @@ while getopts 'p:r:C:L:P:A:D:w:o:c:vh' arg; do D) install_dir="${OPTARG}" ;; w) work_dir="${OPTARG}" ;; o) out_dir="${OPTARG}" ;; + s) sfs_mode="${OPTARG}" ;; c) sfs_comp="${OPTARG}" ;; v) quiet="n" ;; h|?) _usage 0 ;; -- cgit v1.2.3-70-g09d2