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
HRJ
  • 225
  • 2
  • 10

4 Answers4

2
  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
Ian Macintosh
  • 955
  • 1
  • 6
  • 12
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?

mc0e
  • 5,866
  • 18
  • 31
0

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

Mircea Vutcovici
  • 17,619
  • 4
  • 56
  • 83
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).

tim
  • 1,217
  • 3
  • 11
  • 23