Skip to Content

多重基座 X-Win 系統 (Multi-Seat X-Win System)

為了讓逸晨家中那群小天使能夠不再爭奪電腦的使用權,也為了讓那塵封已久的螢幕能有再見光明的日子,在歷經多日的文件搜尋,以及一年多的使用測試後,終於肯定了 multi-seat 的實用性 -- 當然,前提是得看該部主機的主要用途了。

名詞淺釋

  • seat -> 基座;席位。
    在這兒指的是︰一隻滑鼠、一式鍵盤、一部螢幕為一個基座。

需求

  • 內附一組以上 PCI 擴充槽的主機板 (視所需的基座而定)
  • 一片以上的 PCI 界面顯示卡 (視所需的基座而定)
  • 一片 AGP 或 PCI-E 界面的顯示卡 (視所使用的主機板而定,如為內建顯示晶片的主機板,可依情況自行決定。)
  • 兩部或以上的螢幕 (傳統式或液晶螢幕皆可,建議全為液晶螢幕較好,數量依所需的基座而定,最少需兩部螢幕)
  • 兩隻或以上的滑鼠及鍵盤 (視所需的基座而定,連接界面建議皆為 USB 較佳)
  • Xorg 6.9 或之後的 X-Win 版本


概要

    建立多重基座的操作系統環境,大至上由底下幾個步驟來完成︰

  • 安裝硬體
    將顯示卡、滑鼠、鍵盤、螢幕給安裝、連接到電腦主機
  • 安裝 Linux 作業系統
    若是對 Linux 系統不熟的話,建議採用 Ubuntu 這個發行版本。
  • 記錄相關的硬體配置
    主要是要記錄顯示卡以及採用 USB 界面的硬體,其在 Linux 中所分配到的控制資訊。
  • 修改 xorg.conf 設置
    將上個步驟中所記錄下的相關資訊寫入到 xorg.conf 中。
  • 修改 gdm.conf 設置
    修正 gdm.conf 的設置,以便啟動多重 Xserver。
  • 在整個過程中,較需注意的便是各硬體的控置資訊正確取得,我們將會利用 lspci 來取得顯示卡的控制資訊,以及讀取 /proc/bus/input/devices 檔案來取得滑鼠和鍵盤的控制資訊,這也是最重要的一部份,因為取得的資訊錯誤了,將會無法啟動 Xserver 或啟動了,但也凍結了系統的運作 (啊~~當機啦!)........

    安裝硬體

    這一部份相信各位都不會有什麼問題的,主要是在硬體的選購。

    安裝 Linux 作業系統

    記錄相關的硬體配置

    所有的硬體在系統中都會有它自已的一個代號,這樣才能夠辨明 CPU 所下的指令是要給哪個硬體。在此,我們就是要找出所有的顯示卡、滑鼠、鍵盤在系統中所對映的代號,這樣才能於下一個環節中,將正確的硬體代號寫入 xorg.conf 設置檔。
    因為顯示卡較簡單,所以先來找出所有顯示卡的對映代號來︰

    you@hostname:~$ lspci | grep VGA
    00:09.0 VGA compatible controller: nVidia Corporation NV34 [GeForce FX 5200] (rev a1)
    01:00.0 VGA compatible controller: nVidia Corporation NV34 [GeForce FX 5200] (rev a1)
    

    從上列的原始資料中可以看出,逸晨是使用兩片 GeForce FX 5200 來架構雙基座的作業環境,其中︰

    • 00:09.0 -> 這片顯示卡是 PCI 界面
    • 01:00.0 -> 這片顯卡是 AGP 界面

    接下來,讓我們先來看看主機中計有哪些輸入裝置的節點︰

    you@hostname:~$ ls /dev/input
    by-id  by-path  event0  event1  event2  event3  event4  event5  mice  mouse0  mouse1  mouse2  ts0  ts1  ts2
    you@hostname:~$ ls -l /dev/input/by-id
    總計 0
    lrwxrwxrwx 1 root root 9 2007-04-20 10:50 usb-04d9_1400-event-kbd -> ../event2
    lrwxrwxrwx 1 root root 9 2007-04-20 10:50 usb-04d9_1400-event-mouse -> ../event3
    lrwxrwxrwx 1 root root 9 2007-04-20 10:50 usb-04d9_1400-mouse -> ../mouse0
    lrwxrwxrwx 1 root root 9 2007-04-20 10:50 usb-Logitech_Logitech_USB_Optical_Mouse-event-mouse -> ../event4
    lrwxrwxrwx 1 root root 9 2007-04-20 10:50 usb-Logitech_Logitech_USB_Optical_Mouse-mouse -> ../mouse1
    you@hostname:~$ ls -l /dev/input/by-path
    總計 0
    lrwxrwxrwx 1 root root 9 2007-04-20 10:50 pci-0000:00:03.0-usb-0:1:1.0-event-kbd -> ../event2
    lrwxrwxrwx 1 root root 9 2007-04-20 10:50 pci-0000:00:03.0-usb-0:1:1.1-event-mouse -> ../event3
    lrwxrwxrwx 1 root root 9 2007-04-20 10:50 pci-0000:00:03.0-usb-0:1:1.1-mouse -> ../mouse0
    lrwxrwxrwx 1 root root 9 2007-04-20 10:50 pci-0000:00:03.1-usb-0:1:1.0-event-mouse -> ../event4
    lrwxrwxrwx 1 root root 9 2007-04-20 10:50 pci-0000:00:03.1-usb-0:1:1.0-mouse -> ../mouse1
    lrwxrwxrwx 1 root root 9 2007-04-20 10:50 platform-i8042-serio-0- -> ../mouse2
    lrwxrwxrwx 1 root root 9 2007-04-20 10:50 platform-i8042-serio-0-event- -> ../event5
    lrwxrwxrwx 1 root root 9 2007-04-20 10:50 platform-i8042-serio-1-event- -> ../event0
    lrwxrwxrwx 1 root root 9 2007-04-20 10:50 platform-pcspkr-event- -> ../event1
    

    嗯~
    大略看出些什麼來了,但似乎有些實際的裝置連線無法很肯定,所以我們接著查看實際運作的資料︰

    you@hostname:~$ less /proc/bus/input/devices
    I: Bus=0011 Vendor=0001 Product=0001 Version=ab41
    N: Name="AT Translated Set 2 keyboard"
    P: Phys=isa0060/serio0/input0
    S: Sysfs=/class/input/input0
    H: Handlers=kbd event0 
    B: EV=120013
    B: KEY=4 2000000 3802078 f840d001 f2ffffdf ffefffff ffffffff fffffffe
    B: MSC=10
    B: LED=7
    
    I: Bus=0010 Vendor=001f Product=0001 Version=0100
    N: Name="PC Speaker"
    P: Phys=isa0061/input0
    S: Sysfs=/class/input/input1
    H: Handlers=kbd event1 
    B: EV=40001
    B: SND=6
    
    I: Bus=0003 Vendor=04d9 Product=1400 Version=0142
    N: Name="HID 04d9:1400"
    P: Phys=usb-0000:00:03.0-1/input0
    S: Sysfs=/class/input/input2
    H: Handlers=kbd event2 
    B: EV=120003
    B: KEY=10000 7 ff87207a c14057ff febeffdf ffefffff ffffffff fffffffe
    B: LED=7
    
    I: Bus=0003 Vendor=04d9 Product=1400 Version=0142
    N: Name="HID 04d9:1400"
    P: Phys=usb-0000:00:03.0-1/input1
    S: Sysfs=/class/input/input3
    H: Handlers=kbd mouse0 event3 ts0 
    B: EV=7
    B: KEY=1f0000 0 0 39fa d801d101 1e0000 0 0 0
    B: REL=103
    
    I: Bus=0003 Vendor=046d Product=c018 Version=4300
    N: Name="Logitech Logitech USB Optical Mouse"
    P: Phys=usb-0000:00:03.1-1/input0
    S: Sysfs=/class/input/input4
    H: Handlers=mouse1 event4 ts1 
    B: EV=7
    B: KEY=70000 0 0 0 0 0 0 0 0
    B: REL=103
    
    I: Bus=0011 Vendor=0002 Product=0006 Version=0056
    N: Name="ImExPS/2 Logitech Wheel Mouse"
    P: Phys=isa0060/serio1/input0
    S: Sysfs=/class/input/input5
    H: Handlers=mouse2 event5 ts2 
    B: EV=7
    B: KEY=1f0000 0 0 0 0 0 0 0 0
    B: REL=103
    

    從上述所查詢到的資料,我們可以得到底下的記錄表格︰

    Seat NO: VGA Card BusID Keyboard Device (/dev/input) Mouse Device (/dev/input)
    0 00:09:00 event2 mouse1
    1 01:00:00 event0 mouse2

    修改 xorg.conf 設置

    在 xorg.conf 中,是可以利用不同的 layout 來使用不同的裝置,我們就是利用這個特性來達到不同的基座使用不同的硬體配置︰

    Section "InputDevice"
        Identifier     "Keyboard0"
        Driver         "evdev"
        Option	   "Name" "HID 04d9:1400"
        Option	   "Phys" "usb-*/input0"
        Option	   "Device" "/dev/input/event2"
    EndSection
    Section "InputDevice"
        Identifier     "Keyboard1"
        Driver         "evdev"
        Option	   "Phys" "isa0060/serio0/input0"
        Option	   "Device" "/dev/input/event0"
    EndSection
    
    Section "InputDevice"
        Identifier     "Mouse0"
        Driver         "mouse"
        Option	   "Name" "Logitech Logitech USB Optical Mouse"
        Option	   "Phys" "usb-*/input0"
        Option	   "Protocol" "Auto"
        Option         "Device" "/dev/input/mouse1"
        Option         "ZAxisMapping" "4 5"
    EndSection
    Section "InputDevice"
        Identifier     "Mouse1"
        Driver         "mouse"
        Option	   "Phys" "isa0060/serio1/input0"
        Option	   "Protocol" "Auto"
        Option         "Device" "/dev/input/mouse2"
        Option         "ZAxisMapping" "4 5"
    EndSection
    
    Section "Monitor"
        Identifier     "CMC 17 AD 0"
        Option         "DPMS"
    EndSection
    Section "Monitor"
        Identifier     "CMC 17 AD 1"
        Option         "DPMS"
    EndSection
    
    Section "Device"
        Identifier     "PCI FX5200"
        Driver         "nvidia"
        Option 	   "TripleBuffer" "True"
        BusID	   "PCI:0:9:0"
    EndSection
    Section "Device"
        Identifier     "AGP FX5200"
        Driver         "nvidia"
        Option 	   "TripleBuffer" "True"
        BusID	   "PCI:1:0:0"
    EndSection
    
    Section "Screen"
        Identifier     "Screen0"
        Device         "PCI FX5200"
        Monitor        "CMC 17 AD 0"
        DefaultDepth    24
        Option         "AddARGBGLXVisuals" "True"
        SubSection     "Display"
            Depth       16
            Modes      "1280x1024" "1152x864" "1024x768" "832x624" "800x600" "720x400" "640x480"
        EndSubSection
        SubSection     "Display"
            Depth       24
            Modes      "1280x1024" "1152x864" "1024x768" "832x624" "800x600" "720x400" "640x480"
        EndSubSection
    EndSection
    
    Section "Screen"
        Identifier     "Screen1"
        Device         "AGP FX5200"
        Monitor        "CMC 17 AD 1"
        DefaultDepth    24
        Option         "AddARGBGLXVisuals" "True"
        SubSection     "Display"
            Depth       16
            Modes      "1280x1024" "1152x864" "1024x768" "832x624" "800x600" "720x400" "640x480"
        EndSubSection
        SubSection     "Display"
            Depth       24
            Modes      "1280x1024" "1152x864" "1024x768" "832x624" "800x600" "720x400" "640x480"
        EndSubSection
    EndSection
    
    Section "ServerLayout"
        Identifier     "VGA0"
        Screen         "Screen0" 0 0
        InputDevice    "Keyboard0" "CoreKeyboard"
        InputDevice    "Mouse0" "CorePointer"
    EndSection
    
    Section "ServerLayout"
        Identifier     "VGA1"
        Screen         "Screen1" 0 0
        InputDevice    "Keyboard1" "CoreKeyboard"
        InputDevice    "Mouse1" "CorePointer"
    EndSection
    

    編修好 xorg.conf 之後,請不要忘了測試看看喲!!

    you@hostname~$ startx -- -layout vga0
    you@hostname~$ startx -- -layout vga1

    修改 gdm.conf 設置

    最後,請修改 gdm.conf 的設置 (Ubuntu 請修改 gdm.conf-custom)︰

    [servers]0=Standard0
    1=Standard1

    [server-Standard0]name=Standard server
    command=/usr/X11R6/bin/X -nolisten tcp -novtswitch -sharevts -layout VGA0
    flexible=true

    [server-Standard1]name=Standard server
    command=/usr/X11R6/bin/X -nolisten tcp -novtswitch -sharevts -layout VGA1
    flexible=true

    參考來源︰
    http://blog.chris.tylers.info/
    http://linuxgazette.net/124/smith.html
    http://cambuca.ldhs.cetuc.puc-rio.br/multiuser/
    https://help.ubuntu.com/community/MultiseatX
    http://www.linux.com/howtos/XFree-Local-multi-user-HOWTO/index.shtml


    個性簽名

    沒有最好,只有更好!!