# LXD VM You Can Mount a Drive

**URL:** https://discussion.scottibyte.com/t/lxd-vm-you-can-mount-a-drive/104
**Category:** Uncategorized
**Created:** [June 18, 2022, 10:33pm UTC](https://discussion.scottibyte.com/t/lxd-vm-you-can-mount-a-drive/104 "2022-06-18T22:33:06Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![scott](https://discussion.scottibyte.com/letter_avatar_proxy/v4/letter/s/3e96dc/32.png) [@scott](https://discussion.scottibyte.com/u/scott)
#### Post date: [June 18, 2022, 10:33pm UTC](https://discussion.scottibyte.com/t/lxd-vm-you-can-mount-a-drive/104/1 "2022-06-18T22:33:06Z")

</div>

In my series on LXD Virtual Machines we learned several interesting techniques.

It is also possible to create additional virtual disks, called storage volumes which can be attached to a LXD VM. In this presentation, we learn how to work with LXD VM storage volumes. This includes creating a disk, attaching a disk, formatting a disk and mounting the disk in our Ubuntu LXD VM.

This assumes you have followed the previous tutorials on creating an Ubuntu LXD VM.

To create a storage volume on your LXD host:

```auto
lxc storage volume create default mydisk size=10GB --type=block

```

To add the new storage volume to the Ubuntu “test-vm” LXD VM:

```auto
lxc config device add test-vm mydisk disk pool=default source=mydisk

```

We entered the console to access the LXD VM:

```auto
lxc console test-vm --type=vga

```

I installed the Gnome partition manager in Ubuntu at the terminal:

```auto
sudo apt install gparted

```

We created a partition table on the new drive using gparted. We then formatted an ext4 partition in gparted.

We created a mount folder, allowed all access to the folder and mounted the new storage:

```auto
sudo mkdir /mnt/mydisk
sudo chmod 777 /mnt/mydisk
sudo mount /dev/sdb1 /mnt/mydisk

```

To dismount the storage:

```auto
sudo umount /dev/sdb1

```

To mount the drive when the system boots, edit the file systems table:

```auto
sudo nano /etc/fstab

```

Use gparted to find the UUID of the new partition and make an entry in the fstab adjusted for your UUID.

```auto
UUID=a71531e2-46d4-41f3-aec8-c55611541c39 /mnt/mydisk ext4 _netdev 0 0

```

Save the file out of the editor and reboot. The drive should be mounted automatically.

Reverse the process by removing the fstab entry and then shutdown the Ubuntu LXD VM.

To remove the mydisk volume attachment from your LXD VM:

```auto
lxc config device remove test-vm mydisk

```

The storage volume is staill intact at this point and can be attached to another LXD VM if desired.

Commands to list the storage pools you have on your LXD host and your volumes:

```auto
lxc storage list
lxc storage volume list default

```

To permanently delete a volume from your LXD host:

```auto
lxc storage volume delete default mydisk

```
