Adding block device to VM with different device name

How to manage storage volumes - LXD documentation (

By default, the custom storage volume is added to the instance with the volume name as the [device] name. If you want to use a different device name, you can add it to the command:

lxc storage volume attach <pool_name> <block_volume_name> <instance_name> <device_name>

lxc storage volume attach pl block2 jam2 vd1
Error: Failed add validation for device “block2”: Custom block volumes cannot have a path defined

I tend to use lxc config device add which effectively does the same but from the point of view of the instance instead of the one of the volume.

lxc config device add INSTANCE DEVNAME disk source=VOLUME pool=POOL

It has worked.
lxc config device add jam2 vd1 disk source=block2 pool=pl
Now in config, device name is shown as vd1, instead of source name (block2)

    pool: pl
    source: block2
    type: disk

which actually doesn’t matter much
because inside VM, it either way identifies as

Disk /dev/sdc: 953.68 MiB, 1000005632 bytes, 1953136 sectors

Is there no way to disrupt that /dev/sdb /dev/sdc convention, override it by /dev/vdx …?

Nope, but you should be able to find an entry that includes the device name inside of one of the /dev/disk/by-*/ directories

I try to get a better overview of disk attach.
As snap/user space has added some new restrictions, generally there are two ways, one is by
lxc storage volume attach …
other is from point of view of instance:
lxc config device add INSTANCE DEVNAME disk


  1. Type Block can not be attached to container
    though it was previously possible by device unix-block, using any host’s block device, zvol … through its path /home/dev.img or /dev/zd1 …

  2. Type file system can be attached to containers as well as vm, though path must be defined and as for vm:

lxc config device add jam3 st1 disk source=st1 pool=pl2 path=st1
Error: Failed to start device “st1”: Cannot attach directory while instance is running

So, must stop the vm, attach device and start again? Not very convenient.

Yes VMs don’t currently allow directories be passed through as disks whilst the VM is running.
This is something we may be able to fix in certain circumstances, so please could you open an issue

I think a separate one would also be valid for supporting adding block volumes to containers.

This could also then be an opportunity to update the docs with the various limitations.

Pretty sure we already have one for that, I think it’s one of the easy issues with a student working on it.

The issue with add block device to containers is dormant.

Add lxc config device add disk --type=block for containers · Issue #10077 · lxc/lxd (

You mentioned, the issue is merely about removing a restriction.
Removing this restriction is what this issue is abou

It’s slightly more than that in that we also need to effectively pass a unix-block device for it, but yeah, it’s an easy piece of work which is why it’s currently assigned to a student.