5

My host filesystem is ext4 mounted with the noatime flag. But inside an lxc-container, the flag is absent.

Here's the output of mount on the host: /dev/sdb1 on /home type ext4 (rw,noatime)

And here's the output of mount in the container: /dev/sdb1 on / type ext4 (rw)

I now have two questions:

1. Does it make a difference if noatime is set in the container?

My guess is yes.

2. What is the best way to set noatime for the container?

Ideally, I would like to configure such a way, that it honors the host's file system flags always.

Update The /proc/mounts shows slightly different entries:

rootfs / rootfs rw 0 0
/dev/sdb1 /home ext4 rw,noatime 0 0
2
  • Which Linux OS/distribution/version is involved here? – ewwhite Aug 29 '14 at 19:24
  • @ewwhite Ubuntu 14.04 – HRJ Aug 30 '14 at 1:28
2
+50
  1. It does make a difference. atime in the container functions as you would expect it to, having a negative impact on the performance.
  2. According to this ticket you need to use a workaround, using a mount hook instead of having LXC doing the mount for you
1

My guess is that when a system call writes to a file, the kernel code that implements that looks at the noatime flag's status and gets that info from the same kernel routine that provides the info to proc filesystem.

However, that's far from an authoritative view, and if it matters, you should verify it.

Does the atime actually get updated? Check in both the host and hosted system. I doubt the time is recorded differently, but again, that's a guess.

Depending how long you need to count on the answer being correct, you might also need to go hunting for an authoritative answer on what the behaviour is supposed to be. If this is not currently working as intended, it might change in future, and remember that LXC is still not all that far past it's first production release. Asking questions can help stabilise the answer, but maybe take it to an LXC developer list?

0

I think it is a bug in how /etc/mtime file is updated. Check /proc/mounts in both container and on the host.

1
  • I have updated my answer with the contents of /proc/mounts – HRJ Aug 30 '14 at 1:35
0

Not really an answer, more a thought: other then one would believe, the basic fs tools (mount,df) use /etc/mtime, which is simple textfile written by mount and other tools, as source for fs/mount information. If you are chrooted your /etc/mtab may or may not have contents reflecting the real situation on your system, depending on when the chrooted /etc/mtab was created. Your /etc/mtab in the container is obviously not reflecting the actual config (as seen in /proc/mounts).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.