Skip to content

Instantly share code, notes, and snippets.

@josep112
Forked from lmiphay/lxc-copy
Created May 13, 2021 13:20
Show Gist options
  • Save josep112/269c96d94247b7e9a16456e99cf2d6bd to your computer and use it in GitHub Desktop.
Save josep112/269c96d94247b7e9a16456e99cf2d6bd to your computer and use it in GitHub Desktop.
Cloning/copying an lxc on gentoo (lxc-copy / lxc-clone)
lxc-copy is the replacement for lxc-clone:
mkdir -p <new_lxc_path>
lxc-copy --name=<existing_lxc_name> --newname <new_lxc_name> --newpath /<new_lxc_path>
In the new container:
1. /etc/conf.d/hostname - set new hostname
2. /etc/conf.d/net - set new ip (if static ip)
3. /etc/hosts - add new ip/hostname
On the host:
1. add new ip to: /etc/hosts
2. cd /etc/init.d && ln -s lxc lxc.<new_lxc_name>
Test start with:
lxc-start --name=<new_lxc_name> --foreground --logpriority=DEBUG
Fixups:
1. Lots of errors starting the lxc like:
mkdir: cannot create directory '/sys/fs/cgroup/openrc/killprocs': Read-only file system
For a possible fix, see: https://github.com/lxc/lxc/issues/1095
lxc.mount.auto=cgroup:rw proc:mixed sys:mixed
(was: lxc.mount.auto=cgroup:mixed proc:mixed sys:mixed)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment