billythekid's avatar

Homestead/vagrant time drift help

My Homestead box is consistently drifting time from my actual machine. Not just after a sleep event. I was trying to implement this vagrant mod: http://jeremykendall.net/2014/10/06/forcing-an-ntp-update/ but can't work out how to implement that in the vagrant file for the box.

At the moment I'm just sshing into the box when S3 bitches about the skew time and running a sudo ntpdate -s time.nist.gov but it's becoming tiresome to have to do this. would be much better if I could get vagrant to keep an eye on this itself.

Any pointers?

0 likes
7 replies
TerrePorter's avatar

I had to setup the ntpdate in 5 minute crontab in order to keep my times "mostly" synced.

I would keep losing time even with the ntp server running.

1 like
billythekid's avatar

Thanks @TerrePorter

This was my next course of action simply because I'm more familiar with cron etc than vagrant, but it still seems like a workaround when the capability is there to have the guest box just check the time against the host box and when it drifts out, get it in check. I'm sure that line in the vagrant file will do this, but the Homestead box is so bespoke that I'm not sure how I should edit it to make it work. My attempts so far have been futile. Would be good to see this sort of thing come as standard with the homestead setup because looking around the net it's a well known problem that VMs drift on host sleep etc. :o(

TerrePorter's avatar

@billythekid No problem, I'm not sure about vagrant having that capability, though there could be a plugin out there.

I'm using virutalbox for my homestead vm. I also install the guest additions which are supposed to keep the time on the VM the same as the host, but that never seems to work for me. You would think the ntp service would handle the time sync, but it must be taking a vacation or something.

bashy's avatar

This helpful? Not sure if or why this isn't in Homestead itself but

# Set the timesync threshold to 10 seconds, instead of the default 20 minutes.
# If the clock gets more than 15 minutes out of sync (due to your laptop going
# to sleep for instance, then some 3rd party services will reject requests.
vb.customize ["guestproperty", "set", :id, "/VirtualBox/GuestAdd/VBoxService/--timesync-set-threshold", 10000]

Ref: https://github.com/fideloper/Vaprobash/blob/master/Vagrantfile#L147

1 like
billythekid's avatar

Oh, now you mention it @TerrePorter I think there's something screwy with my guestadditions, I get an issue with mounting folders or something...

    default: /vagrant => /Users/billythekid/Homestead7
Failed to mount folders in Linux guest. This is usually because
the "vboxsf" file system is not available. Please verify that
the guest additions are properly installed in the guest and
can work properly. The command attempted was:

mount -t vboxsf -o uid=`id -u vagrant`,gid=`getent group vagrant | cut -d: -f3` vagrant /vagrant
mount -t vboxsf -o uid=`id -u vagrant`,gid=`id -g vagrant` vagrant /vagrant

The error output from the last command was:

/sbin/mount.vboxsf: mounting failed with the error: No such device

..it's not beyond possibilities that this has some effect on the time tracking too if it's a guestadditions functionality.

@bashy, thanks for that line, I'll have a hack at the vagrantfile and see if I can get that to work, looks very similar to the one I had before I was trying to make work. One of these things that you know you're close on but it's just out of reach! lol

anas-k's avatar

I tried this and worked for me, In /etc/ntp.conf file I replaced this line pool ntp.ubuntu.com with this pool time.nist.gov

Please or to participate in this conversation.