Remove overlay filesystem functionality and add detection/removal capability
- Remove unused overlay filesystem configuration and references - Remove overlayfs sections from all profile JSON files - Remove OVERLAY_ENABLED/OVERLAY_PROTECT_CONFIGS from config - Update documentation to focus on tmpfs optimization - Add overlay detection and removal functionality for cleanup - Add remove_overlays() function with safe unmounting - Add overlay status reporting in final optimization summary - Add test-overlay-detection.sh for testing detection logic - Simplify codebase by removing complex unused features - Focus on proven desktop optimizations (tmpfs, zram, kernel)
This commit is contained in:
@@ -113,6 +113,31 @@ analyze_and_prompt() {
|
||||
echo " 🔍 Scanning system for cache directories..."
|
||||
fi
|
||||
|
||||
# === OVERLAY FILESYSTEM CHECK ===
|
||||
echo "🗂️ Overlay Filesystem Analysis:"
|
||||
local overlay_count=$(mount -t overlay | wc -l)
|
||||
if [[ $overlay_count -gt 0 ]]; then
|
||||
echo " ⚠️ Found $overlay_count overlay mounts (deprecated for desktop use)"
|
||||
echo " 📁 Current overlay mounts:"
|
||||
mount -t overlay | head -3 | awk '{print " " $3 " (overlay)"}'
|
||||
[[ $overlay_count -gt 3 ]] && echo " ... and $((overlay_count - 3)) more"
|
||||
echo ""
|
||||
echo " 💡 Overlays are complex and rarely needed on desktop systems."
|
||||
echo " 💡 Consider removing them unless specifically required."
|
||||
needs_changes=true
|
||||
read -p " Would you like to remove overlay mounts? (y/N): " -n 1 -r
|
||||
echo
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
REMOVE_OVERLAYS=true
|
||||
else
|
||||
REMOVE_OVERLAYS=false
|
||||
fi
|
||||
else
|
||||
echo " ✅ No overlay mounts found (good - not needed for desktop)"
|
||||
REMOVE_OVERLAYS=false
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# Always analyze potential tmpfs candidates (even if already configured)
|
||||
local cache_analysis=""
|
||||
local total_cache_size=0
|
||||
@@ -225,7 +250,7 @@ analyze_and_prompt() {
|
||||
if [[ -d /var/lib/flatpak ]]; then
|
||||
local flatpak_size=$(du -sm /var/lib/flatpak 2>/dev/null | cut -f1 || echo 0)
|
||||
if [[ $flatpak_size -gt 1000 ]]; then
|
||||
additional_opportunities="${additional_opportunities} Flatpak apps: ${flatpak_size}MB (consider overlayfs)\n"
|
||||
additional_opportunities="${additional_opportunities} Flatpak apps: ${flatpak_size}MB (consider tmpfs for .cache)\n"
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -535,6 +560,7 @@ analyze_and_prompt() {
|
||||
[[ $SETUP_TMPFS == true ]] && actions+=("tmpfs")
|
||||
[[ $SETUP_KERNEL == true ]] && actions+=("kernel")
|
||||
[[ $SETUP_SERVICE == true ]] && actions+=("service")
|
||||
[[ $REMOVE_OVERLAYS == true ]] && actions+=("remove-overlays")
|
||||
|
||||
if [[ ${#actions[@]} -gt 0 ]]; then
|
||||
echo "📋 Selected optimizations: ${actions[*]}"
|
||||
@@ -551,7 +577,7 @@ analyze_and_prompt() {
|
||||
fi
|
||||
|
||||
# Export variables for the optimization functions
|
||||
export SETUP_ZRAM SETUP_TMPFS SETUP_KERNEL SETUP_SERVICE
|
||||
export SETUP_ZRAM SETUP_TMPFS SETUP_KERNEL SETUP_SERVICE REMOVE_OVERLAYS
|
||||
export SYSTEM_RAM_GB=$ram_gb
|
||||
}
|
||||
|
||||
@@ -612,6 +638,58 @@ setup_zram() {
|
||||
success "zram reconfigured with ${zram_size}GB"
|
||||
}
|
||||
|
||||
remove_overlays() {
|
||||
if [[ $REMOVE_OVERLAYS != true ]]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
log "Removing overlay filesystem mounts..."
|
||||
|
||||
# Get list of overlay mounts
|
||||
local overlay_mounts=$(mount -t overlay | awk '{print $3}')
|
||||
|
||||
if [[ -z "$overlay_mounts" ]]; then
|
||||
log "No overlay mounts found to remove"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Unmount each overlay
|
||||
echo "$overlay_mounts" | while read -r mount_point; do
|
||||
if [[ -n "$mount_point" ]]; then
|
||||
log " Unmounting overlay: $mount_point"
|
||||
if umount "$mount_point" 2>/dev/null; then
|
||||
success " Successfully unmounted: $mount_point"
|
||||
|
||||
# Clean up overlay work directories if they exist in /tmp
|
||||
local work_dir="/tmp/overlay-work$(basename "$mount_point")"
|
||||
local upper_dir="/tmp/overlay-upper$(basename "$mount_point")"
|
||||
|
||||
if [[ -d "$work_dir" ]]; then
|
||||
rm -rf "$work_dir"
|
||||
log " Cleaned up work directory: $work_dir"
|
||||
fi
|
||||
|
||||
if [[ -d "$upper_dir" ]]; then
|
||||
rm -rf "$upper_dir"
|
||||
log " Cleaned up upper directory: $upper_dir"
|
||||
fi
|
||||
else
|
||||
warn " Failed to unmount: $mount_point (may be in use)"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# Remove any overlay entries from fstab
|
||||
if [[ -f /etc/fstab ]] && grep -q "overlay" /etc/fstab; then
|
||||
log "Removing overlay entries from /etc/fstab..."
|
||||
cp /etc/fstab /etc/fstab.backup.$(date +%s)
|
||||
grep -v "overlay" /etc/fstab > /etc/fstab.tmp && mv /etc/fstab.tmp /etc/fstab
|
||||
success "Removed overlay entries from /etc/fstab"
|
||||
fi
|
||||
|
||||
success "Overlay filesystem cleanup completed"
|
||||
}
|
||||
|
||||
setup_tmpfs() {
|
||||
if [[ $SETUP_TMPFS != true ]]; then
|
||||
return 0
|
||||
@@ -934,6 +1012,14 @@ show_final_status() {
|
||||
echo " 📊 Total tmpfs allocated: ${total_mb}MB"
|
||||
fi
|
||||
|
||||
# overlay status
|
||||
local overlay_count=$(mount -t overlay | wc -l)
|
||||
if [[ $overlay_count -eq 0 ]]; then
|
||||
echo " 🗂️ overlays: None (optimal for desktop systems)"
|
||||
else
|
||||
echo " ⚠️ overlays: $overlay_count mounts found (consider removal)"
|
||||
fi
|
||||
|
||||
# kernel with current values
|
||||
if [[ -f /etc/sysctl.d/99-system-optimization.conf ]]; then
|
||||
local swappiness=$(sysctl -n vm.swappiness 2>/dev/null)
|
||||
@@ -986,6 +1072,7 @@ main() {
|
||||
analyze_and_prompt
|
||||
|
||||
# Apply selected optimizations
|
||||
remove_overlays
|
||||
setup_zram
|
||||
setup_tmpfs
|
||||
tune_kernel
|
||||
|
||||
Reference in New Issue
Block a user