2011/11/13

LXC through the looking glass

Checklist for an lxc gentoo (taken from a pre-existing image) container hosted on gentoo:
  1. Start with Diego's static device tarball (to avoid TIOCSCTTY "open /dev/tty failed errors" "could not set controlling tty" from sshd)
  2. To see boot up messages and avoid warnings from /etc/issue add: mknod -m 600 console c 5 1
  3. Remove udev and all other not-relevant services (/etc/runlevels)
  4. The container config should have: 'lxc.tty = 12' and 'lxc.pts = 128'
  5. The container fstab should not have a /dev/pts devpts mount (cf newinstance mount option)
  6. Stop the guest init from running gettys as required.

Then all that is needed is:
  1. lxc-start -n konuk
  2. lxc-console -n konuk
  3. lxc-stop -n konuk

Debug

Useful for debugging are:
  1. List running processes in the lxc: pstree $(lxc-info -n sakc1 --pid | awk '{ print $2 }')
  2. The guest container log when the guest is started with: lxc-start -n konuk -l DEBUG -o /tmp/lxc.log
  3. The guest /var/log/auth.log (configure sshd to report to it - /etc/ssh/sshd_config)
Cherrypick patch from the staging lxc on github:

--- lxc-ps_orig    2012-11-21 21:19:11.000000000 +0000
+++ lxc-ps      2013-01-20 22:24:32.000000000 +0000
@@ -56,7 +56,8 @@
                init_cgroup=${fields#*:}
 
                # Get the filesystem mountpoint of the hierarchy
-               mountpoint=$(grep -E "^cgroup [^ ]+ [^ ]+ ([^ ]+,)?$subsystems(,[^ ]+)? " /proc/self/mounts | cut -d ' ' -f 2)
+               mountpoint=$(awk -v subsysregex="(^|,)$subsystems(,|\$)" \
+                           '$3 == "cgroup" && $4 ~ subsysregex {print $2}' /proc/self/mounts)
                if [ -z "$mountpoint" ]; then continue; fi
 
                # Return the absolute path to the containers' parent cgroup

fstab

sysfs needs to be mounted so that the net scripts can see the various network interfaces are present - they check for entries in: /sys/class/net

Add to the container fstab (note: localmount may not run):

...
sysfs                   /lxc/konuk/sys                  sysfs   defaults 0 0
...

The symptom is:

 * Bringing up interface lo
 *   Caching network module dependencies
 *   ERROR: interface lo does not exist
 *   Ensure that you have loaded the correct kernel module for your hardware
 * ERROR: net.lo failed to start

2011/11/12

Long delays ssh'ing into HP-UX

Easy to fix when you know:

# cd /var/adm
# cp /dev/null wtmps
# cp /dev/null btmps