Multiseat in Ubuntu 14.10


Nathan Osman's Gravatar

Nathan Osman
published Nov. 16, 2014, 8 a.m.


I have really been looking forward to getting this tutorial published. This article will describe something that will be sure to make every Windows and Mac user very jealous. When we are done, we will have converted one computer into two computers. How? Read on.

Requirements

In order to make this work, there are a couple of requirements:

  1. You must have at least two monitors, two mice, and two keyboards.
  2. You must have two separate video cards. *

* If you have an integrated card and a dedicated video card, you may be able to proceed if your BIOS allows both to be active at the same time. This is what I did in my setup.

Unfortunately, I have not played around with my setup enough to determine if it is possible to create a multiseat setup using a single dual-head video card. I may explore this in a future article.

Each "seat" consists of a single monitor, mouse, and keyboard and will eventually run its own login session. The first seat will always be referred to as seat0. We will assign the name seat-1 to the second seat. Although this article will explore only two seats, it is possible to have more than two seats.

Identifying Hardware

We will be using loginctl to assign devices to particular seats. Unfortunately, this is where things get a bit tricky. Devices are identified by directories in /sys, which isn't exactly user-friendly. However, loginctl provides an additional command that will prove to be very helpful. Open a terminal and run the following command:

loginctl seat-status seat0

This command will provide identifiers for the hardware currently assigned to seat0. Because you only have one seat, this will include all of your connected hardware. Here's what the output of the command looks like on my machine:

Multiseat logintctl

You will need to identify each of your devices by their descriptive names and use the associated /sys/... path when assigning them to seats. Consider the following example:

├─/sys/devices/platform/i8042/serio0/input/input2
│ input:input2 "AT Translated Set 2 keyboard"

This device refers to the PS/2 keyboard (PS/2 devices are controlled by the i8042 controller). We can assign this device to seat-1 by using the following command:

sudo loginctl attach seat-1 /sys/devices/platform/i8042/serio0/input/input2

Once you have attached the keyboard to another seat, it will no longer function on seat0. Try typing something on the keyboard - it won't have any effect. In order to actually use the keyboard, you will need to assign one of your video cards to the seat. In my case, I have both an APU (Radeon HD 7560D) and a Radeon R9 270X. Each includes the card and associated framebuffer:

  • Radeon HD 7560D
    • /sys/devices/pci0000:00/0000:00:01.0/drm/card0
    • /sys/devices/pci0000:00/0000:00:01.0/graphics/fb1
  • Radeon R9 270X
    • /sys/devices/pci0000:00/0000:00:04.0/0000:01:00.0/drm/card1
    • /sys/devices/pci0000:00/0000:00:04.0/0000:01:00.0/graphics/fb0

It may be a bit confusing to see fb1 assigned to card0 and fb0 assigned to card1 but if you are careful to match the bus numbers (0000:00:01.0, etc.) you shouldn't have any problems.

Testing It Out

Once you have assigned the hardware to the appropriate seat, reboot your computer and cross your fingers. (Simply logging out or restarting X didn't seem to work for me.) If all went well, you will be greeted with two login screens - one on each monitor.

Don't worry if one of the keyboards or mice isn't assigned to the correct seat. Use the commands above to reassign them to the correct seat. The changes will be applied instantly and you won't need to restart anything.

Try logging in under two different user accounts and launching applications. Each seat is completely isolated from the others, allowing each user to login and use their account as they normally would.

The Sound Challenge

At first, it might seem impossible to have separate sound cards assigned to each seat since most computers only have a single soundcard. Or do they?

  • If your video card has an HDMI port, chances are good that you can use the HDMI port for audio playback as well as video. Open System Settings and click the Sound icon. Try selecting one of the other soundcards listed:

    Multiseat Sound Settings

  • If you have Bluetooth speakers (or, more correctly stated, anything that can act as an A2DP sink), you may be able to use that. I haven't tried this myself, but I see no reason why it wouldn't work.

Once you have identified two soundcards, you can assign them to a particular seat using the same commands as above. For example, I assigned my primary soundcard to seat-1 using:

sudo loginctl attach seat-1 /sys/devices/pci0000:00/0000:00:14.2/sound/card1

Additional Tip

One of the easiest ways to control USB peripherals attached to a seat is to connect them all to a USB hub and assign the entire hub to the seat. That way, the user using the seat can add and remove devices as they please without the need to assign them one-at-a-time.

USB Hub

Resetting Everything

Reverting your setup to its initial configuration (a single seat) couldn't be easier. Just run the following command:

sudo loginctl flush-devices