[solved] Error with LXC create


I have a question on lxc-create. While lxc-create -t download -n name works, the creation of containers with templates does not work. When I try to create a debian container with lxc-create -t debian -n name I get the following error message:

lxc-create -t debian -n debian
debootstrap is /usr/sbin/debootstrap
Checking cache download in /var/cache/lxc/debian/rootfs-stretch-amd64 ...
gpg: key 2B90D010: "Debian Archive Automatic Signing Key (8/jessie) <ftpmaster@debian.org>" not changed
gpg: Total number processed: 1
gpg:              unchanged: 1
Downloading debian minimal ...
/usr/sbin/debootstrap: line 489: can't create /var/cache/lxc/debian/partial-stretch-amd64/test-dev-null: Permission denied
E: Cannot install into target '/var/cache/lxc/debian/partial-stretch-amd64' mounted with noexec or nodev
Failed to download the rootfs, aborting.
Failed to download 'debian base'
failed to install debian
lxc-create: debian: lxccontainer.c: create_run_template: 1473 container creation template for debian failed
lxc-create: debian: tools/lxc_create.c: main: 329 Error creating container debian

Any idea how to fix that? I have installed buildroot but there seems to be something missing to use the template.

Yeah... I ran into that.... it has to do with the way the debootstrap / lxc setup scripts setup a tmp download dir.... from memory the place ( /var/cache/lxc/debian ) is mounted with "nodev" -o mount option.....

I tried a few hacks.... from easiest to hardest;

  1. Use a manual setup command ( TBA will come back to fix... mixed results )
    1a. TBA
    1b. UNTESTED
export LXC_CACHE_PATH="/altcache"; <paste-lxc-create-command-here>
  1. Perhaps try mounting another fs under /var/cache/lxc ... and make sure it is mounted without nodev OR remount with dev might work... I think I has limited success with the latter

  2. hack the setup scripts directly..... spent a day or two on this... TBA will try to dig them up for you.....

find / | grep lxc | grep templates


#under here 
LXC_CACHE_PATH="/altcache" #<ADDEDtoOVERRIDEdefault see 1b or conf files
cache="/altcache" #<ADDED

debootstrap --verbose --variant=minbase --arch=$arch \
        --include=$packages --keyring=${releasekeyring} \
        "$release" "$cache/partial-$release-$arch" $MIRROR
1 Like

Thank you, I will probably try 2. 3 seems really scary... I will report back.

Hi Wolfy,

Apologies for the late reply. I was busy with other things. Your comments put me on the right track. I changed the LOCALSTATEDIR in /usr/share/lxc/templates. This solved my problem.

Thank you!

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.