debootstrap nested in the LXC container fails to mount proc because of apparmor

The command that is run inside an amd64 LXC container:

debootstrap --arch armhf --foreign --variant=buildd --components=main,restricted,universe,multiverse vivid /var/lib/schroot/chroots/vivid-armhf 

Eventually fails like that:

W: Failure trying to run: mount -t proc proc /proc
W: See //debootstrap/debootstrap.log for details

The syslog on the host has this:

audit: type=1400 audit(1449495124.972:29): apparmor="DENIED" operation="mount" info="failed type match" error=-13 profile="lxc-container-default" name="/var/lib/schroot/chroots/vivid-armhf/proc/" pid=25739 comm="mount" fstype="proc" srcname="proc" flags="rw"
audit: type=1400 audit(1449495124.976:30): apparmor="DENIED" operation="mount" info="failed type match" error=-13 profile="lxc-container-default" name="/var/lib/schroot/chroots/vivid-armhf/proc/" pid=25739 comm="mount" fstype="proc" srcname="proc" flags="ro"

And it's really impossible to mount:

user@vm:~$ sudo chroot /var/lib/schroot/chroots/vivid-armhf
/usr/bin/groups: cannot find name for group ID 0
I have no name!@vm:/# mount -t proc proc /proc
mount: proc is write-protected, mounting read-only
mount: cannot mount proc read-only
I have no name!@vm:/#

What needs to be added to the LXC container config to allow such mount?

1 Answer

New profile:

sudo tee /etc/apparmor.d/lxc/lxc-default-with-proc-mounting <<EOM
profile lxc-default-with-proc-mounting flags=(attach_disconnected,mediate_deleted) { #include <abstractions/lxc/container-base> mount fstype=proc options=ro -> /**,
}
EOM

Into container config:

lxc.aa_profile = lxc-default-with-proc-mounting

Reload profiles:

sudo systemctl reload apparmor

Restart container.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like