Proxmox: Mount USB disk to VZ or LXC container

Posted on Fri 06 April 2018 in Wirtualizacja • 1 min read

First check what is the number of VZ container you want to mount disk to:
vzlist
      CTID      NPROC STATUS    IP_ADDR         HOSTNAME
       113         52 running   192.168.15.234     wordpress.pws
       117         49 running   -               debian7.pws
       119         48 running   -               debian9.pws
Look at CTID number.
Then mount disk under folder on host (it’s called HN in documentation):
mount /dev/sdb3 /mnt/usb
So partition sdb3 is now mounted in Proxmox host under /mnt/usb.
If the disk has GPT do this:
parted /dev/sdb print
and then choose right partition number.
Next bind directory to VZ container:
mount --bind /mnt/usb/ /var/lib/vz/root/119/mnt/usb/
Now, disk is bind-mounted to /mnt/usb folder inside the debian9.pws machine which has CTID number 119.

In LXC:
Mount external disk to some directory:
mount /dev/sdb3 /mnt/sdb3
then shutdown container and mount directory /mnt/sdb3 under /shared directory inside container:
pct set 100 -mp0 /mnt/sdb1,mp=/shared