Using two screens in FreeBSD 8 with an Nvidia graphics card
So I finally made the jump to a multiple monitor setup, and boy is it NICE! I’ve been using a dual screen setup at work for several years and found that it really does boost productivity. I had previously been using a single Apple 23″ HD display I bought in 2004 when I bought a PowerMac G5. While I was a little apprehensive at first, it turns out that configuring a dual screen setup in FreeBSD is really quite simple.
First, you’ll need to physically set your monitors up, including placing them on your desk and running the power and video cables. For video, you really will want to use at least DVI. VGA just doesn’t cut it these days, both in terms of clarity and resolution. Fortunately, just about any display you can buy these days has a DVI connector (most have both VGA and DVI). Don’t skimp on monitors either. You do have to look at them for some period of time so you’ll want something with a good contrast ratio and response rate. I managed to snag two Samsung SyncMaster 2243 22″ LCD monitors for $179 a piece at Microcenter (marked down from $219 a piece). I don’t recommend going above this size if you sit close to your screens (and most of us do) because you may end up straining your eyes with very large displays. Also, don’t just line the screens up side by side either. You’ll want to have a somewhat concave layout so it feels more natural to your eyes and brain. I set my screens so that they meet in the middle of my desk and then a tilt them inward a few inches where they meet. Do this by lightly pushing against the place where the bezels meet with your thumb. You may need to adjust the pitch and tilt of the screens afterward to get the bezels properly lined up. With that done, connect the power and video cables. If you are connecting new screens to your system while you are already in your window manager, I would highly recommend powering down your system. I tried a warm reboot on mine after attaching the screens and was greeted by a kernel crash.
When your system boots, you might be greeted with a clone display (same picture on both monitors) or you may see output on just one screen. I’m no expert on Nvidia graphics cards, so I can’t tell you what to expect for a given card. For my setup, I’ve got a Nvidia GeForce 9500GT. It’s a low end card by today’s standards for sure, but I don’t do much gaming at all, so it meets my needs. Depending upon your setup, you may be greeted by either a display manager (Gnome Display Manager, etc…) or just a login prompt. I prefer to keep it simple and shun a display manager for the comfort of a black screen and a login prompt.
Once logged in, you’ll need a shell, so open a terminal if you’re in a window manager. Most users of Xorg these days can get by without a configuration file since Xorg is much better at configuring hardware on its own these days. If you have a static Xorg configuration and have your resolution hard coded, you may see nothing but gibberish. You can either reboot into single user mode and move your configuration file to a backup or just reattach your old screen. Personally, I never specify a resolution since Xorg gets it right anyways. If you do not have an Xorg config, su to root and use the following command to generate one:
# Xorg -configure
This should dump a file called xorg.conf.new in root’s home directory. Open that file up in your favorite editor. Under the Device section, add the following line:
Option "TwinView"
Here’s what my Device section looks like:
Section "Device" Identifier "Card0" Driver "nvidia" VendorName "nVidia Corporation" BoardName "G96 [GeForce 9500 GT]" BusID "PCI:1:0:0" Option "TwinView" EndSection
Next, look for the Screen section. Under that will be several subsections named Display that are used for different color depths. In each of these, we need to add the Virtual directive. The parameters will be different depending on your screen resolution. Since my two screens are capable of a resolution of 1680×1050, I simply double my width parameter to 3360 (we want to span the width of the desktop across the two screens, remember?) to get a Virtual directive of “Virtual 3360 1050″. Here’s what it looks like for 24 bit depth:
SubSection "Display"
Virtual 3360 1050
Viewport 0 0
Depth 24
EndSubSection
With both the TwinView option and the Virtual directive added, copy the configuration over to /etc/X11/ as just xorg.conf. You should be able to restart X or start it up if you’re not using a display manager. You should see one gigantic screen! If not, check your settings. You may need to use Xrandr. It gets installed by default with the xorg-apps port. If you don’t have the xrandr command, you may need to rebuild that port with the Xrandr option enabled. You can test it out by typing “xrandr” at a terminal prompt. You should see a good amount of output including your two display connectors (probably DVI0 and DVI1 or some variation), as well as the supported resolutions. If you do, try the following command:
% xrandr --output DVI1 --right-of DVI0
If you see a single large desktop, congratulations! You’ll want to add the above command to your startup. This is usually at the top of the xinitrc file for non-GDM users or xsessions for GDM users.
Enjoy your added productivity and enormous desktop!