Fix display size on libvirt/Qemu guest
2017-05-22
236 words
2 mins read
Lot of times I find myself of VM that does not correctly resize the screen display and that is literally nuisance. So, here is quick and dirty fix for this.
First you need to find out information about your display with following command:
xrandr -q
And you will see output like this:
Screen 0: minimum 320 x 200, current 1920 x 1080, maximum 8192 x 8192
Virtual-0 connected primary 1920×1080+0+0 0mm x 0mm
1024×768 59.92 +
1920×1200 59.88
1920×1080 59.96*
1600×1200 59.87
1680×1050 59.95
1400×1050 59.98
1280×1024 59.89
1440×900 59.89
1280×960 59.94
1280×854 59.89
1280×800 59.81
1280×720 59.86
1152×768 59.78
800×600 59.86
848×480 59.66
720×480 59.71
640×480 59.38
Virtual-1 disconnected
Virtual-2 disconnected
Virtual-3 disconnected
This tells you the currently configured screens and the resolutions. In my case, the only connected screen as seen above is “Virtual-0“. Now, time to do the magic.
You just need to set the correct display/screen size with following command:
xrandr --output Virtual-0 --mode 1920x1200
Also, if you need to add a new resolution, first you need to create a modeline with following command:
cvt 1200 1024
You will get output like :
# 1200×1024 59.82 Hz (CVT) hsync: 63.59 kHz; pclk: 101.75 MHz
Modeline “1200x1024_60.00” 101.75 1200 1280 1400 1600 1024 1027 1037 1063 -hsync +vsync
and then set that with:
xrandr --output Virtual-0 --mode 1200x1024
Hope this helps you do away with some really pathetic display sizes in VM 🙂
Related Articles:
- 2016/07/25 Install virtual machines in one line
- 2016/04/15 Most simple and fast lightweight container with Fedora systemd
- 2016/02/01 virsh – show ip address of all running VMs
- 2015/05/05 docker search description truncated
- 2016/07/04 Python script to manage virtual machines with python API for libvirt.
Authored By Amit Agarwal
Amit Agarwal, Linux and Photography are my hobbies.Creative Commons Attribution 4.0 International License.