Thursday 25 October 2018

linux - How can I cause a VirtualBox VM (running Ubuntu) to run a command upon resuming its state?


I am running a few Ubuntu VMs on a MacBook Pro host.


Whenever I pause a VM or save its state to disk, the next time I restart it, the system clock goes out of sync.


Is there a way for the VM to know it has just been resumed, and run a command? (for example, running ntpdate -u time.nist.gov as root would do the trick)


I tried modifying the scripts in /etc/pm/sleep.d, but these don't appear to be called on VM suspend/resume.



Answer



For this particular use, the Guest Additions is supposed to synchronize the VM's clock automatically. (See "Time synchronization" at http://www.virtualbox.org/manual/ch04.html, or if you want to customize it, http://www.virtualbox.org/manual/ch09.html#changetimesync.) It's possible that this updating might have stopped working when using an older version of the guest additions than the VirtualBox version on the host.


To install or update the Guest Additions, mount the Guest Additions CD image using the relevant menu command on the host, and run the script from the CD on the guest. For details see the directions at http://www.virtualbox.org/manual/ch04.html#idp11850096.


No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...