0. VirtualBox版本
本安装过程在Win10系统,VirtualBox 6.1.38
版本上进行顺利,最终可实现虚拟机桌面可自动随VirtualBox窗口大小调整分辨率,粘贴板双向共享功能正常。但在VirtualBox 7.0.14
版本上安装后,粘贴板共享功能无效,需要替换旧版本VBoxGuestAdditions_*.iso
增强工具(我用的是VBoxGuestAdditions_6.1.2.iso
)才变正常,另外虚拟机桌面无法随窗口大小自动调整分辨率,即使替换旧版增强工具也无效。问题原因不明。
1. 安装虚拟机
选择使用完整硬盘空间,而非替换原有linux系统(此步骤可能非必须,只是我自己的习惯,未测试替换原有系统选项)
2. 更换yum源
将/etc/yum.repos.d/CentOS-Base.repo
更换成可用版本(目前阿里云的centos-6.10版本可用)
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-6.10
enabled=1
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.10/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
[updates]
name=CentOS-6.10
enabled=1
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.10/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
[extras]
name=CentOS-6.10
enabled=1
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.10/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
[epel]
name=Extra Packages for Enterprise Linux 6 - $basearch
enabled=1
failovermethod=priority
baseurl=http://mirrors.aliyun.com/epel-archive/6/$basearch
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/epel-archive/RPM-GPG-KEY-EPEL-6
3. 安装增强工具
安装增强工具前,需要先更新kernel,并安装kernel-headers,否则会报kernel headers not found for target kernel
错误
3.1 安装kernel-headers
依次运行下列命令,非root用户前面需要加sudo
先更新kernel
yum update kernel -y
再安装kernel-hearders
yum install kernel-headers kernel-devel gcc make -y
然后重启
reboot
3.2 安装增强工具
点击VB菜单栏设备-安装增强功能
,弹出的窗口可直接叉掉
桌面出现VBox-GAs-6.1.38
,双击该图标,打开相应文件夹
在该文件夹内右键,选择open in terminal
唤起终端,切换至root
账户,运行./VBoxLinuxAdditions.run
,等待安装完成。
3.3 设置虚拟机自适应窗口大小调整分辨率
增强工具安装完成后,reboot
。
再次进入系统后,点击VB菜单栏视图-自动调整显示尺寸
,先取消勾选,再点一次重新勾选,此时虚拟机界面应该可以自适应至VB窗口大小。
3.4 设置共享文件夹
设置共享文件夹前或后,需要给非root用户添加共享文件读写权限,运行
sudo usermod -aG vboxsf $(whoami)
reboot
重新进入系统后,共享文件夹设置的共享文件夹即可使用