I’m sure this worked for me before (because I documented it as I went along), but it isn’t working now.
$ lxc launch images:ubuntu/18.04/cloud foo --vm
Creating foo
Starting foo
$ lxc storage volume create default foo1 --type block
Storage volume foo1 created
$ lxc storage volume attach default foo1 foo /dev/sdb
Error: Failed to add device "foo1": Custom block volumes cannot have a path defined
$ lxc storage volume attach default foo1 foo
Description:
Attach new storage volumes to instances
Usage:
lxc storage volume attach [<remote>:]<pool> <volume> <instance> [<device name>] <path> [flags]
...
This is under lxd 4.11 from snap, and the “default” storage pool is of type “dir”.
$ snap list
Name Version Rev Tracking Publisher Notes
core18 20210128 1988 latest/stable canonical✓ base
lxd 4.11 19389 latest/stable canonical✓ -
snapd 2.48.2.1 11036 latest/stable canonical✓ snapd
$ sudo snap refresh
All snaps up to date.
In case it’s relevant:
$ lxc config show foo -e
architecture: x86_64
config:
environment.http_proxy: ""
image.architecture: amd64
image.description: Ubuntu bionic amd64 (20210212_07:42)
image.os: Ubuntu
image.release: bionic
image.serial: "20210212_07:42"
image.type: disk-kvm.img
image.variant: cloud
user.network_mode: ""
volatile.base_image: 951a329c395256b99c6829d0e5c9f727dffd616c6059643510bc7141934fe1e2
volatile.eth0.host_name: tapdbb9fb6f
volatile.eth0.hwaddr: 00:16:3e:8d:a3:a7
volatile.last_state.power: RUNNING
volatile.uuid: 449d85ef-271d-4750-9a00-95be89e26363
devices:
eth0:
name: eth0
nictype: bridged
parent: lxdbr0
type: nic
root:
path: /
pool: default
type: disk
ephemeral: false
profiles:
- default
stateful: false
description: ""
$ lxc exec foo -- /bin/bash -c 'ls -l /dev/sd*'
brw-rw---- 1 root disk 8, 0 Feb 12 19:43 /dev/sda
brw-rw---- 1 root disk 8, 1 Feb 12 19:43 /dev/sda1
brw-rw---- 1 root disk 8, 2 Feb 12 19:43 /dev/sda2
$
What’s the correct way to attach a new block volume to a VM instance?
Thanks,
Brian.