Install fuse powered filesystems within an LXC container

I’m running a Debian Squeeze in an LXC container, and i needed to install SSHFS within the container, a FUSE based filesystem which lets you to mount remote filesystems through SSH. It shouldn’t be a problem, but fuse-utils depends on udev, and as you may know, LXC containers do not support udev, which will cause problems during the install.
While installing the udev package you’ll get some errors related with device creation like the following one:

Populating the new /dev filesystem temporarily mounted on /tmp/udev.EgkS50/...
mknod: `//tmp/udev.EgkS50/ppp': Operation not permitted

In order to solve this i had to allow those new devices to be created in your container’s configuration file by adding the following lines:

#ppp
lxc.cgroup.devices.allow = c 108:0 rwm
#fuse
lxc.cgroup.devices.allow = c 10:229 rwm
#loop0
lxc.cgroup.devices.allow = b 7:0 rwm
#tun
lxc.cgroup.devices.allow = c 10:200 rwm

Now start your container and login.
Then, because the udev install will break your created devices, you should backup them:

user@host:~$ sudo cp -a /dev /dev.old

Go and install your fuse based filesystem, i’ll be installing sshfs:

user@host:~$ sudo apt-get install sshfs

Restore your old devices:

user@host:~$ sudo cp -a /dev.old/* /dev/

Create the fuse device:

user@host:~$ sudo mknod /dev/fuse c 10 229

Avoid udev to boot by disabling its init scripts:

user@host:~$ sudo update-rc.d -f udev disable

And that’s it, you should now be able to mount your fuse powered filesystem :-)

Advertisements
  1. Hi! Please help me.

    sudo lxc-start -n squeeze-sshfs-container
    INIT: version 2.88 booting
    Using makefile-style concurrent boot in runlevel S.
    .udev/ already exists on the static /dev! … (warning).
    mknod: `//dev/loop0′: Operation not permitted
    Starting the hotplug events dispatcher: udevd.
    Synthesizing the initial hotplug events…done.
    Waiting for /dev to be fully populated…
    ^CActivating swap…done.
    Cleaning up ifupdown….
    Setting up networking….
    Activating lvm and md swap…done.
    Checking file systems…fsck from util-linux-ng 2.17.2
    done.
    Mounting local filesystems…done.
    Activating swapfile swap…done.
    Cleaning up temporary files….
    Configuring network interfaces…done.
    Cleaning up temporary files….
    Setting kernel variables …done.
    startpar: service(s) returned failure: udev … failed!

  2. config file:

    lxc.tty = 4
    lxc.pts = 1024
    lxc.rootfs = /var/lib/lxc/squeeze-sshfs-container/rootfs
    lxc.cgroup.devices.deny = a
    # /dev/null and zero
    lxc.cgroup.devices.allow = c 1:3 rwm
    lxc.cgroup.devices.allow = c 1:5 rwm
    # consoles
    lxc.cgroup.devices.allow = c 5:1 rwm
    lxc.cgroup.devices.allow = c 5:0 rwm
    lxc.cgroup.devices.allow = c 4:0 rwm
    lxc.cgroup.devices.allow = c 4:1 rwm
    # /dev/{,u}random
    lxc.cgroup.devices.allow = c 1:9 rwm
    lxc.cgroup.devices.allow = c 1:8 rwm
    lxc.cgroup.devices.allow = c 136:* rwm
    lxc.cgroup.devices.allow = c 5:2 rwm
    # rtc
    lxc.cgroup.devices.allow = c 254:0 rwm
    #ppp
    lxc.cgroup.devices.allow = c 108:0 rwm
    # mounts point
    lxc.mount.entry=proc /var/lib/lxc/squeeze-sshfs-container/rootfs/proc proc node$
    lxc.mount.entry=devpts /var/lib/lxc/squeeze-sshfs-container/rootfs/dev/pts devp$
    lxc.mount.entry=sysfs /var/lib/lxc/squeeze-sshfs-container/rootfs/sys sysfs def$
    lxc.network.type = veth
    lxc.network.flags = up
    lxc.network.link = br0
    lxc.network.ipv4 = 10.66.6.20/24
    lxc.network.name = eth0

  3. sudo lxc-start -n squeeze-sshfs-container
    lxc-start: write /cgroup/squeeze-sshfs-container/devices.allow : Invalid argument
    lxc-start: failed to setup the cgroups for ‘squeeze-sshfs-container’
    lxc-start: failed to setup the container
    lxc-start: invalid sequence number 1. expected 2
    lxc-start: failed to spawn ‘squeeze-sshfs-container’

  4. Thanks for a great article.

  5. I would like to thnkx for the efforts you have put in writing this site. I am hoping the same high-grade site post from you in the upcoming also. Actually your creative writing skills has encouraged me to get my own web site now. Actually the blogging is spreading its wings rapidly. Your write up is a great example of it.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: