[SOLVED] Mounting a network drive dynamically to the guest

cogis

Member
Mar 17, 2022
13
3
8
34
Hello,

On windows virtual machine, i try to mount dynamically a network drive from a webdav server
So i can run a command from qm (or the proxmox api) ex :

qm guest exec 288 "C:\WINDOWS\system32\cmd.exe" -- "/c net use y: http://webdav.host:8000 /user:user password"

But the issue is the qemu guest agent on windows run on "system" user, so the mounted network drive is not accessible from the user
When i try to access i got the error "ask access to administrator", while i am on an administrator user


1648544043367.png

One other way to do this is maybe with qemu : https://plkt.io/a/2021/01/28/mounting-a-local-directory-in-a-qemu-kvm-virtual-machine/
But i dont know if it can work in my case, i want to mount a drive without having to restart the VM

Do you have any idea how to resolve this issue ?

Thank you
 
was just an idea.. no clue how to do it then...
 
your first post, the error '127.0.0.1@8000\DavWWWRoot'

127.0.0.1 would refer to the local host - in this case the VM you are trying to map a network resource - is this correct? what you intended?

when you say you are trying to do this 'dynamically' - what would trigger the requirement to access the drive? - can it not just be made a persistent mapping?
 
your first post, the error '127.0.0.1@8000\DavWWWRoot'

127.0.0.1 would refer to the local host - in this case the VM you are trying to map a network resource - is this correct? what you intended?

when you say you are trying to do this 'dynamically' - what would trigger the requirement to access the drive? - can it not just be made a persistent mapping?

No i need dynamic mapping because multiple user can access the machine, and they need access to their personal drive, so to mount/unmount dynamically

So my solution for windows VM is to write a .bat file from qemu agent containing :
Code:
net use y: http://webdav.host:8000 /user:user password
I just ask the user to run this script, available in start up menu.


For Linux VM its more simple and 100% automated, i can from the guest agent (that is using root user) mount webdav connection, and add correct group user permission to mounted drive
 
Last edited:
I just ask the user to run this script, available in start up menu.
If you want to automate this you can put the script in the common startup folder accessible via WinKey + R and typing shell:common startup

This should run for every user once they login.
 

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!