CCoder 2020-05-05
最近因为测试的需要,需要改动虚拟机时间。用date -s "xxxx"修改后马上又会恢复,查看并没有时间同步任务。后来发现虚拟机的时间一直与主机同步。
解决:只需要关闭虚拟机与主机时间同步:
关闭时间同步:
vboxmanage guestproperty set <虚拟机名/虚拟机UUID> --timesync-set-stop
打开时间同步:
vboxmanage guestproperty set <虚拟机名/虚拟机UUID> --timesync-set-start
举例:命令行下查看虚拟机名或虚拟机UUID,VirtualBox安装在Ubuntu系统下
1、查看创建的全部虚拟机:
---------------------------------------------------------------
:~$ vboxmanage list vms ##在那个用户下创建的虚拟,就要在对应的用户下执行这个命令,否则看不到
"Win7 ASP work" {41adc8c1-8bf2-4b1c-a062-066a8335a231}
"Win7 ASP Config " {781dece8-dbb3-4e10-a745-7471cd7998a7}
"FusionCube 3.2.1.SPC200_Builder" {037e75c9-2560-4f74-8c3f-ee4973d5402f}
"Win2012R2" {05107d8d-595a-4159-81b8-0348de07c7a0}
"Ubuntu1804 " {141d8347-6e3e-41ce-b5d1-133f888b2c98}
"CentOS6.9" {fbb1bd1e-8a30-49aa-86d3-269f0187e0b2}
"CentOS-7-1810_1" {4a651d2c-1015-4c79-a225-259b920e3851}
"OpenSUSE15 Xfce" {d9045e81-2f2d-48cf-9b9a-66a726cc1e5e}
"Debian9.5" {09603512-ea6c-47b0-9125-36ac4494b2a5}
"CentOS7_GUI" {3a5ed059-abfc-4b28-8361-3ce8b2138e1b}
"CentOS7.5" {60684866-b7a4-41c4-b846-98a581951938}
"Ubuntu20.20" {e4a8c933-749e-4b42-beff-6911e9fcf9da}
---------------------------------------------------------------
2、只查看运行的虚拟机
---------------------------------------------------------------
:~$ vboxmanage list runningvms
"CentOS-7-1810_1" {4a651d2c-1015-4c79-a225-259b920e3851}
"OpenSUSE15 Xfce" {d9045e81-2f2d-48cf-9b9a-66a726cc1e5e}
"Debian9.5" {09603512-ea6c-47b0-9125-36ac4494b2a5}
:~$
---------------------------------------------------------------
3、关闭时间同步
---------------------------------------------------------------
:~$ vboxmanage guestproperty set "OpenSUSE15 Xfce" --timesync-set-stop ##虚拟机名必须用""号括起来
---------------------------------------------------------------
4、打开时间同步
---------------------------------------------------------------
:~$ vboxmanage guestproperty set d9045e81-2f2d-48cf-9b9a-66a726cc1e5e --timesync-set-start ##通过UUID方式打开,如果虚拟机不好用,重启虚拟机后好用
---------------------------------------------------------------