要调整CentOS虚拟机的分辨率,必须先安装VirtualBox Guest Additions,否则无法获取动态分辨率支持(如窗口自适应、更多分辨率选项)。具体操作如下:
/run/media/你的用户名/VBox_GAs_版本号)。sudo yum install kernel kernel-core kernel-modules kernel-devel gcc make perl elfutils-libelf-devel -y
cd /run/media/你的用户名/VBox_GAs_版本号
sudo ./VBoxLinuxAdditions.run
安装增强功能并重启后,可通过CentOS的「系统设置」直接调整分辨率:
若图形界面无法正常使用,或需要固定特定分辨率,可通过xrandr命令手动调整:
HDMI-1、VGA-1等为显示设备名称):xrandr
输出示例:HDMI-1 connected primary 1024x768+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
1024x768 60.00*+
800x600 60.32
1920x1080 59.94
1920x1080),替换命令中的HDMI-1(你的显示设备名称)和1920x1080(目标分辨率),执行:xrandr --output HDMI-1 --mode 1920x1080
若成功,分辨率会立即切换。若上述方法无法长期保存分辨率,可手动编辑xorg.conf文件(需谨慎操作,错误的配置可能导致无法进入图形界面):
xorg.conf文件:sudo Xorg -configure
生成的文件默认位于/root/xorg.conf.new。/etc/X11/目录下:sudo cp /root/xorg.conf.new /etc/X11/xorg.conf
vi)打开xorg.conf,找到Section "Screen"部分,修改Modes行为你需要的分辨率(如"1920x1080" "1366x768"):Section "Screen"
Identifier "Screen0"
Device "Card0"
Monitor "Monitor0"
DefaultDepth 24
SubSection "Display"
Depth 24
Modes "1920x1080" "1366x768" "800x600"
EndSubSection
EndSection