[TUTORIAL] USB Automount

Hello,

pve6-usb-automount uses the mount option "sync" for mounting drives. This means no caches or other optimations are used for write operations. This can be especially slow on mechanical drives. The benefit is when the write process finishes the data was really written on disk and not in some cache. This is enabled by default to avoid data loss when someone just unplugs the drive.

You can try to enable async mode in the /usr/bin/pve6_usb_automount.py script. Just search for -o sync and change to async or delete this section and restart the pve6-usb-automount service, then unplug and plug in your disk again. You can see the mode by running the mount command.
Thanks! I will test this.
 
Hello,

thanks for this very useful tool. I have attached a 1.5TB HDD via USB3. It gets recognized and I find it in /media/sdb1/ and create backups from my two lxc containers. However, I cannot create a backup of my VM on this external drive.

INFO: starting new backup job: vzdump 305 --node proxmox --compress gzip --storage usb-sdb1 --remove 0 --mode stop
INFO: Starting Backup of VM 305 (qemu)
INFO: Backup started at 2021-01-12 14:32:37
INFO: status = stopped
INFO: backup mode: stop
INFO: ionice priority: 7
INFO: VM Name: ubuntu
INFO: include disk 'scsi0' 'local-lvm:vm-305-disk-0' 40G
INFO: include disk 'efidisk0' 'local-lvm:vm-305-disk-1' 4M
INFO: creating vzdump archive '/media/sdb1/dump/vzdump-qemu-305-2021_01_12-14_32_37.vma.gz'
INFO: starting kvm to execute backup task
kvm: vfio: Cannot reset device 0000:00:14.2, no available reset mechanism.
kvm: vfio: Cannot reset device 0000:00:14.0, no available reset mechanism.
kvm: vfio: Cannot reset device 0000:00:14.2, no available reset mechanism.
kvm: vfio: Cannot reset device 0000:00:14.0, no available reset mechanism.
ERROR: unable to open file '/media/sdb1/dump/vzdump-qemu-305-2021_01_12-14_32_37.vma.dat' - No such file or directory
INFO: aborting backup job
INFO: stopping kvm after backup task
trying to acquire lock...
OK
ERROR: Backup of VM 305 failed - unable to open file '/media/sdb1/dump/vzdump-qemu-305-2021_01_12-14_32_37.vma.dat' - No such file or directory
INFO: Failed at 2021-01-12 14:32:42
cp: cannot create regular file '/media/sdb1/dump/vzdump-qemu-305-2021_01_12-14_32_37.log': No such file or directory
INFO: Backup job finished with errors
TASK ERROR: job errors

-- Logs begin at Tue 2021-01-12 14:29:13 CET. --
Jan 12 14:32:42 proxmox pvedaemon[13299]: INFO: Backup job finished with errors
Jan 12 14:32:42 proxmox pvedaemon[13299]: job errors
Jan 12 14:32:42 proxmox pvedaemon[1043]: <root@pam> end task UPID:proxmox:000033F3:000051D0:5FFDA4F5:vzdump:305:root@pam: job errors
Jan 12 14:32:43 proxmox systemd[1]: systemd-rfkill.service: Succeeded.

total 16
drwxr-xr-x 4 root root 4096 Jan 12 14:32 .
drwxr-xr-x 6 root root 4096 Jan 12 14:40 ..
drwxr-xr-x 2 root root 4096 Jan 12 14:16 vzdump-qemu-305-2021_01_12-14_16_55.tmp
drwxr-xr-x 2 root root 4096 Jan 12 14:32 vzdump-qemu-305-2021_01_12-14_32_37.tmp

It is possible to copy, also big files, to this drive via console, so I assume it is some specific conflict here. Please also not that it is possible to create a backup of this same VM to my local drive. Also, after the error message the external drive is not visible in Proxmox anymore and the mountpoint /media/sdb1 is empty. At that point I can only restart the Proxmox host and then later attach the drive in order to make it show up again.

Looking forward to your suggestion!
 
Thanks for your reply. The filesystem is ext4.

Filesystem Type Size Used Avail Use% Mounted on
udev devtmpfs 7.8G 0 7.8G 0% /dev
tmpfs tmpfs 1.6G 9.1M 1.6G 1% /run
/dev/mapper/pve-root ext4 57G 32G 23G 59% /
tmpfs tmpfs 7.8G 25M 7.8G 1% /dev/shm
tmpfs tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup
/dev/sda2 vfat 511M 312K 511M 1% /boot/efi
/dev/fuse fuse 30M 20K 30M 1% /etc/pve
tmpfs tmpfs 1.6G 0 1.6G 0% /run/user/0
/dev/sdb1 ext4 1.4T 54G 1.3T 5% /media/sdb1
Disk /dev/sdb: 1.4 TiB, 1500301910016 bytes, 2930277168 sectors
Disk model: SuperSpeed
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x000e1568

Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 2930276351 2930274304 1.4T 83 Linux
 
I think I found a possible reason and it is due to the fact that I am passing through 2 devices to the guest VM: the IGPU and the bluetooth module. The latter one (00:14:3) shares the same prefix of the address as the USB controller (00:14:0). As a consequence all USB devices are no longer accessible to the host when the VM starts and, which I also did no know when starting a backup. I can verify this with "lsub" which gives results before the VM starts, but the output is empty after it starts.

Here are some more details:
00:02.0 VGA compatible controller: Intel Corporation Iris Plus Graphics 655 (rev 01)
00:14.0 USB controller: Intel Corporation Cannon Point-LP USB 3.1 xHCI Controller (rev 30)
00:14.2 RAM memory: Intel Corporation Cannon Point-LP Shared SRAM (rev 30)
00:14.3 Network controller: Intel Corporation Cannon Point-LP CNVi [Wireless-AC] (rev 30)
This is what the conf of the VM looks like:
agent: 1
args: -device vfio-pci,host=00:02.0,addr=0x18,x-igd-opregion=on
balloon: 4096
bios: ovmf
boot: order=scsi0;net0
cores: 6
efidisk0: local-lvm:vm-305-disk-1,size=4M
hostpci0: 00:14,pcie=1
machine: q35
memory: 8192
name: ubuntu
net0: virtio=B6:4A:02:CC:4F:86,bridge=vmbr0,firewall=1
numa: 0
ostype: l26
scsi0: local-lvm:vm-305-disk-0,cache=writeback,size=40G
scsihw: virtio-scsi-pci
smbios1: uuid=c431493c-d4b4-4c31-b9ae-e610bdb276bb
sockets: 1
usb0: host=046d:c52b
usb1: host=3-3
vga: none
vmgenid: 7b08e701-2192-4c5f-b1b1-6fcd3f3b1e78

Upon removing hostpci0: 00:14,pcie=1 from the VM and restarting the host, the backups runs fine. In the error message of my previous post you can also see some messages related to this:

kvm: vfio: Cannot reset device 0000:00:14.2, no available reset mechanism.
kvm: vfio: Cannot reset device 0000:00:14.0, no available reset mechanism.
kvm: vfio: Cannot reset device 0000:00:14.2, no available reset mechanism.
kvm: vfio: Cannot reset device 0000:00:14.0, no available reset mechanism.

Since I created that part of the config with the Proxmox UI, I wonder if there is a better way to specifically pass through just device 00:14.3 rather than 00:14 and will investigate here a bit more. But when doing that by adding hostpci0: 00:14.3,pcie=1 I do not seem to get the bluetooth passed through.

As a side note 00:14.3 is in a different IOMMU group as the other devices from 00:14

/sys/kernel/iommu_groups/0/devices/0000:00:00.0
/sys/kernel/iommu_groups/10/devices/0000:00:1d.0
/sys/kernel/iommu_groups/11/devices/0000:00:1d.6
/sys/kernel/iommu_groups/12/devices/0000:00:1f.0
/sys/kernel/iommu_groups/12/devices/0000:00:1f.3
/sys/kernel/iommu_groups/12/devices/0000:00:1f.4
/sys/kernel/iommu_groups/12/devices/0000:00:1f.5
/sys/kernel/iommu_groups/12/devices/0000:00:1f.6
/sys/kernel/iommu_groups/13/devices/0000:3c:00.0
/sys/kernel/iommu_groups/1/devices/0000:00:02.0
/sys/kernel/iommu_groups/2/devices/0000:00:08.0
/sys/kernel/iommu_groups/3/devices/0000:00:12.0
/sys/kernel/iommu_groups/4/devices/0000:00:14.0
/sys/kernel/iommu_groups/4/devices/0000:00:14.2
/sys/kernel/iommu_groups/5/devices/0000:00:14.3
/sys/kernel/iommu_groups/6/devices/0000:00:16.0
/sys/kernel/iommu_groups/7/devices/0000:00:17.0
/sys/kernel/iommu_groups/8/devices/0000:00:1c.0
/sys/kernel/iommu_groups/9/devices/0000:00:1c.4

Bottom line, it seems to be unrelated to the automount tool, but rather hardware/config specific to my NUC8I5.
 
Last edited:
It appears Proxmox 7 support is available:
Code:
apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 2FAB19E7CCB7F415
echo "deb https://apt.iteas.at/iteas bullseye main" > /etc/apt/sources.list.d/iteas.list
apt update
apt install pve7-usb-automount

Thank you!

I would suggest always modifying the first post with installation details and info so people know how to use it on any version of Proxmox release.
 
  • Like
Reactions: oek and fireon
@fireon again, thank you for your work with this. ❤️

Does this map to the GUID of the USB devices so as to always mount it as the same name? If not, could you extend it to do so? I simply want reliability in naming for certain drives.

Also could you please extend its functionality to 1) allow us to custom name volumes and 2) select if we don't want certain volumes mounted??

For example, when I insert some drives that are GPT and have an EFI partition/volume, I do not want those to automatically show up. It would be nice to have a way to select those to not show up when auto-mounting.

Does this make sense?
 
Hi i can't add the Key as described?

apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 2FAB19E7CCB7F415
Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
Executing: /tmp/apt-key-gpghome.OxXoXK2W6n/gpg.1.sh --recv-keys --keyserver keyserver.ubuntu.com 2FAB19E7CCB7F415
gpg: keyserver receive failed: Connection timed out


------

Edit 01.02.22
was a firewall/proxy issue ^^
 
Last edited:
Evening together

I use this tool on Proxmox 6.4-13.
How can I cleanly remove this tool?

I already did it with apt remove pve6-usb-automount as well as that
"deb https://apt.iteas.at/iteas buster main"> "removed from" /etc/apt/sources.list.d/iteas.list ".

However, this doesn't seem to be enough and my system won't boot afterwards.
And outputs an error with "pve6-usb-automount".
 
Evening together

I use this tool on Proxmox 6.4-13.
How can I cleanly remove this tool?

I already did it with apt remove pve6-usb-automount as well as that
"deb https://apt.iteas.at/iteas buster main"> "removed from" /etc/apt/sources.list.d/iteas.list ".

However, this doesn't seem to be enough and my system won't boot afterwards.
And outputs an error with "pve6-usb-automount".
And what is the error called?
 
Hmm, ok schein dann nicht richtig deinstalliert worden zu sein. Du musst dein System, sofern es immer noch nicht bootet im RecoveryMode hochfahren und den Automounter mit --purge deinstallieren. Dann wird auch jeglichen Config sauber gelöscht.
 
  • Like
Reactions: e-i-k-e
Hmm, ok schein dann nicht richtig deinstalliert worden zu sein. Du musst dein System, sofern es immer noch nicht bootet im RecoveryMode hochfahren und den Automounter mit --purge deinstallieren. Dann wird auch jeglichen Config sauber gelöscht.
Hallo Fireon,

danke für den Tipp. Mit --purge hat es sofort geklappt! :)
 
  • Like
Reactions: fireon
@fireon Really appirecated your work here. May I know if I can automount 2 USB drive? it looks like it only mounts the first one. I'm using the PVE7
 
@l
@fireon Really appirecated your work here. May I know if I can automount 2 USB drive? it looks like it only mounts the first one. I'm using the PVE7
Yes thats possible because it uses the systems kernel name for mount and PVE storage name (sda, sdb, sdc, ...)
 
  • Like
Reactions: fireon

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!