...
This commit is contained in:
@@ -147,109 +147,108 @@ log "Created installimage configuration at /autosetup"
|
||||
# Create autosetup directory for additional scripts
|
||||
mkdir -p /autosetup_scripts
|
||||
|
||||
# Create post-installation script for btrfs optimization
|
||||
cat > /autosetup_scripts/post_install.sh << 'EOF'
|
||||
#!/bin/bash
|
||||
# # Create post-installation script for btrfs optimization
|
||||
# cat > /autosetup_scripts/post_install.sh << 'EOF'
|
||||
# #!/bin/bash
|
||||
|
||||
# Post-installation script for btrfs optimization
|
||||
# # Post-installation script for btrfs optimization
|
||||
|
||||
log() {
|
||||
echo "[$(date +'%Y-%m-%d %H:%M:%S')] $1"
|
||||
}
|
||||
# log() {
|
||||
# echo "[$(date +'%Y-%m-%d %H:%M:%S')] $1"
|
||||
# }
|
||||
|
||||
log "Starting post-installation btrfs optimization..."
|
||||
# log "Starting post-installation btrfs optimization..."
|
||||
|
||||
# Install btrfs-progs if not already installed
|
||||
if ! command -v btrfs &> /dev/null; then
|
||||
log "Installing btrfs-progs..."
|
||||
apt-get update
|
||||
apt-get install -y btrfs-progs
|
||||
fi
|
||||
# # Install btrfs-progs if not already installed
|
||||
# if ! command -v btrfs &> /dev/null; then
|
||||
# log "Installing btrfs-progs..."
|
||||
# apt-get update
|
||||
# apt-get install -y btrfs-progs
|
||||
# fi
|
||||
|
||||
# Set btrfs mount options for better performance and features
|
||||
log "Configuring btrfs mount options..."
|
||||
# # Set btrfs mount options for better performance and features
|
||||
# log "Configuring btrfs mount options..."
|
||||
|
||||
# Backup original fstab
|
||||
cp /etc/fstab /etc/fstab.backup
|
||||
# # Backup original fstab
|
||||
# cp /etc/fstab /etc/fstab.backup
|
||||
|
||||
# Update fstab with optimized btrfs mount options
|
||||
sed -i 's/btrfs\s\+defaults/btrfs defaults,noatime,compress=zstd:3,space_cache=v2,autodefrag/' /etc/fstab
|
||||
# # Update fstab with optimized btrfs mount options
|
||||
# sed -i 's/btrfs\s\+defaults/btrfs defaults,noatime,compress=zstd:3,space_cache=v2,autodefrag/' /etc/fstab
|
||||
|
||||
# Create btrfs maintenance scripts
|
||||
mkdir -p /etc/cron.weekly
|
||||
# # Create btrfs maintenance scripts
|
||||
# mkdir -p /etc/cron.weekly
|
||||
|
||||
# Weekly balance script
|
||||
cat > /etc/cron.weekly/btrfs-balance << 'BALANCE_EOF'
|
||||
#!/bin/bash
|
||||
# Weekly btrfs balance to optimize space usage
|
||||
/usr/bin/btrfs balance start -dusage=50 -musage=50 / 2>/dev/null || true
|
||||
BALANCE_EOF
|
||||
# # Weekly balance script
|
||||
# cat > /etc/cron.weekly/btrfs-balance << 'BALANCE_EOF'
|
||||
# #!/bin/bash
|
||||
# # Weekly btrfs balance to optimize space usage
|
||||
# /usr/bin/btrfs balance start -dusage=50 -musage=50 / 2>/dev/null || true
|
||||
# BALANCE_EOF
|
||||
|
||||
chmod +x /etc/cron.weekly/btrfs-balance
|
||||
# chmod +x /etc/cron.weekly/btrfs-balance
|
||||
|
||||
# Weekly scrub script for data integrity
|
||||
cat > /etc/cron.weekly/btrfs-scrub << 'SCRUB_EOF'
|
||||
#!/bin/bash
|
||||
# Weekly btrfs scrub for data integrity check
|
||||
/usr/bin/btrfs scrub start / 2>/dev/null || true
|
||||
SCRUB_EOF
|
||||
# # Weekly scrub script for data integrity
|
||||
# cat > /etc/cron.weekly/btrfs-scrub << 'SCRUB_EOF'
|
||||
# #!/bin/bash
|
||||
# # Weekly btrfs scrub for data integrity check
|
||||
# /usr/bin/btrfs scrub start / 2>/dev/null || true
|
||||
# SCRUB_EOF
|
||||
|
||||
chmod +x /etc/cron.weekly/btrfs-scrub
|
||||
# chmod +x /etc/cron.weekly/btrfs-scrub
|
||||
|
||||
# Install and configure snapper for automatic snapshots
|
||||
log "Installing and configuring snapper for automatic snapshots..."
|
||||
apt-get install -y snapper
|
||||
# # Install and configure snapper for automatic snapshots
|
||||
# log "Installing and configuring snapper for automatic snapshots..."
|
||||
# apt-get install -y snapper
|
||||
|
||||
# Create snapper config for root
|
||||
snapper -c root create-config /
|
||||
# # Create snapper config for root
|
||||
# snapper -c root create-config /
|
||||
|
||||
# Configure snapper for reasonable snapshot retention
|
||||
snapper -c root set-config TIMELINE_CREATE=yes
|
||||
snapper -c root set-config TIMELINE_CLEANUP=yes
|
||||
snapper -c root set-config NUMBER_CLEANUP=yes
|
||||
snapper -c root set-config NUMBER_MIN_AGE=1800
|
||||
snapper -c root set-config NUMBER_LIMIT=50
|
||||
snapper -c root set-config NUMBER_LIMIT_IMPORTANT=10
|
||||
# # Configure snapper for reasonable snapshot retention
|
||||
# snapper -c root set-config TIMELINE_CREATE=yes
|
||||
# snapper -c root set-config TIMELINE_CLEANUP=yes
|
||||
# snapper -c root set-config NUMBER_CLEANUP=yes
|
||||
# snapper -c root set-config NUMBER_MIN_AGE=1800
|
||||
# snapper -c root set-config NUMBER_LIMIT=50
|
||||
# snapper -c root set-config NUMBER_LIMIT_IMPORTANT=10
|
||||
|
||||
# Enable snapper timer
|
||||
systemctl enable snapper-timeline.timer
|
||||
systemctl enable snapper-cleanup.timer
|
||||
# # Enable snapper timer
|
||||
# systemctl enable snapper-timeline.timer
|
||||
# systemctl enable snapper-cleanup.timer
|
||||
|
||||
log "Post-installation btrfs optimization completed"
|
||||
EOF
|
||||
# log "Post-installation btrfs optimization completed"
|
||||
# EOF
|
||||
|
||||
chmod +x /autosetup_scripts/post_install.sh
|
||||
# chmod +x /autosetup_scripts/post_install.sh
|
||||
|
||||
log "Created post-installation script at /autosetup_scripts/post_install.sh"
|
||||
# log "Created post-installation script at /autosetup_scripts/post_install.sh"
|
||||
|
||||
# Create a script to monitor RAID status
|
||||
cat > /autosetup_scripts/raid_monitor.sh << 'EOF'
|
||||
#!/bin/bash
|
||||
# # Create a script to monitor RAID status
|
||||
# cat > /autosetup_scripts/raid_monitor.sh << 'EOF'
|
||||
# #!/bin/bash
|
||||
|
||||
# RAID monitoring script for btrfs
|
||||
# # RAID monitoring script for btrfs
|
||||
|
||||
check_btrfs_raid() {
|
||||
echo "=== Btrfs RAID Status ==="
|
||||
btrfs filesystem show
|
||||
echo
|
||||
echo "=== Btrfs Device Stats ==="
|
||||
btrfs device stats /
|
||||
echo
|
||||
echo "=== Btrfs Filesystem Usage ==="
|
||||
btrfs filesystem usage /
|
||||
}
|
||||
# check_btrfs_raid() {
|
||||
# echo "=== Btrfs RAID Status ==="
|
||||
# btrfs filesystem show
|
||||
# echo
|
||||
# echo "=== Btrfs Device Stats ==="
|
||||
# btrfs device stats /
|
||||
# echo
|
||||
# echo "=== Btrfs Filesystem Usage ==="
|
||||
# btrfs filesystem usage /
|
||||
# }
|
||||
|
||||
# Check if btrfs tools are available
|
||||
if command -v btrfs &> /dev/null; then
|
||||
check_btrfs_raid
|
||||
else
|
||||
echo "btrfs-progs not installed. Install with: apt-get install btrfs-progs"
|
||||
fi
|
||||
EOF
|
||||
# # Check if btrfs tools are available
|
||||
# if command -v btrfs &> /dev/null; then
|
||||
# check_btrfs_raid
|
||||
# else
|
||||
# echo "btrfs-progs not installed. Install with: apt-get install btrfs-progs"
|
||||
# fi
|
||||
# EOF
|
||||
|
||||
chmod +x /autosetup_scripts/raid_monitor.sh
|
||||
|
||||
log "Created RAID monitoring script at /autosetup_scripts/raid_monitor.sh"
|
||||
# chmod +x /autosetup_scripts/raid_monitor.sh
|
||||
# log "Created RAID monitoring script at /autosetup_scripts/raid_monitor.sh"
|
||||
|
||||
# Verify configuration
|
||||
log "Verifying configuration..."
|
||||
@@ -284,4 +283,4 @@ else
|
||||
fi
|
||||
|
||||
log "Installation process completed."
|
||||
EOF
|
||||
|
||||
|
||||
Reference in New Issue
Block a user