「Linux」- 修改屏幕的分辨率

# 查看显示器支持的分辨率

How can I get the monitor resolution using the command line?
How can I list the available video modes for my screen?
How do I change the screen resolution using Ubuntu command line?

# 如何持久化设置的模式

How to debug xrandr not setting up the desired resolution?
How can I make xrandr customization permanent?

# gtf 1920 1080 60
# cvt <h-resolution> <v-resolution> [refresh]

# vim /etc/X11/xorg.conf

# 生成 xorg.conf 文件

How to make an xorg.conf file
How to create xorg.conf

# nvidia-xconfig

# Xorg :1 -configure
# cp /root/xorg.conf.new /etc/X11/xorg.conf

相关链接

xrandr: where does VIRTUAL1 output come from?

自定义屏幕分辨率 Change Resolution

How to Set A Custom Screen Resolution in Ubuntu Desktop | UbuntuHandbook
How to set display resolution permanent in Ubuntu 16.04 – Ask Ubuntu
Screen resolution not showing all options
Screen Resolution: xrandr “cannot find mode”

在 VirtualBox 5.2.44, Guest Ubuntu 20.04 TLS 中,即使安装 Guest Additions 组件中,显示器分辨率自动调整还是存在问题。最后,在 Ubuntu 中,我们通过自定义分辨率来解决该问题,以实现虚拟机屏幕显示最大化。

该笔记将记录:在 Ubuntu 20.04 中,如何自定义屏幕分辨率(适用于 X.Org 桌面环境),以及相关问题的解决方法。

临时配置

> cvt 1840 1015
# 1840x1015 59.94 Hz (CVT) hsync: 63.11 kHz; pclk: 154.50 MHz
Modeline "1840x1015_60.00"  154.50  1840 1952 2144 2448  1015 1018 1028 1053 -hsync +vsync

> xrandr --newmode "1840x1015_60.00"  154.50  1840 1952 2144 2448  1015 1018 1028 1053 -hsync +vsync

> xrandr --listactivemonitors
Monitors: 1
 0: +*VGA-1 1840/487x1015/269+0+0  VGA-1

> xrandr --addmode VGA-1 1840x1015_60.00

最后,在 Settings 中,选择 1840×1015 分辨率即可。

持久保存

配置是临时的,无法持久化。如果希望持久化:

常用设置

// ---------------------------------------------------------------------------- // Linux as Host

# cvt 1880 972

# xrandr --newmode  "1880x972_60.00"  151.25  1880 2000 2192 2504  972 975 985 1009 -hsync +vsync

# xrandr --listactivemonitors
...

# xrandr --addmode Virtual1 "1880x972_60.00"

# cvt 1920 972
xrandr --newmode "1920x972_60.00"  154.75  1920 2040 2240 2560  972 975 985 1009 -hsync +vsync

# xrandr --listactivemonitors
xrandr --addmode Virtual2 "1920x972_60.00"

// ---------------------------------------------------------------------------- // Windows as Host

# cvt 1840 1015
xrandr --newmode "1840x1015_60.00"  154.50  1840 1952 2144 2448  1015 1018 1028 1053 -hsync +vsync
# xrandr --listactivemonitors
xrandr --addmode Virtual1 1840x1015_60.00