Proxmox – Add external usb drive to LXC container

proxmox
How to mount an external USB(3) drive to a LXC container

In this example we make use of a Western Digital 1TB external USB3 drive.
This device is NTFS formatted, which is easy to handle in Windows.

Our container is used for samba services and has ID 102.

At the host system (Proxmox)

– Check which device the drive has been given on the host.
lsblk (in this case ‘sdg’, partition ‘sdg1’)

– Add a mounting location
mkdir /mnt/ext-usb

– Install the ntfs-3g package
apt-get update && apt-get install ntfs-3g

– Mount the disk to the mountlocation
mount -t ntfs-3g /dev/sdg1 /mnt/ext-usb

AT LXC client (container)

– Add a mount location inside the LXC container
mkdir /mnt/ext-usb

At the host

– Mount the drive to the container in this example we use mp1 (check if mp1 is not allready used!)
pct set 102 -mp1 /mnt/ext-usb,mp=/mnt/ext-usb

Comments

2 responses to “Proxmox – Add external usb drive to LXC container”

  1. jean Avatar
    jean

    How can you bind mount a single usb drive to multiple lxc containers? I noticed when i perform bind mount from host to lxc1 the host can no longer see the files. when i bind mounted the same usb drive to lxc2 using the same procedure and directories no files were available (makes sense probably since they were not available to host anymore either).

    1. Stefan Avatar
      Stefan

      I think the info on the following page could solve your problem:
      https://blog.simos.info/how-to-view-the-files-of-your-lxd-container-from-the-host/

      I’m not a guru, just an enthousiast who’s writing notes on my website 🙂

Leave a Reply