2017-03-04

Start a pristine, minimal SUSE system in an LXC container (no Docker)

Going through some old emails I stumbled upon some instructions from Thorsten Behrens on bringing up a clean, minimal SUSE environment in an LXC container using libvirt-lxc. Obviously that could be useful for testing things. I tried it on the laptop and tweaked it for Leap 42.2:

sudo zypper in lxc libvirt virt-install
sudo systemctl start libvirtd.service
mkdir libvirt
INSTALL_ROOT=/home/smithfarm/libvirt  # must be full path
sudo zypper \
    --root $INSTALL_ROOT \
    addrepo \
    http://download.opensuse.org/distribution/leap/42.2/repo/oss/ \
    repo-oss
sudo zypper \
    --non-interactive \
    --gpg-auto-import-keys \
    --root $INSTALL_ROOT \
    install \
    --auto-agree-with-licenses \
    aaa_base rpm zypper wget vim   # downloads and installs a bunch of stuff
sudo virsh net-start default       # does not happen automatically
sudo virt-install \
     --connect lxc:/// \
     --os-variant opensuse42.2 \
     --name opensuse42.2 \
     --ram 1024 \
     --filesystem $INSTALL_ROOT,/

This works and gets me to a login prompt, but I don't know the root password.

Break out of the container with "CTRL-]". Re-enter with:

sudo virsh --connect lxc:/// console opensuse42.2

Change the root password (or execute an arbitrary command as "root"):

sudo virsh -c lxc:/// lxc-enter-namespace opensuse42.2 --noseclabel /usr/bin/passwd

No comments:

Post a Comment