[SOLVED] Container and NOT always-on USB Disk

UTxCipo

New Member
Nov 29, 2020
5
1
3
41
Hi folks, I'm quite new to proxmox but I've done some good work on it, now my home server runs:
  • a VM for pfsense
  • a CT (Ubuntu) for Plex server for music streaming only (with a dedicated USB pendrive)
  • a CT (Alpine) for Samba, with a dedicated 3TB USB drive, but I don't need to keep it on 24/7
so, the problem is with this Samba CT, it runs well but if I shut down the USB drive, when I power it up again it seems is not "auto mounted" again... to have the fully functional service I musst reboot the CT.

Is there any solution about?

thakyou
 
Last edited:
I've found a clue, the usb passthrough, but I'm not sure how to adapt it to my usecase...

Is it possible to passthrough an USB HDD?
 
So, I almost found a solution, using udev, triggered by the HDD insertion... It runs a script do this:

pct start 103

The problem now is this way the container doesn't boot up correctly, it hangs for a minute and then fails.

The same command done by hand in the terminal starts the container like a charm...

It seems to be correlated to the mountpoit entry in the config file of the container, if I remove this:

mp0: /dev/disk/by-label/Data,mp=/media/red,backup=0

udev runs correctly but in this case I have no more the disk to be shared by samba

Could some of you give me any clue about?

Thanks And sorry for my bad english
 
Last edited:
Finally, I've foud a solution, I'll try to make some order in what I've found:

the container don't boot if:
  • the command pct start $id is given by the udev script AND
  • within the config file there is a mount point like this: mp0: /dev/disk/by-label/$label,mp=/path/to/mount,backup=0
I thought that something strange was happening and started to think about that "-" (the minus character), so I've added to my /etc/udev/rules.d/10-local.rules the key SYMLINK, now its content is like this:

Code:
ACTION=="add", ATTRS{idVendor}=="2109", ATTRS{idProduct}=="0715", ATTRS{serial}=="000000123ADC", KERNEL=="sd?1", SYMLINK+="sdf1", RUN+="/etc/udev/reboot-ct.sh"

/etc/udev/reboot-ct.sh
Code:
#!/bin/bash
    sleep 5s
    pct reboot 103

/etc/pve/lxc/103.conf
Code:
arch: amd64
cores: 1
hostname: samba
memory: 64
mp0: /dev/sdf1,mp=/media/red,backup=0
net0: name=eth0,bridge=vmbr0,firewall=1,hwaddr=EA:A8:02:46:BF:24,ip=dhcp,ip6=dhcp,type$
onboot: 1
ostype: alpine
rootfs: local-lvm:vm-103-disk-0,size=4G
swap: 256
unprivileged: 1

With this config I have what I wanted, a samba server without the need to run the hdd 24/7, now when I power up the HDD the container reboots and I have my shares up!

PS. the "minus" strangeness I think is a bug somewhere...