Changing GPU drivers on a Linux system after boot but before startx (i.e., in a non-graphical environment) without rebooting is possible but requires careful handling. Here’s how you can do it:
Steps to Change GPU Drivers Without Rebooting
-
Stop the Display Manager (if running)
If you're in a terminal (e.g., via Ctrl+Alt+F2), ensure no X server is running:
sudo systemctl stop display-manager # Replace with your DM (e.g., gdm, lightdm, sddm)
-
Unload the Current GPU Driver
Identify the loaded GPU driver module:
lsmod | grep -E 'nvidia|amdgpu|radeon|nouveau|i915'
Then unload it:
sudo rmmod nvidia_drm nvidia_modeset nvidia # Example for NVIDIA
sudo rmmod amdgpu radeon nouveau i915 # Example for AMD/Intel
-
Load the New GPU Driver
Load the new driver module:
sudo modprobe nouveau # Example: Switching to Nouveau
sudo modprobe nvidia # Example: Switching to NVIDIA
-
Reconfigure the X Server (if needed)
If you're using a custom xorg.conf, ensure it matches the new driver:
sudo nvidia-xconfig # For NVIDIA (if installed)
Or manually edit /etc/X11/xorg.conf.
-
Restart the Display Manager (Optional)
If you need to test the new driver before startx:
sudo systemctl start display-manager
(But since you want to avoid rebooting, you can proceed to startx manually.)
-
Start X Manually
Run:
startx
If it fails, check logs in /var/log/Xorg.0.log.
Alternative: Use init 3 and init 5 (If Using SysVinit)
If your system uses SysVinit (older systems), you can switch runlevels:
sudo init 3 # Switch to multi-user (text mode)
# Change drivers as above
sudo init 5 # Switch back to graphical mode
Important Notes
- Kernel Mode Setting (KMS): Some drivers (like
amdgpu or i915) are loaded early in boot. You may need to disable KMS in the kernel command line (nomodeset) if switching drivers dynamically fails.
- NVIDIA Proprietary Drivers: These often require a reboot due to deep kernel integration. Switching between
nouveau and nvidia may not work cleanly without a reboot.
- Fallback Option: If
startx fails, you may need to reboot to recover.
Best Practice
If possible, use a live USB or chroot environment to test driver changes before applying them to your main system. Some driver changes (especially NVIDIA) are safer with a full reboot.
Would you like help with a specific driver (NVIDIA, AMD, Intel)? Let me know!