Switching clock synchronization off under Debian

  • Thread starter Borek
  • Start date
  • #1
Borek
Mentor
28,651
3,144
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.
 

Answers and Replies

  • #2
Vanadium 50
Staff Emeritus
Science Advisor
Education Advisor
26,708
10,261
touch -d date doesn't work?
 
  • #3
Borek
Mentor
28,651
3,144
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.
 
  • #4
Vanadium 50
Staff Emeritus
Science Advisor
Education Advisor
26,708
10,261
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".
 
  • #5
Borek
Mentor
28,651
3,144
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.

A less foolproof way is to disable whichever network time package is being used

That's what timedatectl set-ntp false does.

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.
 
  • #6
Vanadium 50
Staff Emeritus
Science Advisor
Education Advisor
26,708
10,261
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 jim mcnamara
  • #7
Borek
Mentor
28,651
3,144
If you need linux only for scripting, why not use bash for Windows?

That's something new to check.
 
  • #8
Vanadium 50
Staff Emeritus
Science Advisor
Education Advisor
26,708
10,261
Did you ever give bash for Windows a try? Did it work?
 
  • #9
Borek
Mentor
28,651
3,144
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
Borek
Mentor
28,651
3,144
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.
 

Related Threads on Switching clock synchronization off under Debian

Replies
3
Views
905
  • Last Post
Replies
1
Views
3K
Replies
14
Views
3K
  • Last Post
Replies
10
Views
2K
  • Last Post
Replies
2
Views
4K
  • Last Post
Replies
15
Views
3K
  • Last Post
Replies
20
Views
2K
  • Last Post
Replies
5
Views
2K
  • Last Post
Replies
2
Views
2K
Top