vitorpy's Dotfiles
at main 77 lines 2.5 kB view raw
1#!/bin/bash 2# Configure silent boot for Arch Linux 3# This script modifies systemd-boot entries for a clean, minimal boot experience 4 5set -e 6 7echo "==> Configuring silent boot..." 8 9# Silent boot kernel parameters 10SILENT_PARAMS="quiet loglevel=3 rd.systemd.show_status=auto rd.udev.log_level=3 vt.global_cursor_default=0 video=2256x1504" 11 12# Find all boot entries 13BOOT_ENTRIES=$(find /boot/loader/entries/ -name "*.conf" -type f) 14 15if [ -z "$BOOT_ENTRIES" ]; then 16 echo "ERROR: No boot entries found in /boot/loader/entries/" 17 exit 1 18fi 19 20# Process each boot entry 21for entry in $BOOT_ENTRIES; do 22 echo " - Processing: $(basename "$entry")" 23 24 # Check if silent boot params are already present 25 if grep -q "quiet loglevel=3" "$entry"; then 26 echo " Already configured for silent boot, skipping" 27 continue 28 fi 29 30 # Backup original entry 31 sudo cp "$entry" "$entry.bak" 32 33 # Add silent boot parameters to options line 34 sudo sed -i "s/^options /options $SILENT_PARAMS /" "$entry" 35 36 echo " ✓ Added silent boot parameters" 37done 38 39# Create /etc/kernel/cmdline for persistent kernel parameters 40echo "==> Creating /etc/kernel/cmdline for persistent configuration..." 41 42# Get current root parameters from existing boot entry 43FIRST_ENTRY=$(echo "$BOOT_ENTRIES" | head -1) 44ROOT_PARAMS=$(grep "^options" "$FIRST_ENTRY" | sed 's/^options //' | sed "s/$SILENT_PARAMS //") 45 46# Create /etc/kernel/cmdline with silent boot params + root params 47echo "$SILENT_PARAMS $ROOT_PARAMS" | sudo tee /etc/kernel/cmdline > /dev/null 48 49echo " ✓ Created /etc/kernel/cmdline (will persist across kernel upgrades)" 50 51# Configure systemd to hide boot messages 52echo "==> Configuring systemd for minimal output..." 53 54# Create systemd system.conf.d directory if it doesn't exist 55sudo mkdir -p /etc/systemd/system.conf.d 56 57# Create silent boot configuration 58sudo tee /etc/systemd/system.conf.d/silent-boot.conf > /dev/null <<'EOF' 59[Manager] 60# Silent boot configuration 61ShowStatus=error 62DefaultStandardOutput=journal 63EOF 64 65echo " ✓ Created /etc/systemd/system.conf.d/silent-boot.conf" 66 67echo "" 68echo "==> Silent boot configured successfully!" 69echo "" 70echo "Changes made:" 71echo " - Added kernel parameters for quiet boot" 72echo " - Created /etc/kernel/cmdline for persistent configuration" 73echo " - Configured systemd to show only errors" 74echo " - Backup files created with .bak extension" 75echo "" 76echo "These settings will survive kernel upgrades." 77echo "Reboot to see the changes take effect."