Proxmox - Pass HDD to Container
The first thing you want to do is create a mount point for your drive using the drives UUID. Open up the shell on Proxmox (PM) host and grab the UUID of the disk you want to mount.
lsblk -f
You will want to grab the UUID which looks something like this:
6a0be238-82ee-4c22-841c-f57cafb5bcfa
Make sure to identify the correct drive when grabbing the UUID. Next, we need to create the mountpoint for the drive on your PM host. I always mount my drives under the “/media” directory.
mkdir /media/[Your mount point]
With the mount point created, next we will create an entry in the FSTAB for the drive on the PM host. Open up FSTAB with nano
nano /etc/fstab
Now add your drive, replacing the <UUID> and <Mount Point> with your own.
UUID=<UUID> /media/<YOUR MOUNT POINT> ext4 defaults,noatime,nofail 0 0
To mount the drive using the entry we just created, run mount
mount -av
Now start the container and create a mount point inside the container where we can pass the drive to. Again, I will use the ‘/media’ directory and create a folder called ‘postdata’. You can name your folder whatever you want.
sudo mkdir /media/<YOUR MOUNT POINT>
Now instead of modifying the container’s FSTAB, we will instead modify the config for the VM. Stop the container and open the PM host shell again. Open the config up with nano, taking note of the Container ID you want to mount the drive to.
nano /etc/pve/lxc/[YOUR CONTAINER ID].conf
Then at the bottom add an entry for mount point 0 (mp0). Take note of where the container mount point is and the PM host mount point, and ensure they reflect your settings.
mp0: /media/<HOST Mount Point>,mp=/media/<CONTAINER Mount Point>
That’s it. Start your container and check to ensure the drive is mounted.
df -h
You should now see the drive mounted to the mount point you created in the container earlier. Note that you can still mount drives using the container’s FSTAB, for instance I have a samba drive which I want the container to mount automatically when it’s started. The FSTAB file will be empty by default but you can add new entries there.