debugfs: Cannot set the last write time to zero
For Qubes OS, I am trying to reset the last write time of an ext3 filesystem to zero, to ensure reproducible builds. Unfortunately, this doesn’t work.
It's not possible to set the last write time to be zero, currently. The superblock last write time is set when the file system is closed in libext2fs. From line 304 in lib/ext2fs/closefs.c:
fs->super->s_wtime = fs->now ? fs->now : time(NULL);
It is possible to set the last write time to be some other value, but a certain amount of trickery is required:
% debugfs -w /tmp/foo.img debugfs: ssv wtime 19990102 debugfs: set_current_time 19990102 Setting current time to Fri Jan 1 19:00:00 1999
debugfs: quit
% dumpe2fs -h /tmp/foo.img | grep "Last write time" dumpe2fs 1.46.4 (18-Aug-2021) Last write time: Fri Jan 1 19:00:00 1999
"And we'll party like it's 1999" :-)