(For the lxc flow only) This task is a prerequisite for installing each of the multiple instances of vSLX on the server.
Note
Although this legacy, unscripted flow is still supported, we recommend the scripted flow under Container installation (multiple vSLX labs).Note
Although all sudo users can create and access all containers, our user in this flow isvlab1_user
, created in
Creating additional Linux users.
lxc
, using the following commands, confirming prompts to continue.
vlab1_user@ubuntu:~$ sudo apt-get update vlab1_user@ubuntu:~$ sudo apt-get install lxc
vlab1_user@ubuntu:~$ sudo lxc-create --name VLAB1 --template download --bdev dir -- --dist ubuntu --release xenial --arch amd64 --force-cache --no-validate --server images.linuxcontainers.org
Note
Because the previous example did not specify-P <directory-path>
, the VLAB1 container is created in the default directory path,
/var/lib/lxc. Command syntax is as follows:
sudo lxc-create [ -P <directory-path> ] --name <container-name> --template download --bdev dir -- --dist ubuntu --release xenial --arch amd64 --force-cache --no-validate --server images.linuxcontainers.org
vlab1_user@ubuntu:/slxos-dist$ sudo ls /var/lib/lxc
vlab1_user@ubuntu:/slxos-dist$ sudo vi /var/lib/lxc/VLAB1/rootfs/root/mkdev.sh
#!/bin/bash # # LXC autodev hook for Ubuntu 16 Container # # Some required device files for vSLX are # not imported inside the container. So manually # create them. # croot=${LXC_ROOTFS_MOUNT} for i in `/usr/bin/seq 0 7` do /bin/mknod $croot/dev/loop$i b 7 $i done mknod $croot/dev/loop-control c 10 237 for j in `/usr/bin/seq 0 11` do /bin/mknod $croot/dev/dm-$j b 252 $j done /bin/mkdir -p $croot/dev/net /bin/mknod $croot/dev/net/tun c 10 200 exit 0
vlab1_user@ubuntu:/slxos-dist$ sudo chmod +x /var/lib/lxc/VLAB1/rootfs/root/mkdev.sh vlab1_user@ubuntu:/slxos-dist$ sudo ls -l /var/lib/lxc/VLAB1/rootfs/root/mkdev.sh -rwxr-xr-x 1 root root 453 May 2 16:13 /var/lib/lxc/VLAB1/rootfs/root/mkdev.sh
vlab1_user@ubuntu:/slxos-dist$ sudo vi /var/lib/lxc/VLAB1/config
# Template used to create this container: /usr/share/lxc/templates/lxc-download # Parameters passed to the template: --dist ubuntu --release xenial --arch amd64 # --force-cache --no-validate --server images.linuxcontainers.org # Template script checksum (SHA-1): 9748088977ba845f625e45659f305a5395c2dc7b # For additional config options, please look at lxc.container.conf(5) # Uncomment the following line to support nesting containers: #lxc.include = /usr/share/lxc/config/nesting.conf # (Be aware this has security implications) # Distribution configuration lxc.include = /usr/share/lxc/config/ubuntu.common.conf lxc.arch = x86_64 # Container specific configuration lxc.rootfs = /var/lib/lxc/VLAB1/rootfs lxc.rootfs.backend = dir lxc.utsname = VLAB1 # Network configuration lxc.network.type = veth lxc.network.link = lxcbr0 <-- Change it to br0 lxc.network.flags = up lxc.network.hwaddr = 00:16:3e:b5:7d:b9
# Template used to create this container: /usr/share/lxc/templates/lxc-download # Parameters passed to the template: --dist ubuntu --release xenial --arch amd64 # --force-cache --no-validate --server images.linuxcontainers.org # Template script checksum (SHA-1): 9748088977ba845f625e45659f305a5395c2dc7b # For additional config options, please look at lxc.container.conf(5) # Uncomment the following line to support nesting containers: #lxc.include = /usr/share/lxc/config/nesting.conf # (Be aware this has security implications) # Distribution configuration lxc.include = /usr/share/lxc/config/ubuntu.common.conf lxc.arch = x86_64 # Container specific configuration lxc.rootfs = /var/lib/lxc/VLAB1/rootfs lxc.rootfs.backend = dir lxc.utsname = VLAB1 # Network configuration lxc.network.type = veth lxc.network.link = br0 <-- Changed from lxcbr0 lxc.network.flags = up lxc.network.hwaddr = 00:16:3e:b5:7d:b9 # vSLX configuration <-- You need to add the folllowing sections: lxc.aa_profile = unconfined lxc.cgroup.devices.allow = c 10:236 rwm lxc.cgroup.devices.allow = b 252:* rwm lxc.cgroup.devices.allow = b 7:* rwm # Expose tun device lxc.cgroup.devices.allow = c 10:200 rwm # To export SLX-OS distribution directory into the container. Change paths as needed. # The following implementation uses container /slxos directory as the container # mount point to access the SLX-OS software distribution. # The host-specific path for the same directory is /var/lib/lxc/VLAB1/rootfs/slxos. # This implementation mounts your_user's home directory to the mount point /slxos. lxc.mount.entry = /slxos-dist /var/lib/lxc/VLAB1/rootfs/slxos-dist none bind 0 0 # syntax: /<SLX-OS-Build-dir>/slxos-dist <directory-path>/<container-name>/rootfs/slxos # none bind 0 0 lxc.cgroup.devices.allow = c 10:237 rwm lxc.autodev = 1 lxc.hook.autodev = ${LXC_ROOTFS_MOUNT}/root/mkdev.sh
vlab1_user@ubuntu:/slxos-dist$ sudo mkdir /var/lib/lxc/VLAB1/rootfs/slxos-dist