How to manually configure a monitor in CentOS7, attached via KVM?
Solution 1
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.
Solution 2
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
Solution 3
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)
#!/bin/bash
# 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"
Related videos on Youtube
Ajay Parsana
Updated on September 18, 2022Comments
-
Ajay Parsana over 1 year
<html> <head> <title></title> <script src="jquery-1.10.2.js"></script> <script type="text/javascript"> $(function() { $('#myList').delegate('li', 'click', function() { var text = $(this).attr('id'); var hashname = "#" + "content"; var linkname = text + ".html"; alert(text); $(hashname).load(linkname); }); }); </script> <ul id="myList" class="dropdown-menu"> <li id="about"> <a href="about.html">About us</a></li> <li id="Services"><a href="#">Services</a></li> <li id ="faq"><a href="faq.html">FAQ</a></li> </ul> </head> <body> Main Content </div> <br /> <div id="content"></div> </body> </html>
I want to load header only once and want to dynamically load content by creating diff pages. Above code works well in mozilla but not workinf in Chrome or IE. Please help.
Below is Services.html
<p>This is dynamic content of service page</p> <ul id="myList" class="dropdown-menu"> <li><a href="services.html">Services</a></li> </ul>
-
JJJ almost 10 yearsWhat does "not working" mean? Error messages in the console? What do you expect to happen and what happens instead?
-
-
JJJ almost 10 yearsCan you explain why the original code works in some browsers? And is that C# or something? The question doesn't specify their server-side technology.
-
Ninita almost 10 yearsI used only C#, HTML and JavaScript with JQuery. I update my answer to answer to your questions too
-
JJJ almost 10 years"Above code works well in mozilla but not workinf in Chrome or IE."
-
Ninita almost 10 yearsOk, I haven't saw that, sorry. However that is strange. That is the code orign? Some internet example?
-
Ajay Parsana almost 10 yearsThanks. I tried it on server and its working on IE and Chrome. { --allow-file-access-from-files} can u pls let me know how to do this?
-
Ajay Parsana almost 10 yearsThanks for your reply. what is myController in your code?
-
Ninita almost 10 yearswow, that your question let me concerned. I've never made websites without the MVC framework, and I also assumed that you were using this framework that makes web developers life much more easier. Sorry.. So 'myController' is a name that a gave to a fictitious controller, and a controller is a component of the MVC pattern
-
Pete TNT almost 10 yearsCreate a shortcut for Chrome and add the flag after the executable name such as "C:\Users\petetnt\AppData\Local\Google\Chrome\Application\chrome.exe" --allow-file-access-from-files . Make sure that you close all the Chrome sessions (even the background tasks) when you restart/launch the browser.
-
Paul about 8 yearsThis is spot on - a rare gem of information on use of xrandr. A thousand upvotes to you, sir.
-
Eric Renouf over 7 yearsAs 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.
-
Yaseen over 7 yearsWorked for me as well. On CentOS 7.
-
mivk almost 6 yearsGreat answer. But now, where can I put the commands so that it becomes the default on startup?
-
Kevin Keane about 4 years@SteliosAdamantidis Yes. Note step 5 that should take care of that problem.