Wednesday, May 11, 2016

Pro Tip: Do not remove 'kmod' in Ubuntu LXC Container. It removes '/sbin/init/'

Long story short: Do not remove the package 'kmod' on Ubuntu systems.  Various packages depend on this package, including cron and upstart.  Since upstart provides /sbin/init, the container will fail to start.

I was in the process of trimming down an LXC container and in doing so I noticed the 'kmod' package.  The description makes it seem like the perfect candidate for removal in an LXC container.

justin@deimos:~$ apt-cache show kmod

Description-en: tools for managing Linux kernel modules
 This package contains a set of programs for loading, inserting, and
 removing kernel modules for Linux.
 It replaces module-init-tools.
After removing this package, and the packages cron and upstart.  I then restarted my container... and after it failed to start, I enabled the log feature and found this error:

      lxc-start 1462981210.791 NOTICE   lxc_start - start.c:start:1152 - exec'ing '/sbin/init'      lxc-start 1462981210.791 ERROR    lxc_start - start.c:start:1155 - No such file or directory - failed to exec /sbin/init      lxc-start 1462981210.791 ERROR    lxc_sync - sync.c:__sync_wait:51 - invalid sequence number 1. expected 4      lxc-start 1462981210.791 ERROR    lxc_start - start.c:__lxc_start:1080 - failed to spawn 'lxc_container'

I thought I might have been fighting with previously closed bugs, but it turned out just to be be my own over zealousness in saving a few bytes of disk space. Oops!

No comments: