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
-
Linux Servers Targeted by Akira Ransomware
A group of bad actors who have already extorted $42 million have their sights set on the Linux platform.
-
TUXEDO Computers Unveils Linux Laptop Featuring AMD Ryzen CPU
This latest release is the first laptop to include the new CPU from Ryzen and Linux preinstalled.
-
XZ Gets the All-Clear
The back door xz vulnerability has been officially reverted for Fedora 40 and versions 38 and 39 were never affected.
-
Canonical Collaborates with Qualcomm on New Venture
This new joint effort is geared toward bringing Ubuntu and Ubuntu Core to Qualcomm-powered devices.
-
Kodi 21.0 Open-Source Entertainment Hub Released
After a year of development, the award-winning Kodi cross-platform, media center software is now available with many new additions and improvements.
-
Linux Usage Increases in Two Key Areas
If market share is your thing, you'll be happy to know that Linux is on the rise in two areas that, if they keep climbing, could have serious meaning for Linux's future.
-
Vulnerability Discovered in xz Libraries
An urgent alert for Fedora 40 has been posted and users should pay attention.
-
Canonical Bumps LTS Support to 12 years
If you're worried that your Ubuntu LTS release won't be supported long enough to last, Canonical has a surprise for you in the form of 12 years of security coverage.
-
Fedora 40 Beta Released Soon
With the official release of Fedora 40 coming in April, it's almost time to download the beta and see what's new.
-
New Pentesting Distribution to Compete with Kali Linux
SnoopGod is now available for your testing needs