Changing the location of LXD entirely

Hello Friends:

I’m starting with LXD anew, and have the following two physical mount-points:

1) / (OS F/S H/W RAID-0 Stripe)
2) /drives.d/2TBssd.d/ (Data F/S H/W RAID-0 Stripe)

I want all of my LXD activity to occur under the directory:

/drives.d/2TBssd.d/VMs.d/LXD.d/

instead of the default of:

/var/snap/lxd/common/

What is the recommended way of doing this? And if it’s not possible (say, because doing so might cause lxd and/or snapd problems), I’d like storage disks and pools to be beneath there at least (for performance and space).

But truthfully, I prefer everything LXC to be beneath that directory (so that it’s wholly contained). Basically, I want to shift LXD’s location, and in turn, shift the associated default location where assets are created.

Thank you!

Setting up a bind-mount from /var/snap/lxd/common/lxd to /drives.d/2TBssd.d/VMs.d/LXD.d in /etc/fstab and rebooting to ensure all mount namespaces have caught up should work.

Hi @stgraber

Ah, okay.

So something like the following? (Although I’m unsure I have the fstab options correct – I just turned off my server for the night).

/etc/fstab:

/var/snap/lxd/common/lxd /drives.d/2TBssd.d/VMs.d/LXD.d none bind,rw 0 0

Other way around, source goes first.

(Sorry, I realize my previous message may not have been super clear, you want /var/snap/lxd/common/lxd to be stored at /drives.d/2TBssd.d/VMs.d/LXD.d so that becomes /drives.d/2TBssd.d/VMs.d/LXD.d /var/snap/lxd/common/lxd none bind 0 0 as an fstab entry.

1 Like

@stgraber

Correct. I need all assets stored under that other (2TB) directory, because it has more space and is faster.

One quick follow-up question:

Do I need to uninstall snapd lxd first (to clear out /var/snap/lxd/common/lxd), then institute the bind mount (with reboot), and then reinstall snapd lxd? Probably not because the destination directory would not be present, but just making sure.

Thank you for your replies and even the fstab entry. I do appreciate it!

Nah, LXD will re-create the content of the directory on first startup.

Thank you!

/drives.d/2TBssd.d/VMs.d/LXD.d /var/snap/lxd/common/lxd none bind 0 0