LXC VM - how to add a second virtual disk?

Hi, I have a LXC VM running, with a virtual 20G OS system drive, located ‘virtual-machines/VMname/root.img’. How can I add a second virtual disk, ie, secondDrive.img please?

Kind regards.

lxc storage volume create default my-vol size=20GiB --type=block
lxc config device add VMname my-vol disk pool=default source=my-vol

This creates a block custom storage volume on the storage pool default, calls the volume my-vol and gives it a size of 20GiB. It then attaches that volume to the VM VMname through a disk device called my-vol.

Perfect, thank you stgraber.

I see it places the newly added virtual disk in ‘custom/default_my-vol/root.img’, and not with the virtual machine folder.

Only the main image (where the OS is on) is placed in the virtual-machines directory. All additional disks or custom volumes are placed in custom.

2 Likes