Klaus Knopper answers your Linux questions
Mountpoint Dates
Good day Klaus, I have noticed the following anomaly and would appreciate your comments. All of the following are performed as root.
- I create a new mountpoint with today's date, of course. I mount a device (USB stick or hard drive partition) onto this mountpoint and look at its date. Knoppix 7.3 (also vs. 7.5) in text mode shows 31 Dec 1969. Others (SystemRescueCd, INX, and TRK) show 1 Jan 1970 00h00. Close enough. This minor difference is not the issue. Unmounting the device (
umount
) causes the mountpoint's date to change back to today's date. - An already existing mountpoint will have its own date (e.g., 7 Sep 2012). While a device is mounted here, the mountpoint date shows as 1 Jan 1970 (epoch time?), but after unmounting the device (
umount
), the mountpoint date reverts to its original 7 Sep 2012 date.
Any clarification you can provide for this strange behavior would be much appreciated.
Regards,
Ted
Hello, Ted. Apart from a small time difference between Knoppix and other distros, the effect you described with changing mountpoint dates has a perfectly natural cause.
First, about the time difference: Most computers have a built-in battery-backed clock, so the system knows the correct date and time as soon as its booted up by looking up the BIOS time. The command responsible for that is
sudo hwclock
which will read the hardware registers and show you the clock time, independent of the time known by the running operating system, where the system time can be retrieved by date.
Because there are many timezones on the globe, an offset is added or subtracted by the setting stored in /etc/timezone
. Because Knoppix has no way of knowing where your computer is based geographically without using some kind of network geolocation service (which I don't do because of privacy reasons), the timezone for English versions of Knoppix is preset to UTC (Universal Time).
Your battery-backed clock, on the other hand, is assumed by Knoppix to contain the "local time" – as in most Windows versions (so you get the same time on both OSes) – whereas other distros also use UTC, which may be more common with Unix-ish systems. The timezone difference may explain the time offset when looking at file and directory timestamps.
Metadata such as permissions and dates are stored independently from the file data, so the software writing files may choose not to set any additional information. This would leave permissions and dates in the default state, which is most likely "all bits set to zero," except for the file geometry, which indicates locations and sizes of a file's chunks on the physical device.
If you get a file date display of something like 1.1.1970, it means that the file's timestamp, which is measured in seconds since 1.1.1970 (the "epoch," as you wrote) is set to zero. Some embedded electronic devices do this when storing video and photo data because they have no internal clock from which to get the correct date, or just for simplicity of the file writing algorithms.
Now for the mountpoint dates: The root directory of a filesystem, which is the uppermost directory containing all the files and directories on the partition (and the only one that has no directory name because of its top position in the directory hierarchy), also has permissions and file dates. So, the date displayed for the mountpoint on your system before mounting the partition is just the local date set on that directory. This changes, however, after mounting the filesystem; then, it becomes the date of the root directory set in the mounted filesystem. The original directory permissions and dates of the local mountpoint directory are just shadowed by the mounted device, and they will become visible again after unmounting the filesystem.
If you change the date of the mountpoint while a filesystem mount is active there, you will change that date on the mounted device, not on the local directory. The command
sudo touch /media/sdb1
will set the date of the local directory named /media/sdb1
to the current time in case there is no filesystem mounted there. However, the same command will set the date of the root directory of a mounted device, instead, when issued after the mount
command.
Infos
« Previous 1 2
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Thousands of Linux Servers Infected with Stealth Malware Since 2021
Perfctl is capable of remaining undetected, which makes it dangerous and hard to mitigate.
-
Halcyon Creates Anti-Ransomware Protection for Linux
As more Linux systems are targeted by ransomware, Halcyon is stepping up its protection.
-
Valve and Arch Linux Announce Collaboration
Valve and Arch have come together for two projects that will have a serious impact on the Linux distribution.
-
Hacker Successfully Runs Linux on a CPU from the Early ‘70s
From the office of "Look what I can do," Dmitry Grinberg was able to get Linux running on a processor that was created in 1971.
-
OSI and LPI Form Strategic Alliance
With a goal of strengthening Linux and open source communities, this new alliance aims to nurture the growth of more highly skilled professionals.
-
Fedora 41 Beta Available with Some Interesting Additions
If you're a Fedora fan, you'll be excited to hear the beta version of the latest release is now available for testing and includes plenty of updates.
-
AlmaLinux Unveils New Hardware Certification Process
The AlmaLinux Hardware Certification Program run by the Certification Special Interest Group (SIG) aims to ensure seamless compatibility between AlmaLinux and a wide range of hardware configurations.
-
Wind River Introduces eLxr Pro Linux Solution
eLxr Pro offers an end-to-end Linux solution backed by expert commercial support.
-
Juno Tab 3 Launches with Ubuntu 24.04
Anyone looking for a full-blown Linux tablet need look no further. Juno has released the Tab 3.
-
New KDE Slimbook Plasma Available for Preorder
Powered by an AMD Ryzen CPU, the latest KDE Slimbook laptop is powerful enough for local AI tasks.