Linux, Tips and TricksVirtualbox Set date and time manually

Virtualbox Set date and time manually

This post is about setting time manually on a Linux VM independent of the host machine.
Virtualbox automatically syncs VM time to the host machine and sometimes the guest additions will do this as well.

I am doing this on the below
Host OS: Windows 10
Guest OS: CentOS 7
Guest VM Name: CentOS 7

Shutdown all VM’s and close the Virtualbox software.
Nothing related to Virtualbox should be running.

Important: Take a backup of these files as we will be modifying them.
Change the username accordingly

  1. The main Virtualbox xml file: C:\Users\{your-user-name}\.VirtualBox\VirtualBox.xml
  2. The xml file of the VM you need to change the time: C:\Users\{your-user-name}\VirtualBox VMs\CentOS 7\CentOS 7.vbox

Again take a backup before editing.
Edit both files and add the below lines to both files

<ExtraDataItem name="VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" value="1"/>

Save both files.
Start your Virtual machine
Once it boots up, you can set the date and time manually by using the below command

date -s "24 SEP 2018 22:58:00"

check the new date with the date command

You should disable things like ntp if they are set to update time automatically

Categories: Linux, Tips and Tricks


No Comments Yet. Be the first?

Post a comment

Your email address will not be published. Required fields are marked *