Guerrilla Tactics to Force Screen Mode in Ubuntu

Readers of my previous posts will know about the bad luck I've had when it comes to getting the screen setup on Linux, particularly with Ubuntu Linux. It's a particularly annoying problem when the hardware detection goes wrong and one is presented with a list of unsuitable screen modes. What follows is a way of using XRandR (X Rotate and Resize) to brute force a desired screen mode for X when conventional routes have failed.

Once you've added the new mode and tested that it works, you can add it to your xorg.conf or to the startup script of your login manager. Most of what follows assumes that you are using Ubuntu Linux, but it should work just as well with all but the most unusual distributions.

If you're having a problem whereby your monitor immediately goes blank and reports that the incoming signal is out of range when X starts, it might be worth attempting to the change the screen mode by hitting ctrl+alt+[minus symbol]. Repeatedly pressing this combination might select a screen mode that your monitor can display.

Once you have a usable display, open up a command line and type:

xrandr

When you invoke XRandR with no parameters, it lists the currently supported screen modes. Typical output might look something like this:

Screen 0: minimum 800 x 600, current 800 x 600 , maximum 800 x 600
default connected 800x600 +0+0 0mm x 0mm
800x600 60.0

If the screen resolution and refresh rate that you need are listed here, it might be a good idea to try changing the screen mode using the standard tools for your desktop environment or the specific tools for your graphics card driver.

If your desired resolution is not displayed, you can add it to the system using XRandR. First generate a modeline for your screen setup using the cvt command. For example, if you need a screen mode of 1280x1024 at 60Hz, type:

cvt 1280 1024 60

The output should look something like this:

# 1280x1024 59.89 Hz (CVT 1.31M4) hsync: 63.67 kHz; pclk: 109.00 MHz
Modeline "1280x1024_60.00" 109.00 1280 1368 1496 1712 1024 1027 1034 1063 -hsync +vsync

Add this mode to the system using XRandR

xrandr --newmode "1280x1024_60.00" 109.00 1280 1368 1496 1712  1024 1027 1034 1063 -hsync +vsync

I got the technical information I needed by copying and pasting everything after the word “Modeline” from the output of cvt. Now type “xrandr” again to make sure that the new mode has been added to the system. You should see it listed along with the other modes. Note that the string “1280x1024_60.00" in that example is simply the name of the mode, the actual numbers in the name are irrelevant. Once the mode has been created, attach it to a display output using the following.

xrandr --addmode default 1280x1024_60.00

On my setup, the display output is called “default”, as revealed by the second line of the output of the xrandr command with no parameters. Now try changing to the new screen mode.

xrandr --output default --mode 1280x1024_60.00

If this works, you're ready to make the change permanent. You can do this by editing the xorg.conf file or adding a command sequence to a startup file.

Basically, you add the modeline to the “Monitor” section of your xorg.conf file and the mode itself to the “Display” subsection within the “Screen” main section, adding to or replacing what's already there.

So, in keeping with the above examples, the Monitor section should look something like this:

Section "Monitor"
    Identifier "default"
    Modeline "1280x1024_60.00" 109.00 1280 1368 1496 1712 1024 1027 1034 1063 -hsync +vsync 
    Option "PreferredMode" "1280x1024_60.00"
EndSection

and the Screen section something like:

Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    DefaultDepth    24
    SubSection     "Display"
    Modes “1280x1024_60.00”
        Depth       24
    EndSubSection
EndSection

Reboot and see if you have a working display.

Another way of doing this is to add the command sequence that you've already used to your login manager. This is a last resort if other means simply refuse to work, but it works pretty well. In the case of KDM, the KDE4 login manager, you should be able to edit the startup script by typing

sudo kwrite /etc/kde4/kdm/Xsetup

The equivalent GDM (Gnome) file is “/etc/gdm/Init/Default”. Using the setup above as example, simply cut and paste the following lines to this file.

xrandr --newmode "1280x1024_60.00" 109.00 1280 1368 1496 1712 1024 1027 1034 1063 -hsync +vsync
xrandr --addmode default 1280x1024_60.00
xrandr --output default --mode 1280x1024_60.00

There you have it, a rather guerrilla method of forcing the screen to do what you want.

______________________

UK based freelance writer Michael Reed writes about technology, retro computing, geek culture and gender politics.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

ubuntu scr res

Anonymous's picture

My computer claims to have 1280x1024 screen, ubuntu allows for that size, but refuses to believe the computer.

So I added xforce vga=771 to the boot and that seems to work well enough.
g

Crude, thought we were past that!

TomW001's picture

I recall having to do this sort of nonsense back over 12 years ago using Slackware. I've been running Mandriva for almost 8 years now and this type of screen setup is unheard of! Just run XFdrake and the utility does all this for you, from the command line.

When I looked at Ubuntu, I could not understand all the excitment surrounding it. I found Ubuntu to be crude and lacking a *lot* of polish that I otherwise take for granted.

How to set max monitor resolution

TomM's picture

Hi. I have tried to change desktop resolution for xubuntu virtual machine (running under xen), but encoutered following error

xrandr: screen cannot be larger than 800x600 (desired size 1024x768)

How can I set up the resolution of virtual screen?

I have exactly the same

AndyW's picture

I have exactly the same issue. Using VirtualPC 2007.
There is a lot of information and much chat on how to make the changes mentioned above permanent etc, but nowhere can I find information on what to do if the above steps dont work! I too get the error: "screen cannot be larger than 800x600 (desired size 1024x768 )"
Seems logical that Additions for Virtual PC would sort it but I can't find an ubuntu version so dead end has been reached :¬(
Anyone..?

Not sure this will work for me

davesnyd's picture

On my system-- a laptop with nvidia graphics-- there is almost nothing in the xorg.conf:

/etc/X11$ cat xorg.conf

Section "Screen"
Identifier "Configured Screen Device"
DefaultDepth 24
EndSection

Section "Device"
Identifier "Configured Video Device"
Driver "nvidia"
EndSection

I'm not worried about setting the resolution of my primary display (the laptop screen)-- but I find that for about half the projectors I try, the laptop does not successfully read their edid, so I'm left with 640x480.

I usually set them up using TwinView, with the projector echoing the upper left corner of my screen.

Given the paucity of information in my xorg.conf and my desire to change the resolution of an external screen, can you provide guidance on how I would modify the instructions above to successfully reach, say, a 1280x1024 resolution on a projector that isn't behaving well (i.e., not broadcasting an edid correctly)?

nvidia-settings

Michael Reed's picture

Does the nvidia-settings command work? If not, nvidia-settings can generate a fresh xorg.conf file, that might be more complete.

If you can't get that to work and the xrandr command does allow you to manually set the screen mode you want, it might be worth adding the command sequence to the startup script of your login manager as described. Try it, would be my advice.

UK based freelance writer Michael Reed writes about technology, retro computing, geek culture and gender politics.

A good thing about using

videociks's picture

A good thing about using Xrandr is that you can always try it to see if it works from the command line without editing any files.

HELP

OARS78's picture

Greetings from Venezuela, I got this problem with my video card Drivers, my card It's a Nvidia GeForce 6200, using Ubuntu 10.04, my monitor It's a Samsung 19" widescreen.
The resolution 1440x900 doesn't get it from the drivers... Did search the Nvidia page, got the driver but nothing...
This metod that you mention here would work to force that resolution???
Thanx in advance for the attention and congratulation for the blog, had learn a lot with all of you.

I had similar problems with

Ben's picture

I had similar problems with my Samsung monitors. I had 2 connected to an ATI card. The one connected to the DVI port set is resolution correctly. The one connected to the VGA port wouldn't. I checked the X log and the monitor was reporting the wrong resolutions when connected via the VGA cable, but not the DVI cable. In the end I got an HDMI to DVI cable and connected the second monitor to that. Then both monitors worked correctly.

Try it

Michael Reed's picture

A good thing about using Xrandr is that you can always try it to see if it works from the command line without editing any files.

UK based freelance writer Michael Reed writes about technology, retro computing, geek culture and gender politics.

Excellent! Just what i was

humberto's picture

Excellent!

Just what i was looking for.

Debian Lenny with an ati card and the proprietary drivers set don't get the full resolution of my LCD.

01010010 01010100 01000110 01001101 00100001

Webinar
One Click, Universal Protection: Implementing Centralized Security Policies on Linux Systems

As Linux continues to play an ever increasing role in corporate data centers and institutions, ensuring the integrity and protection of these systems must be a priority. With 60% of the world's websites and an increasing share of organization's mission-critical workloads running on Linux, failing to stop malware and other advanced threats on Linux can increasingly impact an organization's reputation and bottom line.

Learn More

Sponsored by Bit9

Webinar
Linux Backup and Recovery Webinar

Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.

In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.

Learn More

Sponsored by Storix