68 lines
2.7 KiB
Bash
68 lines
2.7 KiB
Bash
#!/usr/bin/env bash
|
|
# Rollback optimization changes
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
source "$SCRIPT_DIR/../../lib/common.sh"
|
|
|
|
GRUB_FILE="/etc/default/grub"
|
|
BACKUP_DIR="$(data_dir backups)"
|
|
|
|
log_header "Rollback Optimizations"
|
|
|
|
# ── 1. GRUB rollback ────────────────────────────────────
|
|
log_info "GRUB backups:"
|
|
mapfile -t grub_backups < <(find "$BACKUP_DIR" -name 'grub-*.bak' -print 2>/dev/null | sort -r)
|
|
|
|
if (( ${#grub_backups[@]} == 0 )); then
|
|
log_info " No GRUB backups found"
|
|
else
|
|
for i in "${!grub_backups[@]}"; do
|
|
printf " [%d] %s\n" "$i" "${grub_backups[$i]}"
|
|
done
|
|
echo ""
|
|
|
|
if confirm "Restore most recent GRUB backup?"; then
|
|
require_root
|
|
backup="${grub_backups[0]}"
|
|
cp "$backup" "$GRUB_FILE"
|
|
log_success "GRUB restored from: $backup"
|
|
|
|
log_info "Regenerating boot configuration..."
|
|
if is_cmd grubby; then
|
|
# On BLS systems, also need to remove args via grubby
|
|
grubby --update-kernel=ALL --remove-args="iommu amdgpu.gttsize ttm.pages_limit" 2>/dev/null || true
|
|
log_success "Boot entries updated via grubby"
|
|
elif [[ -d /boot/grub2 ]]; then
|
|
grub2-mkconfig -o /boot/grub2/grub.cfg
|
|
log_success "GRUB regenerated via grub2-mkconfig"
|
|
elif [[ -d /boot/grub ]]; then
|
|
grub-mkconfig -o /boot/grub/grub.cfg
|
|
log_success "GRUB regenerated via grub-mkconfig"
|
|
else
|
|
log_error "Could not find grubby or grub config directory. Regenerate manually."
|
|
fi
|
|
log_warn "Reboot required for changes to take effect."
|
|
fi
|
|
fi
|
|
|
|
# ── 2. Tuned profile rollback ───────────────────────────
|
|
prev_profile_file="$BACKUP_DIR/tuned-previous-profile.txt"
|
|
if [[ -f "$prev_profile_file" ]]; then
|
|
prev_profile="$(cat "$prev_profile_file")"
|
|
current="$(tuned-adm active 2>/dev/null | sed 's/Current active profile: //' || echo "unknown")"
|
|
log_info "Tuned profile: $current (previous: $prev_profile)"
|
|
|
|
if [[ "$current" != "$prev_profile" ]] && confirm "Restore tuned profile to $prev_profile?"; then
|
|
sudo tuned-adm profile "$prev_profile"
|
|
log_success "Tuned profile restored to: $prev_profile"
|
|
fi
|
|
else
|
|
log_info "No previous tuned profile saved"
|
|
fi
|
|
|
|
# ── 3. BIOS reminder ────────────────────────────────────
|
|
echo ""
|
|
log_warn "BIOS VRAM changes cannot be rolled back automatically."
|
|
log_info "To revert: Reboot → F10 → Advanced → UMA Frame Buffer Size → restore previous value"
|