Arch Linux 安装 Xorg GNOME

先查看显卡信息

[berly@archlinux ~]$ lspci | grep VGA
00:02.0 VGA compatible controller: Intel Corporation UHD Graphics 630 (Desktop)
01:00.0 VGA compatible controller: NVIDIA Corporation GP107M [GeForce GTX 1050 Ti Mobile] (rev a1)

安装Intel驱动

sudo pacman -S xf86-video-intel mesa

安装Nvidia驱动

sudo pacman -S nvidia nvidia-lts nvidia-utils

如图修改相关文件

使用nvidia-xconfig生成xorg.conf文件,修改其中的Module、Files、Device、Screen配置,Device中要写入busid,screen的device修改成nvidia

  GNU nano 4.2                                                /etc/X11/xorg.conf                                                           
# nvidia-xconfig: X configuration file generated by nvidia-xconfig
# nvidia-xconfig:  version 430.14


Section "ServerLayout"
    Identifier     "Layout0"
    Screen      0  "Screen0" 0 0
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"
EndSection

Section "Module"
    Load "modesetting"
EndSection

Section "Files"
    ModulePath     "/usr/lib/xorg/modules"
EndSection

Section "InputDevice"

    # generated from default
    Identifier     "Mouse0"
    Driver         "mouse"
    Option         "Protocol" "auto"
    Option         "Device" "/dev/psaux"
    Option         "Emulate3Buttons" "no"
    Option         "ZAxisMapping" "4 5"
EndSection

Section "InputDevice"

    # generated from default
    Identifier     "Keyboard0"
    Driver         "kbd"
EndSection

Section "Monitor"
    Identifier     "Monitor0"
    VendorName     "Unknown"
    ModelName      "Unknown"
    Option         "DPMS"
EndSection

Section "Device"
    Identifier     "nvidia"
    Driver         "nvidia"
    BusID          "PCI:1:0:0"
    Option         "AllowEmptyInitialConfiguration"
    VendorName     "NVIDIA Corporation"
EndSection

Section "Screen"
    Identifier     "Screen0"
    Device         "nvidia"
    Monitor        "Monitor0"
    DefaultDepth    24
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection

GNU nano 4.2                                        /etc/X11/xorg.conf.d/20-nvidia.conf                                                  
Section "Device"
    Identifier "Nvidia Card"
    Driver "nvidia"
    VendorName "NVIDIA Corporation"
    BoardName "GeForce GTX 1050 Ti"
EndSection
GNU nano 4.2                                               /etc/mkinitcpio.conf                                                          

MODULES=(i915 nvidia nvidia_modeset nvidia_uvm nvidia_drm)

安装Xorg(图形界面)、GNOME、GDM

sudo pacman -S xorg-server xorg-xinit xorg-apps 
sudo pacman -S gnome gnome-extra
sudo pacman -S gdm

systemctl enable gdm.service

为普通用户复制一份xinitrc,不过我发现当使用startx时,会死机卡住,有时还会出现黑屏,只有一个光标在闪。

如果出错,可以查看 /var/log/Xorg.0.log,也有可能不是Xorg.0.log,具体问题具体分析

我的log文件没有出错信息,但确实无法打开,停留在加载的信息上,提示xclock xterm command not found

找了很久,最后解决方法:

先备份 cp /etc/X11/xinit/xinitrc  /etc/X11/xinit/xinitrc.bak

再修改xinitrc文件

GNU nano 4.2                                               /etc/X11/xinit/xinitrc                                                          
#!/bin/sh

#xrandr --setprovideroutputsource modesetting NVIDIA-0
#xrandr --auto

userresources=$HOME/.Xresources
usermodmap=$HOME/.Xmodmap
sysresources=/etc/X11/xinit/.Xresources
sysmodmap=/etc/X11/xinit/.Xmodmap

# merge in defaults and keymaps

if [ -f $sysresources ]; then

    xrdb -merge $sysresources

fi

if [ -f $sysmodmap ]; then
    xmodmap $sysmodmap
fi

if [ -f "$userresources" ]; then

    xrdb -merge "$userresources"

fi

if [ -f "$usermodmap" ]; then
    xmodmap "$usermodmap"
fi

# start some nice programs

if [ -d /etc/X11/xinit/xinitrc.d ] ; then
 for f in /etc/X11/xinit/xinitrc.d/?*.sh ; do
  [ -x "$f" ] && . "$f"
 done
 unset f
fi

#twm & xclock -geometry 50x50-1+1 & xterm -geometry 80x50+494+51 & xterm -geometry 80x20+494-0 & exec xterm -geometry 80x66+0+0 -name login
export GDK_BACKEND=x11
exec gnome-session

 

你可能感兴趣的:(archlinux)