小智 0
您可以挂载为 rootfs squashfs 映像,但它是只读的。
mount: warning: /var/lib/lxc/busy2/rootfs/ seems to be mounted read-only.
Run Code Online (Sandbox Code Playgroud)
您应该在squashfs 上再有一层,例如aufs。
这项技术在Slax中大量使用。
您可以手动重复此操作。进行真正的lxc配置,然后通过aufs层将squashfs映像安装到rootfs目录。
从手册页:
# sudo mount -t aufs -o br:/rw_branch:/ro_branch none /aufs
Run Code Online (Sandbox Code Playgroud)
我对 busybox 的实验返回 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
Run Code Online (Sandbox Code Playgroud)
从楼主的角度看:
# 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 .
Run Code Online (Sandbox Code Playgroud)