Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Switching clock synchronization off under Debian

  1. Oct 10, 2018 #1

    Borek

    User Avatar

    Staff: Mentor

    I am working on a project* in which I need to fake a pendrive so that it looks like if it was used for several years. That means copying files, making directories, removing them and so on. It needs to be done in such a way that all dates looks OK, which makes it less trivial than it sounds.

    While the pendrive is FAT formatted and tries to look as if it was used under Windows, it is easier to script the operation under Unix. I have Debian installed in VBox. And here is the problem - I am unable to stop Debian from synchronizing time.

    I already did it in the spring, then using timedatectl set-ntp false to stop NTP was enough. For some reason now after several operations/seconds (not sure yet what it is that triggers synchronization) my system clock is back to the current.

    Any idea how to stop the clock from synchronizing?

    Note: the most obvious approach to setting up dates (using touch) doesn't work - it sets up only one of three dates assigned to every file in FAT, so for someone savvy it is obvious it was tampered with.

    *In case you wonder - here is the project page: facebook.com/PDZWT (in Polish), first version was published in June, but it contained some mistakes and I want to start from scratch.
     
  2. jcsd
  3. Oct 10, 2018 #2

    Vanadium 50

    User Avatar
    Staff Emeritus
    Science Advisor
    Education Advisor
    2017 Award

    touch -d date doesn't work?
     
  4. Oct 10, 2018 #3

    Borek

    User Avatar

    Staff: Mentor

    Actually it sets two of the three dates. Still, one to go.
     
  5. Oct 11, 2018 #4

    Vanadium 50

    User Avatar
    Staff Emeritus
    Science Advisor
    Education Advisor
    2017 Award

    To answer the question you asked, the most sureproof way to do this is to disconnect the network, reboot the machine, enter the time in the BIOS, and go. This is probably slow. A less foolproof way is to disable whichever network time package is being used (ntpd and chrony are the most popular, but it sounds like you have at least one more running than you think) and then reset the time through the shell. This is less foolproof since a) the system still keeps track of time internally, and b) there are certain expectations that are no longer the case (i.e. "safe to delete this temporary file").

    To answer the question you want to ask, the WindowsAPI has a function SetFileTime that allows for setting all three times. Maybe you can use WINE, but I don't think "easier to script" trumps "missing in the kernel API".
     
  6. Oct 11, 2018 #5

    Borek

    User Avatar

    Staff: Mentor

    No go, as I wrote in the opening post I am using Virtual Box. If I had a spare computer it would be a no-brainer.

    That's what timedatectl set-ntp false does.

    And I am using it in a different part of the project, where there are just a few files to generate and copy, not hundreds in tens of directories and directory trees.
     
  7. Oct 11, 2018 #6

    Vanadium 50

    User Avatar
    Staff Emeritus
    Science Advisor
    Education Advisor
    2017 Award

    But apparently it's not doing this.

    I don't see any way to do this subject to all of your constraints. The fundamental problem on the linux side is that "creation date" is not part of the Posix standard, but is part of the FAT32 file system.

    If you need linux only for scripting, why not use bash for Windows?
     
  8. Oct 12, 2018 #7

    Borek

    User Avatar

    Staff: Mentor

    That's something new to check.
     
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted