diff --git a/usr/share/rear/layout/prepare/default/320_apply_mappings.sh b/usr/share/rear/layout/prepare/default/320_apply_mappings.sh index 1a3e212813..ebb9cd774c 100644 --- a/usr/share/rear/layout/prepare/default/320_apply_mappings.sh +++ b/usr/share/rear/layout/prepare/default/320_apply_mappings.sh @@ -17,8 +17,12 @@ for file_to_migrate in "$LAYOUT_FILE" "$original_disk_space_usage_file" "$rescue if apply_layout_mappings "$file_to_migrate" ; then DebugPrint "Applied disk layout mappings to $file_to_migrate" else - LogPrintError "Failed to apply disk layout mappings to $file_to_migrate" - applied_mappings_to_all_files="no" + if [ "$file_to_migrate" = "$original_disk_space_usage_file" ] ; then + LogPrint "WARNING: Failed to apply disk layout mappings to $file_to_migrate (likely due to unmapped excluded disks)." + else + LogPrintError "Failed to apply disk layout mappings to $file_to_migrate" + applied_mappings_to_all_files="no" + fi fi done is_true $applied_mappings_to_all_files || Error "Failed to apply disk layout mappings" diff --git a/usr/share/rear/layout/save/GNU/Linux/510_current_disk_usage.sh b/usr/share/rear/layout/save/GNU/Linux/510_current_disk_usage.sh index 319f8db9e4..b672313b77 100644 --- a/usr/share/rear/layout/save/GNU/Linux/510_current_disk_usage.sh +++ b/usr/share/rear/layout/save/GNU/Linux/510_current_disk_usage.sh @@ -24,3 +24,20 @@ else df -Pl -BM -x encfs -x tmpfs -x devtmpfs >$original_disk_space_usage_file fi +# Automatically comment out lines in original_disk_space_usage_file that match AUTOEXCLUDE_PATH +if test "$AUTOEXCLUDE_PATH" ; then + for exclude in "${AUTOEXCLUDE_PATH[@]}" ; do + while read -r _ _ _ _ _ mountpoint ; do + # Check if mountpoint is a subdirectory of the exclude path + # Logic matching layout/save/default/320_autoexclude.sh: + if test "${mountpoint#${exclude%/}/}" != "$mountpoint" ; then + DebugPrint "Automatically excluding $mountpoint from $original_disk_space_usage_file (belongs to $exclude in AUTOEXCLUDE_PATH)" + local escaped_mp + # Escape the mountpoint for use in the subsequent sed command + escaped_mp=$( echo "$mountpoint" | sed 's/[][\/$*.^]/\\&/g' ) + # Comment out the line + sed -i "/ $escaped_mp$/s/^/#/" "$original_disk_space_usage_file" + fi + done < <( grep -v -E "^Filesystem|^#" "$original_disk_space_usage_file" ) + done +fi