3

I want to use fake block device inside my container. I made loop devices and added disk to a container, but I do not see it /dev/ directory listing.

# truncate -s 10G xfs.img
# mkfs.xfs xfs.img
# losetup -f xfs.img
# lxc config device add Cont01 BDisk disk source=/dev/loop0 path=/mnt/disk
# lxc exec Cont1 -- df -h
...
/dev/loop0                9.8G     36.0M      9.2G   0% /mnt/disk
# lxc exec Cont1 "ls /dev/ | grep loop"
#

I guess it's related with apparmor or security policy. Can anyone advice a safe way to get LXC access to a fake block devices?

UPDATE the way to mount fake block device:

$ lxc config device add ceph04 BDisk unix-block path=/dev/loop1

1 Answer 1

1

The LXD GitHub has alot of documentation related to configuration.

https://github.com/lxc/lxd/blob/master/doc/configuration.md

Search there for "unix-block" and you will find what you need.

Quote follows:

Devices configuration

LXD will always provide the container with the basic devices which are required for a standard POSIX system to work. These aren't visible in container or profile configuration and may not be overridden.

Those includes:

/dev/null (character device) /dev/zero (character device) /dev/full (character device) /dev/console (character device) /dev/tty (character device) /dev/random (character device) /dev/urandom (character device) /dev/net/tun (character device) /dev/fuse (character device) lo (network interface)

Anything else has to be defined in the container configuration or in one of its profiles. The default profile will typically contain a network interface to become eth0 in the container.

To add extra devices to a container, device entries can be added directly to a container, or to a profile.

Devices may be added or removed while the container is running.

Every device entry is identified by a unique name. If the same name is used in a subsequent profile or in the container's own configuration, the whole entry is overriden by the new definition.

Device entries are added through: lxc config device add [key=value]...

= = = end quote = = =

An example command:

lxc profile device add [key=value]...

Also, if you use LXD I'd highly recommend subscribe to the lxc-users mail alias as the developers monitor that and answer Q&A daily.

https://lists.linuxcontainers.org/

Lastly, there is an LXD sub-reddit on Reddit (if you use Reddit?) that is NOT for support but does provide a lot of great info on LXD.

https://www.reddit.com/r/LXD/

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .