diff --git a/snapshots/overlay/overlay.go b/snapshots/overlay/overlay.go index 2222207a6..153e7aa81 100644 --- a/snapshots/overlay/overlay.go +++ b/snapshots/overlay/overlay.go @@ -70,6 +70,7 @@ type snapshotter struct { root string ms *storage.MetaStore asyncRemove bool + indexOff bool } // NewSnapshotter returns a Snapshotter which uses overlayfs. The overlayfs @@ -102,10 +103,17 @@ func NewSnapshotter(root string, opts ...Opt) (snapshots.Snapshotter, error) { return nil, err } + // figure out whether "index=off" option is recognized by the kernel + var indexOff bool + if _, err = os.Stat("/sys/module/overlay/parameters/index"); err == nil { + indexOff = true + } + return &snapshotter{ root: root, ms: ms, asyncRemove: config.asyncRemove, + indexOff: indexOff, }, nil } @@ -465,6 +473,11 @@ func (o *snapshotter) mounts(s storage.Snapshot) []mount.Mount { } var options []string + // set index=off when mount overlayfs + if o.indexOff { + options = append(options, "index=off") + } + if s.Kind == snapshots.KindActive { options = append(options, fmt.Sprintf("workdir=%s", o.workPath(s.ID)),