[pkg-lxc-devel] Bug#859220: Script /usr/share/lxcfs/lxc.mount.hook fails with mount command error 32 and causes lxc-start to fail

Tony Thedford tony at accesslab.com
Fri Mar 31 18:12:19 UTC 2017


Package: lxc
Version: 2.0.7-2~bpo8+1

When I invoke the lxc-start command, it fails to start the container and 
outputs this error information:

lxc-start 20170330232720.943 ERROR    lxc_conf - conf.c:run_buffer:405 - 
Script exited with status 32.
       lxc-start 20170330232720.943 ERROR    lxc_conf - 
conf.c:lxc_setup:3890 - failed to run mount dhooks for container 
'debian8-base'.
       lxc-start 20170330232720.943 ERROR    lxc_start - 
start.c:do_start:811 - Failed to setup container "debian8-base".
       lxc-start 20170330232720.943 ERROR    lxc_sync - 
sync.c:__sync_wait:57 - An error occurred in another process (expected 
sequence number 3)
       lxc-start 20170330232720.944 ERROR    lxc_start - 
start.c:__lxc_start:1346 - Failed to spawn container "debian8-base".
       lxc-start 20170330232726.454 ERROR    lxc_start_ui - 
tools/lxc_start.c:main:366 - The container failed to start.
       lxc-start 20170330232726.454 ERROR    lxc_start_ui - 
tools/lxc_start.c:main:368 - To get more details, run the container in 
foreground mode.
       lxc-start 20170330232726.454 ERROR    lxc_start_ui - 
tools/lxc_start.c:main:370 - Additional information can be obtained by 
setting the --logfile and --logpriority options.

I traced the problem back to these lines in the script 
/usr/share/lxcfs/lxc.mount.hook:

         # Mount the new entries
         for entry in /var/lib/lxcfs/cgroup/*; do
             DEST=$(basename $entry)

             if [ "$DEST" = "name=systemd" ]; then
                 DEST="systemd"
             fi

             if [ ! -d ${LXC_ROOTFS_MOUNT}/sys/fs/cgroup/${DEST} ]; then
                 mkdir ${LXC_ROOTFS_MOUNT}/sys/fs/cgroup/${DEST}
             fi

             mount -n --bind $entry 
${LXC_ROOTFS_MOUNT}/sys/fs/cgroup/$DEST    <-- ERROR 32 thrown here 
causing program to exit since shell bang line includes bash set -e option.

The mount error is caused by the $entry variable containing the exact 
string '/var/lib/lxcfs/cgroup/*' which is never a valid directory and 
cannot be mounted. The error condition of entry = 
'/var/lib/lxcfs/cgroup/*' is happening because the enclosing 'for' loop 
returns this string in the case where there are no files contained in 
the folder /var/lib/lxcfs/cgroup/ which is correct for bash operation. 
To work around this condition I modified my 
/usr/share/lxcfs/lxc.mount.hook script file as follows:

         # Mount the new entries
         for entry in /var/lib/lxcfs/cgroup/*; do
             DEST=$(basename $entry)

########### Tony inserted this FIX ##############
             if [ "$DEST" = "*" ]; then
                 break
             fi
#################################################

             if [ "$DEST" = "name=systemd" ]; then
                 DEST="systemd"
             fi

             if [ ! -d ${LXC_ROOTFS_MOUNT}/sys/fs/cgroup/${DEST} ]; then
                 mkdir ${LXC_ROOTFS_MOUNT}/sys/fs/cgroup/${DEST}
             fi

             mount -n --bind $entry ${LXC_ROOTFS_MOUNT}/sys/fs/cgroup/$DEST

This seems to have fixed the problem and my computer lxc operation 
appears to be working Ok now.

I am using Debian GNU/Linux 8 (jessie), kernel version 3.16.39-1+deb8u2, 
libc6 2.19-18+deb8u7, bash version 4.3.30(1)-release, dash version 
0.5.7-4+b1

Thanks



More information about the Pkg-lxc-devel mailing list