4 require_binaries mksquashfs unsquashfs ||
return 1
6 for i
in CONFIG_SQUASHFS CONFIG_BLK_DEV_LOOP CONFIG_OVERLAY_FS
; do
7 if ! check_kernel_config
$i; then
8 dinfo
"dracut-squash module requires kernel configuration $i (y or m)"
22 hostonly
="" instmods squashfs loop overlay
26 local squash_candidate
=( "usr" "etc" )
28 # shellcheck disable=SC2174
29 mkdir
-m 0755 -p "$squash_dir"
30 for folder
in "${squash_candidate[@]}"; do
31 mv "$initdir/$folder" "$squash_dir/$folder"
34 # Move some files out side of the squash image, including:
35 # - Files required to boot and mount the squashfs image
36 # - Files need to be accessible without mounting the squash image
39 "$squash_dir"/usr
/lib
/modules
/*/modules.
* \
40 "$squash_dir"/usr
/lib
/dracut
/* \
41 "$squash_dir"/etc
/initrd-release
43 [[ -f $file ]] ||
continue
44 DRACUT_RESOLVE_DEPS
=1 dracutsysrootdir
="$squash_dir" inst
"${file#$squash_dir}"
48 # Install required files for the squash image setup script.
49 hostonly
="" instmods
"loop" "squashfs" "overlay"
50 inst_multiple modprobe mount mkdir
ln echo
52 mv "$initdir"/init
"$initdir"/init.orig
53 inst
"$moddir"/init-squash.sh
/init
54 inst
"$moddir"/clear-squash.sh
/squash
/clear-squash.sh
56 # Keep systemctl outsite if we need switch root
57 if [[ ! -f "$initdir/lib/dracut/no-switch-root" ]]; then
61 # Remove duplicated files
62 for folder
in "${squash_candidate[@]}"; do
63 find "$initdir/$folder/" -not -type d \
64 -exec bash
-c 'mv -f "$squash_dir${1#$initdir}" "$1"' -- "{}" \
;
69 if [[ $DRACUT_SQUASH_POST_INST ]]; then
74 inst
"$moddir/squash-mnt-clear.service" "$systemdsystemunitdir/squash-mnt-clear.service"
75 $SYSTEMCTL -q --root "$initdir" add-wants initrd-switch-root.target squash-mnt-clear.service