Type: unix-block

Note

The unix-block device type is supported for containers. It supports hotplugging.

Unix block devices make the specified block device appear as a device in the instance (under /dev). You can read from the device and write to it.

Device options

unix-block devices have the following device options:

gid

GID of the device owner in the instance

Key: gid
Type:

integer

Default:

0

major

Device major number

Key: major
Type:

integer

Default:

device on host

minor

Device minor number

Key: minor
Type:

integer

Default:

device on host

mode

Mode of the device in the instance

Key: mode
Type:

integer

Default:

0660

path

Path inside the instance

Key: path
Type:

string

Required:

either source or path must be set

required

Whether this device is required to start the instance

Key: required
Type:

bool

Default:

true

See Hotplugging for more information.

source

Path on the host

Key: source
Type:

string

Required:

either source or path must be set

uid

UID of the device owner in the instance

Key: uid
Type:

integer

Default:

0

Configuration examples

Add a unix-block device to an instance by specifying its source and path:

lxc config device add <instance_name> <device_name> unix-block source=<path_on_host> path=<path_on_instance>

If you want to use the same path on the instance as on the host, you can omit the source option:

lxc config device add <instance_name> <device_name> unix-block path=<path_to_the_device>

See Configure devices for more information.

Hotplugging

Hotplugging is enabled if you set required=false and specify the source option for the device.

In this case, the device is automatically passed into the container when it appears on the host, even after the container starts. If the device disappears from the host system, it is removed from the container as well.