Switching clock synchronization off under Debian

Click For Summary

Discussion Overview

The discussion revolves around the challenge of preventing clock synchronization in a Debian environment while attempting to manipulate file timestamps on a FAT-formatted pendrive. Participants explore various methods to achieve this, considering the implications of different approaches in a virtualized setting.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant describes a project requiring the simulation of file usage over several years, emphasizing the need for accurate timestamp manipulation.
  • Another participant suggests using the command touch -d date to set file dates, but acknowledges it only modifies two of the three timestamps on FAT files.
  • A different participant proposes disconnecting the network and setting the BIOS time as a foolproof method to prevent synchronization, while noting the limitations of this approach in a virtual machine context.
  • Some participants discuss the effectiveness of disabling network time synchronization services, such as ntpd and chrony, but express uncertainty about whether this method is fully effective.
  • One participant mentions the Windows API function SetFileTime as a potential solution for setting all three timestamps, suggesting the use of WINE for compatibility.
  • Another participant questions the necessity of using Linux for scripting, proposing the use of Bash for Windows as an alternative.
  • A later reply indicates that the original poster found success with Raspbian, where they could disable the NTP daemon.
  • One participant shares an update about using Ubuntu for Windows, noting its functionality for automating tasks related to data collection.

Areas of Agreement / Disagreement

Participants express differing opinions on the effectiveness of various methods to prevent time synchronization, and there is no consensus on a definitive solution. The discussion remains unresolved regarding the best approach to manipulate file timestamps accurately.

Contextual Notes

Participants highlight limitations related to the handling of file timestamps in FAT versus POSIX systems, and the challenges posed by operating within a virtualized environment. There are also unresolved questions about the reliability of disabling network time synchronization.

Borek
Mentor
Messages
29,183
Reaction score
4,620
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.
 
Computer science news on Phys.org
touch -d date doesn't work?
 
Borek said:
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.

Actually it sets two of the three dates. Still, one to go.
 
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".
 
Vanadium 50 said:
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.

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.

Vanadium 50 said:
A less foolproof way is to disable whichever network time package is being used

That's what timedatectl set-ntp false does.

Vanadium 50 said:
To answer the question you want to ask, the WindowsAPI has a function SetFileTime

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.
 
Borek said:
timedatectl set-ntp false does.

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?
 
  • Like
Likes   Reactions: jim mcnamara
Vanadium 50 said:
If you need linux only for scripting, why not use bash for Windows?

That's something new to check.
 
Did you ever give bash for Windows a try? Did it work?
 
Vanadium 50 said:
Did you ever give bash for Windows a try? Did it work?

Nope, I finally made the final version on Raspbian, where I was able to switch the ntpd down.

Bash for Windows sounds like an interesting project, I have it on my "check in a spare time" list.
 
  • #10
Update: Ubuntu for Windows. Haven't tested it thoroughly, but at least some basic things that I needed to automate collecting data from the Raspberry Pi camera mounted in the bird house worked as expected.

From what I understand it will be somehow further integrated into power shell soon, no idea about the details.
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 10 ·
Replies
10
Views
3K
Replies
1
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 25 ·
Replies
25
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
Replies
10
Views
5K
  • · Replies 38 ·
2
Replies
38
Views
9K
  • · Replies 13 ·
Replies
13
Views
4K
Replies
14
Views
5K