linux - Ubuntu clock is wrong and I can't change it (running as VirtualBox Guest under OSX)

15
2013-12
  • Ludo

    I have a strange problem with my Ubuntu Natty virtual machine running under VirtualBox on OSX.

    One day last week, my clock on the top bar in Gnome stopped displaying the correct time (I'm not running Unity). I'm on GMT, so right now it should be 9:31, but it's showing 3:31, so I think it's something to do with TimeZones.

    If I go into the date and time applet, the time is initially wrong but after a second sets itself to the correct GMT Time. The timezone is correclty set as London and it makes no difference if I unlock and set it again or select manual or automatic from internet time.

    From a bash prompt, the "date" command shows: "Tue Sep 20 03:33:35 CDT 2011".

    If I run "sudo dpkg-reconfigure tzdata" I am correctly set as London. Upon exiting the commnand I'm shown the correct London time, but then typing "date" again shows the CDT time again.

    :~/$ date
    Tue Sep 20 03:33:35 CDT 2011
    
    :~/$ sudo dpkg-reconfigure tzdata
    Current default time zone: 'Europe/London'
    Local time is now:      Tue Sep 20 09:34:22 BST 2011.
    Universal Time is now:  Tue Sep 20 08:34:22 UTC 2011.
    
    :~/$ date
    Tue Sep 20 03:34:26 CDT 2011
    

    The clock is correct in OSX. This has been working fine for a month or two - I think it stopped working after an update last week. Any ideas?

  • Answers
  • flyman

    I had a similar issue with ArchLinux guest in VirtualBox host. When I use TIMEZONE="Africa/Johannesburg" or TIMEZONE="Asia/Bahrain" in my rc.conf file, the output of date is correct but when I use TIMEZONE="/Etc/GMT+2" or "/Etc/GMT+3" (corresponding to aforementioned timezones) then the VBoxService sets time 6 hours to early.

    My hardware clock time always remains correct (sudo hwclock --show) and setting system time from hardware clock (sudo hwclock --hctosys) sets system time correctly until VBoxService runs timesync again and output of date is 6 hours too early.

    To summarize; using timezones from /usr/share/zoneinfo// seems to work but other zoneinfos might not work, I don't know why this is.

  • evan.bovie

    I had the exact same issue on my regular Ubuntu install. The reason turned out to be that I had installed sontek's dotfiles. In a .profile, the TZ variable was explicitly set to America/Chicago. Removing this entry fixed the problem.

    What lead me to the answer was this question, and new123456's comment.

  • evan.bovie

    In order to change your timezone, run the following command in the shell:

    $ sudo "ln -sf /usr/share/zoneinfo/America/Los_Angeles /etc/localtime"
    

    That command assumes that your hardware (BIOS) clock is GMT. You can scour /usr/share/zoneinfo for a better option.


  • Related Question

    Sync Iphone in Windows XP running as Virtualbox guest under Ubuntu 9.10
  • postfuturist

    I run (K)Ubuntu 9.10 as my main operating system, but I still have a valid XP license, so I've been running Windows XP as a guest operating system with Virtualbox 3.10. I cannot get Itunes (running under Windows XP) to detect the presence of my Iphone. I found this link: http://blog.rootshell.be/2009/01/15/iphone-itunes-virtualbox/ which explains how to get this Itunes-in-XP-in-Virtualbox-under-Ubuntu configuration to work, but it involves editing the file /etc/init.d/mountdevsubfs.sh which apparently does not exist in Ubuntu 9.10.

    Does anyone know how get Itunes in XP running as a guest in Ubuntu 9.10 to detect and sync with an Iphone?


  • Related Answers
  • postfuturist

    Here is how I got it to work:

    First, I followed the instructions on this page: https://help.ubuntu.com/community/VirtualBox/USB

    This included adding a line to /etc/fstab and a couple lines to /etc/udev/rules.d/40-basic-permissions.rules . Nothing seemed to change, Itunes was still ignoring my Iphone.

    Curious if the device was even being registered by Windows, I went into the Device Manager in XP. There was an unknown USB device with a question mark. I went in to the properties for the unknown USB device, did a reinstall drivers action, allowing Windows to search for drivers online. In about 10 seconds the Iphone was recognized, drivers loaded, and Itunes saw the device.

    I was able to sync, even upgrade to the latest firmware. Here's a tip, set a USB device filter in VirtualBox that just limits it to devices with a Manufacturer of "Apple Inc." I had an issue with doing a restore because during the restore, the device appears slightly differently to the computer, and if you don't have the proper filters set up, the device will not appear to the guest OS automatically since the host OS sees it as a different device. That's why the best option is just to tell it to send all Apple USB devices through.

  • random

    Try this:

    From a terminal run the following command:

    1. Add yourself to the vboxusers group if not already there: -

      if [ "`grep vboxusers /etc/group|grep $USER`" == "" ] ;   
      then sudo usermod -G vboxusers -a $USER ; fi
      

    This works for Karmic 9.10 Host and Windows XP Guest

    From a terminal run the following command:

    1. This will check for your vbox user id which you'll need for the next steps. This will display a line that looks a bit like this: vboxusers:x:123:myself 123 is the user id of your machine you're looking for

      grep vbox /etc/group
      
    2. This will edit your FSTAB File

       sudo gedit /etc/fstab
      
    3. Add the following line to the bottom of the fstab file: Replace userid with the number displayed from step 1.

       none /proc/bus/usb usbfs devgid=userid,devmode=664 0 0 
      

    Example: none /proc/bus/usb usbfs devig=123,devmod=664 0 0

    1. Reboot Ubuntu 9.10

    2. Once logged into Ubuntu 9.10 start VirtualBox (Don't power on a guest OS yet)

    3. Click Settings from the VirtualBox main page for the Windows XP Guest OS

    4. Click the System tab on the left side of screen

      • Enable IO APIC is needs to be selected
    5. Click the USB tab on the left side of screen

      • Enable USB Controller and Enable USB 2.0 (EHCI) Controller need to be selected
      • Your USB device should be recognized and ticked in the lower screen. If not, press the 'add' button (to the far right, 2nd one with the green cross) and add it.
    6. Power on your Guest OS and USB should work

    From Set up USB for Virtualbox at the Ubuntu forums.

  • Area 51

    Heres how I do it.

    Run itunes under VB and plug your iphone/itouch whatever in. On the linux desktop you'll see an icon for the new device. Select it and unmount it. Then go to VB and right click the USB icon down the bottom and put a click in the box for your device. XP under VB will know see the device.

    No commands, nothing else to install, no files to edit.