在 Linux 客户机上的 VirtualBox VM 中强制监视器分辨率

Ill*_*ass 10 linux virtualbox multiple-monitors virtualization slackware

我在运行 Slackware-current 的 VirtualBox 4 VM 中工作。我添加了一个外部显示器,并试图将它们设置为以原始分辨率运行,但我没有运气。

我正在按照本页上的说明进行操作

但是我无法通过添加新监视器模式的步骤,即:

xrandr --addmode VBOX1 1600x1200_60.00
Run Code Online (Sandbox Code Playgroud)

当我运行它时,我收到一条错误消息:

X Error of failed request: BadMatch (invalid parameter attributes)
Major opcode of failed request: 151 (RANDR)
Minor opcode of failed request: 18 (RRAddOutputMode)
Serial number of failed request: 20
Current serial number in output stream: 21
Run Code Online (Sandbox Code Playgroud)

我浏览了许多论坛,安装了最新版本的 VirtualBox4,并安装了来宾操作系统运行时实用程序。

我还确保我的虚拟显示器可以处理这个问题,即: xrandr | grep -i maximum

产量:

minimum 64 x 64, current 800 x 600, maximum 32000 x 32000
Run Code Online (Sandbox Code Playgroud)

有没有其他人遇到过类似的事情?

Clo*_*oud 9

我自己也遇到过这个确切的问题。

首先,在大多数指南中,您通常会执行以下操作:

  1. 指定显示器分辨率,然后将其提供给 gtf:(
    gtf 1024 768 60获取 60Hz 下 1024x768 分辨率的 Modeline 信息)。
    就我而言,它产生:

    #1024x768 @ 60.00 Hz (GTF) 同步:47.70 kHz;pclk: 64.11 MHz Modeline "1024x768_60.00" 64.11 1024 1080 1184 1344 768 769 772 795 -HSync +Vsync

  2. 创建新模式:(
    xrandr --newmode "1024x768_60.00" 64.11 1024 1080 1184 1344 768 769 772 795 不要包含尾随-HSync +Vsync。一些指南告诉您这样做,但由于某种原因它会破坏配置)。

  3. 现在您应该能够将模式添加到新的显示中:
    xrandr --addmode VBOX0 1024x768_60.00

  4. 为设备设置新模式: xrandr --output VBOX0 --mode 1024x768_60.00

如果第 3 步仍然失败(这些步骤适用于我的笔记本电脑屏幕,它是 1680x1050,但由于某种原因不适用于支持 1600x1200 的外接显示器。尽管这些步骤适用于我的外接显示器的分辨率高达 1280x1024。奇怪),你可以仍然尝试让 xrandr 使用auto模式。就我而言,它可以让我的笔记本电脑屏幕和外接显示器完美运行。我使用的脚本附在下面:

#!/bin/bash

# Script to automatically resize virtual monitors in VirtualBox

# Start the server
sudo killall VBoxService
sleep 1
sudo VBoxService
sleep 1

# Start the client service
VBoxClient-all

# Get the modeline information we want for the following resolutions:
# 1680x1050@60.00Hz (Laptop display)
RES0="1680 1050 60"
# 1280x1024@60Hz (External monitor)
RES1="1280 1024 60"

# Setup mappings for physical to virtual monitors
MAP0="VBOX0"
MAP1="VBOX1"

# Generate settings
SETTINGS0=$( gtf $RES0 | grep Modeline | cut -d ' ' -f4-16 )
SETTINGS1=$( gtf $RES1 | grep Modeline | cut -d ' ' -f4-16 )

# Get name of modelines from settings
NAME0=$( echo $SETTINGS0 | cut -d ' ' -f1 )
NAME1=$( echo $SETTINGS1 | cut -d ' ' -f1 )

# Echo settings
echo "Modeline for Display 0 ($NAME0): $SETTINGS0"
echo "Modeline for Display 1 ($NAME1): $SETTINGS1"

# Create the new modelines via xrandr
xrandr --newmode $SETTINGS0
xrandr --newmode $SETTINGS1

# Add the newly created modelines to devices
xrandr --addmode $MAP0 $NAME0
xrandr --addmode $MAP1 $NAME1

# Finally, enable the new modes
xrandr --output $MAP0 --mode $NAME0
xrandr --output $MAP1 --mode $NAME1

# Extra: Attempt to run "auto" mode on the external monitor
# This is out last-ditch effort (which worked in this case) to get it running at
# 1600x1200 instead of 1280x1024 :)
xrandr --output $MAP1 --auto --above $MAP0
Run Code Online (Sandbox Code Playgroud)

  • xrandr --addmode VBOX0 "1600x900_60.00" 给了我以下错误:无法获得输出默认值的伽马大小。找不到输出“VBOX0” (3认同)

小智 7

在 virtualbox 上运行 Arch 时我遇到了同样的问题。分配更多的视频内存似乎为我解决了这个问题。

在此处输入图片说明