Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Is it possible to use a SquashFS filesystem as an LXC rootfs? I can mount an ext3 image as a rootfs just by setting lxc.rootfs to the filename, but if it's any other type of image, lxc-start just says that it can't mount an ext3 filesystem. The lxc.conf man page doesn't suggest any way to specify the filesystem type.

Additionally, if I get past that stage, can you mount other loopback filesystems in the container just by using lxc.mount.entry entries with 'loop' in the options field?

share|improve this question
add comment

1 Answer 1

You can mount as rootfs squashfs image, but it would be read-only.

mount: warning: /var/lib/lxc/busy2/rootfs/ seems to be mounted read-only.

You should have another layer over squashfs, e.g. aufs.

This technique mass used in Slax.

You can repeat this just by hand. Make true lxc config, than mount your squashfs image to rootfs dir by aufs layer.

From man page:

# sudo mount -t aufs -o br:/rw_branch:/ro_branch none /aufs

My experiment with busybox return True:

# mount -o loop -t squashfs /var/busy/busy_rootfs.squashfs /var/busy/squashfs-mnt/
mount: warning: /var/busy/squashfs-mnt/ seems to be mounted read-only.
# mount -t aufs -o br:/var/busy/aufs-root/:/var/busy/squashfs-mnt/ none /var/lib/lxc/busy2/rootfs

# lxc-start --name busy2

udhcpc (v1.20.2) started
Sending discover...
Sending select for 10.0.3.105...
Lease of 10.0.3.105 obtained, lease time 3600

Please press Enter to activate this console.



BusyBox v1.20.2 (Ubuntu 1:1.20.0-8ubuntu1) built-in shell (ash)
Enter 'help' for a list of built-in commands.

/ # ls
ls
bin      etc      lib      mnt      root     selinux  usr
dev      home     lib64    proc     sbin     tmp      var

/ # touch root.file
touch root.file
/ # ls -latr root.file
ls -latr root.file
-rw-r--r--    1 root     root             0 Aug 23 12:38 root.file

Look from host:

# ls -latr /var/busy/aufs-root/
total 24
drwxr-xr-x 3 root root 4096 Aug 23 12:15 var
drwx------ 2 root root 4096 Aug 23 12:25 .wh..wh.plnk
drwx------ 2 root root 4096 Aug 23 12:25 .wh..wh.orph
-r--r--r-- 1 root root    0 Aug 23 12:25 .wh..wh.aufs
drwxr-xr-x 6 root root 4096 Aug 23 12:30 ..
drwxr-xr-x 2 root root 4096 Aug 23 12:38 dev
-rw-r--r-- 1 root root    0 Aug 23 12:38 root.file
drwxr-xr-x 6 root root 4096 Aug 23 12:39 .
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.