如何在 LXC 中创建 dm-crypt 设备?

如何在 LXC 中创建 dm-crypt 设备?

在一个 LXC 容器上,我需要放置敏感数据,最好存储在 dm-crypt 加密文件系统中。

当我写作时

sudo cryptsetup luksFormat --cipher aes-xts-plain --size 512 $MyDocsCryptDir/$MyDocsCryptFile

确认对话框后我收到错误:

Cannot find a free loopback device.

LXC 安装在 Ubuntu 12.04 上,内核为 3.6.3,来自kernel-ppa/mainline - Ubuntu 内核

容器配置:

lxc.network.type=veth
lxc.network.link=lxcbr0
lxc.network.flags=up
lxc.network.hwaddr= 00:16:3e:10:97:12
lxc.network.ipv4 = 10.0.3.11/24

lxc.devttydir = lxc
lxc.tty = 4
lxc.pts = 1024
lxc.arch = amd64
lxc.cap.drop = sys_module mac_admin

lxc.cgroup.devices.deny = a
# Allow any mknod (but not using the node)
lxc.cgroup.devices.allow = c *:* m
lxc.cgroup.devices.allow = b *:* m
# /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
#fuse
lxc.cgroup.devices.allow = c 10:229 rwm
#tun
lxc.cgroup.devices.allow = c 10:200 rwm
#full
lxc.cgroup.devices.allow = c 1:7 rwm
#hpet
lxc.cgroup.devices.allow = c 10:228 rwm
#kvm
lxc.cgroup.devices.allow = c 10:232 rwm
lxc.utsname = statystyka
lxc.mount = /var/lib/lxc/statystyka/fstab
lxc.rootfs = /var/lib/lxc/statystyka/rootfs

答案1

您可以尝试允许容器使用系统模块(通过删除sys_module):

lxc.cap.drop = mac_admin

也可能通过允许使用设备映射器块:

lxc.cgroup.devices.allow = b 252:* rwm

相关内容