I have a fresh desktop install of CentOS7 with Gnome 3.

I need to use this machine with a KVM but for some reason CentOS7 cannot detect my monitor through the KVM I have, so it defaults to "Unknown Display" at a 1024x768 resolution (everything detects and works at higher resolutions if I connect the monitor directly to the system).

How can I manually configure things so I can use larger resolutions?

I tried editing monitors.xml with a new resolution, but upon reboot CentOS7 rejected the change, saying it could not detect, and went back to 1024x768.


I found the base of the solution here: https://askubuntu.com/questions/186288/how-to-detect-and-configure-an-output-with-xrandr

In modern Linux distributions, including CentOS, the xrandr library is responsible for things such as screen resolution, rotation and so on. Since your system does not autodetect, you have to manually tell it about the mode your monitor is capable of.

I had the same problem with a KVM, and the sample output is from my computer:

Step 1:

Find the name of your port. This will be something like VGA1, HDMI1 or so. You maybe able to find it from /var/log/Xorg.0.log, or you can use the xrandr utility:

> xrandr
Screen 0: minimum 8 x 8, current 1024 x 768, maximum 32767 x 32767
DP1 disconnected (normal left inverted right x axis y axis)
HDMI1 disconnected (normal left inverted right x axis y axis)
VGA1 connected primary 1024x768+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
   1024x768      60.00* 
   800x600       60.32    56.25  
   848x480       60.00  
   640x480       59.94  
VIRTUAL1 disconnected (normal left inverted right x axis y axis)

My KVM is connected to the VGA port called VGA1. Because the KVM blocks auto-detection, xrandr only saw the 1024x768 resolution.

Step 2:

Tell xrandr about the new mode. Modes are simply strings that have video display parameters attached to them.

Step 2.1

Find the display parameters you need. I wanted 1600x900 @ 60 Hz:

> gtf 1600 900 60 -x
# 1600x900 @ 60.00 Hz (GTF) hsync: 55.92 kHz; pclk: 119.00 MHz
  Modeline "1600x900_60.00"  119.00  1600 1696 1864 2128  900 901 904 932  -HSync +Vsync

Step 2.2

Create the new mode with xrandr using the values from the gtf command:

> xrandr --newmode "1600x900" 119.00  1600 1696 1864 2128  900 901 904 932  -HSync +Vsync

The first parameter is the name of the new mode - you could actually call it anything you like, just use the same name in the subsequent steps.

Step 3

Tell xrandr that VGA1 understands the mode called 1600x900:

> xrandr --addmode VGA1 1600x900

Step 4

Tell xrandr to switch to the new mode.

> xrandr --output VGA1 --mode 1600x900

Note: if you made a mistake and your monitor does not actually understand the new mode, you will get a blank screen!

If you do get a blank screen, you can probably recovery by blindly typing:

> xrandr --output VGA1 --mode 1024x768

Another way around that is to connect from another computer via SSH, and executing this command via SSH instead of on the console.

Step 5

Create a script that automates the newmode, addmode and output commands, since they will not be preserved during a reboot.

  • 1
    This is spot on - a rare gem of information on use of xrandr. A thousand upvotes to you, sir.
    – Paul
    May 9 '16 at 20:43
  • 1
    Worked for me as well. On CentOS 7.
    – Yaseen
    Jan 26 '17 at 7:59
  • 2
    Great answer. But now, where can I put the commands so that it becomes the default on startup?
    – mivk
    Jul 27 '18 at 8:57
  • @SteliosAdamantidis Yes. Note step 5 that should take care of that problem. Feb 17 '20 at 18:07

I agree that this is nearly the solution. This put my screen in the right resolution.

$ cvt 1920 1080 60
# 1920x1080 59.96 Hz (CVT 2.07M9) hsync: 67.16 kHz; pclk: 173.00 MHz
Modeline "1920x1080_60.00"  173.00  1920 2048 2248 2576  1080 1083 1088 1120 -hsync +vsync

However with two major black columns on both the left and right side of the screen. I guess some kind of overscan.

So I had to grep some values picked up during boot from xorg.log.

$ grep 1080 /var/log/Xorg.0.log
[  2316.000] (II) modeset(0): Modeline "1920x1080"x0.0  148.50  1920 2008 2052 2200  1080 1084 1089 1125 +hsync +vsync (67.5 kHz eP)

So after replacing the cvt values, with the values Xorg.0.log, I got the right screen layout.

$ xrandr --newmode "1920x1080_60.00" 148.50  1920 2008 2052 2200  1080 1084 1089 1125 +hsync +vsync

I had roughly the same situation, and the above answer is one of the more complete explanations of how to go about fixing this, but I had to go one more level to get my 32" Samsung to render in 2560x1440.

gtf is the method used above to get the timings, which works mostly, but it would not get me a mode with the resolution of 2560x1440. I used the cvt program, with the -r switch(necessary for this, and not suitable for crt's, only devices that can live w/o the blanking).

~% cvt -r  2560 1440 60
# 2560x1440 59.95 Hz (CVT 3.69M9-R) hsync: 88.79 kHz; pclk: 241.50 MHz
Modeline "2560x1440R"  241.50  2560 2608 2640 2720  1440 1443 1448 1481 +hsync -vsync

This timing mode, used analygously to the information above given by gtf, worked like a charm. I still wish I could make this get "baked" into the X11 system, but I made the script to create, add, and then switch to the mode, so it works great.

And my aging eyes love the enormous monitor. Nothing exceeds like excess...

(Script to do the mode add and switch follows)

 # Used to get timing: cvt -r  2560 1440 60
xrandr --newmode  "2560x1440R"  241.50  2560 2608 2640 2720  1440 1443 1448 1481 +hsync -vsync
xrandr --addmode HDMI1 "25 60x1440R"
xrandr --output HDMI1 --mode "2560x1440R"

After spending a couple of precious hours trying the above and other "solutions," I ran into this:


  • As links tend to get stale and die, link-only answers are not considered very helpful here. Perhaps you could go into detail about what you actually did to solve the problem in your answer, while still pointing to resources that helped you along the way. That way people using this site will see the answer directly, even if the other link goes away. Oct 10 '16 at 11:18

Not the answer you're looking for? Browse other questions tagged or ask your own question.