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.

  1. 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.
  2. 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.

The Author

Klaus Knopper is an engineer, creator of Knoppix, and co-founder of LinuxTag expo. He works as a regular professor at the University of Applied Sciences, Kaiserslautern, Germany. If you have a configuration problem, or if you just want to learn more about how Linux works, send your questions to: klaus@linux-magazine.com

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Ask Klaus!

    Klaus Knopper is the creator of Knoppix and co-founder of LinuxTag expo. He currently works as a teacher, programmer, and consultant. If you have a configuration problem, or if you just want to learn more about how Linux works, send your questions to: klaus@linux-magazine.com

  • Ask Klaus!
  • Practical Knoppix

    Knoppix creator Klaus Knopper shares some tips for using Knoppix in the real world.

  • Ask Klaus!

    Klaus Knopper is the creator of Knoppix and co-founder of LinuxTag expo. He currently works as a teacher, programmer, and consultant. If you have a configuration problem, or if you just want to learn more about how Linux works, send your questions to: klaus@linux-magazine.com

  • Ask Klaus!

    Klaus Knopper is the creator of Knoppix and co-founder of LinuxTag expo. He works as a teacher, programmer, and consultant. If you have a configuration problem, or if you just want to learn more about how Linux works, send your questions to: klaus@linux-magazine.com

comments powered by Disqus

Direct Download

Read full article as PDF:

Price $2.95

News