Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> Linux 教學

Ubuntu Linux NVIDIA 顯卡驅動安裝與解析度問題徹底解決:nvidia-settings 與 xorg.conf 手動修正

編輯:Linux 教學

前言

Ubuntu 安裝 NVIDIA 專有驅動後,常面臨「系統顯示設定無高解析度選項」、「重啟後解析度重置」等問題。本文記錄從 nvidia-settings 圖形配置到手動編輯 /etc/X11/xorg.conf 永久固定解析度 (以 1440x900 為例) 的完整解決路徑。

一、問題現象

  • 系統 → 偏好設定 → 螢幕解析度:最高僅 1280x1024,缺少原生 1440x900 (寬螢幕)。
  • 已安裝 nvidia-glx/nvidia-driver 但無法生效。
  • 用 nvidia-settings 臨時調整為 1440x900 後,重啟 X 又恢復 1280x1024。

二、階段性解決:nvidia-settings 臨時調整

# 終端執行 (需圖形環境)
sudo nvidia-settings
  1. 左側選單選 X Server Display Configuration。
  2. 解析度下拉選單選 1440x900 (若列表有)。
  3. 點 Apply → 確認畫面正常 → Save to X Configuration File。
  4. 此步驟會嘗試寫入 /etc/X11/xorg.conf,但權限/格式問題常導致寫入失敗或重啟失效。

三、根治方案:手動編輯 xorg.conf 固定 ModeLine 順序

1. 備份原配置

sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.backup

2. 編輯配置檔

sudo gedit /etc/X11/xorg.conf

3. 定位 Screen 區塊,調整所有 Display 子區塊的 Modes 順序

核心原理:X Server 依序嘗試 Modes 列表中的解析度,採用「螢幕支援的第一個」。若首項為不支援的解析度 (如 1440x1440),會 fallback 到次項 (1280x1024)。

修改策略:將目標解析度 1440x900 移至每個 Depth 子區塊 Modes 列表首位。

Section "Screen"
    Identifier     "Default Screen"
    Device         "nVidia Corporation GeForce 7300 SE"
    Monitor        "LAW982"
    DefaultDepth   24
    Option         "AddARGBVisuals" "True"
    Option         "AddARGBGLXVisuals" "True"
    Option         "NoLogo" "True"
    SubSection "Display"
        Depth     1
        Modes    "1440x900" "1280x1024" "1280x960" "1152x864" "1024x768" "832x624" "800x600" "720x400" "640x480"
    EndSubSection
    SubSection "Display"
        Depth     4
        Modes    "1440x900" "1280x1024" "1280x960" "1152x864" "1024x768" "832x624" "800x600" "720x400" "640x480"
    EndSubSection
    SubSection "Display"
        Depth     8
        Modes    "1440x900" "1280x1024" "1280x960" "1152x864" "1024x768" "832x624" "800x600" "720x400" "640x480"
    EndSubSection
    SubSection "Display"
        Depth     15
        Modes    "1440x900" "1280x1024" "1280x960" "1152x864" "1024x768" "832x624" "800x600" "720x400" "640x480"
    EndSubSection
    SubSection "Display"
        Depth     16
        Modes    "1440x900" "1280x1024" "1280x960" "1152x864" "1024x768" "832x624" "800x600" "720x400" "640x480"
    EndSubSection
    SubSection "Display"
        Depth     24
        Modes    "1440x900" "1280x1024" "1280x960" "1152x864" "1024x768" "832x624" "800x600" "720x400" "640x480"
    EndSubSection
EndSection

4. 重啟 X 驗證

# 方案 A: 重啟顯示管理器 (GDM/LightDM)
sudo service gdm restart
# 或
sudo systemctl restart lightdm

# 方案 B: 重啟系統
sudo reboot

登入畫面即為 1440x900,桌面進入後系統顯示設定亦顯示當前解析度 1440x900。

四、進階優化:關閉 NVIDIA 啟動 Logo

在 Section "Device" 加入:

Option "NoLogo" "True"

完整片段:

Section "Device"
    Identifier     "nVidia Corporation GeForce 7300 SE"
    Driver         "nvidia"
    Option         "NoLogo" "True"
EndSection

五、現代系統 (Ubuntu 16.04+) 補充說明

  • Wayland 會話:NVIDIA 專有驅動在 Wayland 下相容性較差,登入畫面選擇 GNOME on Xorg 會話。
  • 無 xorg.conf 時代:新版 Xorg 自動偵測,無需手寫配置。若需自定,建議在 /etc/X11/xorg.conf.d/ 建立片段檔 (如 10-monitor.conf) 而非完整 xorg.conf。
  • 動態模式 (RandR 1.2+):xrandr --output HDMI-0 --mode 1440x900 --rate 60 可熱插拔切換,無需重啟 X。
  • DRM KMS:核心模式設定 (Kernel Mode Setting) 接管模式列表,xorg.conf Modes 僅作備選參考。

六、故障排查清單

現象檢查項目
修改後進入黑屏/低解析度1. cat /var/log/Xorg.0.log | grep -i mode 查看實際採用模式
2. 確認 Monitor 區塊 HorizSync/VertRefresh 範圍涵蓋目標解析度
3. 恢復備份 cp xorg.conf.backup xorg.conf
nvidia-settings 無法儲存以 root 執行 sudo nvidia-settings,或手動編輯 xorg.conf
雙螢幕解析度錯亂在 Device 區塊加入 Option "DynamicTwinView" "False" 禁用動態雙顯示
驅動版本與核心不匹配 (DKMS 失敗)重新安裝 linux-headers-$(uname -r) 並 dkms autoinstall

結語

NVIDIA 驅動下解析度問題本質是 X Server 模式選擇邏輯與螢幕 EDID 偵測不匹配。手動編輯 xorg.conf 將目標解析度置於所有 Modes 列表首位,從根源上強制 X Server 採用期望模式。現代系統雖推薦無配置檔自動偵測,但理解 Modes 優先序機制對排查疑難雜症仍具核心價值。

Copyright © Windows教程網 All Rights Reserved