9

On Ubuntu v14.04, I have a drive mounted at /mnt/log-overlay that I would like to mount over the top of /var/log.

The following mount command successfully creates that overlay, and works fine:

mount -t overlayfs -o lowerdir=/var/log,upperdir=/mnt/log-overlay overlayfs /var/log

What do I need to add to /etc/fstab to make sure this overlay mounts at boot?

LABEL=cloudimg-rootfs   /    ext4   defaults,discard    0 0
/dev/xvde   /mnt/log-overlay    auto    defaults,nobootwait,comment=cloudconfig 0   2
[what-goes-here?]
Zanna
  • 69,223
  • 56
  • 216
  • 327
Graham Leggett
  • 361
  • 1
  • 3
  • 6

1 Answers1

7

From the figure-it-out-as-you-post-the-question department.

The following /etc/fstab entry successfully mounts /mnt/log-overlay on top of /var/log at boot:

overlayfs   /var/log    overlayfs   defaults,lowerdir=/var/log,upperdir=/mnt/log-overlay,comment=cloudconfig    0   2

Previous fstab entries:

LABEL=cloudimg-rootfs   /    ext4   defaults,discard    0 0
/dev/xvde   /mnt/log-overlay    auto    defaults,nobootwait,comment=cloudconfig 0   2
Zanna
  • 69,223
  • 56
  • 216
  • 327
Graham Leggett
  • 361
  • 1
  • 3
  • 6
  • 2
    FYI if your overlay mount references other non-root disks, there is no deterministic guarantee those will be available when the overlay mount is processed (mounts are forked in parallel). This will cause a mount failure during reboots - and enter into maintenance mode. To avoid this add the `noauto` to the (4th) options field. And add a post-boot script to mount the overlay when all local disks are up. – colm.anseo May 13 '19 at 15:28
  • Good point @colminator. That "post-boot script" could also be the mount command directly... – Matthieu Dec 09 '19 at 15:02