Skip to content

Instantly share code, notes, and snippets.

@gionn
Created November 21, 2013 16:49
Show Gist options
  • Save gionn/7585324 to your computer and use it in GitHub Desktop.
Save gionn/7585324 to your computer and use it in GitHub Desktop.
How to enable bind mount inside lxc container

How to enable bind mount inside lxc container

When mount is returning:

STDERR: mount: block device /srv/database-data/postgres is write-protected, mounting read-only
mount: cannot mount block device /srv/database-data/postgres read-only

and dmesg shows:

[ 6944.194280] type=1400 audit(1385049795.420:32): apparmor="DENIED" operation="mount" info="failed type match" error=-13 parent=6631 profile="lxc-container-default" name="/var/lib/postgresql/9.1/main/" pid=6632 comm="mount" srcname="/srv/database-data/postgres/" flags="rw, bind"

AppArmor is blocking mount -o bind inside the LXC container.

To enable id add in /etc/apparmor.d/lxc/lxc-default:

profile lxc-container-default flags=(attach_disconnected,mediate_deleted) {
  ...
    mount options=(rw, bind),
  ...

Reload apparmor:

# /etc/init.d/apparmor reload
@AdaLovelance
Copy link

Thanks so much!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment