-----Original Message-----
From: Eryk Sun
On Mon, May 25, 2020 at 10:59 AM Steve Barnes
wrote: On Windows https://freetechtutors.com/create-virtual-hard-disk-using-diskpart-wi ndows/ gives a nice description of creating a virtual disk with only operating system commands. Note that it shows the commands being used interactively but it can also be scripted by starting diskpart /s script.txt -
...
it does need to be run as admin.
Well, darn. That seriously reduces its usefulness.
Creating and mounting a VHD can be implemented in PowerShell as well, but it requires installing the Hyper-V management tools and services (not the hypervisor itself). The hyper-v cmdlets for managing virtual disks (e.g. mount-vhd) also require administrator access, since the underlying API does (e.g. AttachVirtualDisk). A new system service and client application would have to be developed in order to allow standard users to manage virtual disks. Here's a PowerShell example to create, format, and mount a volume on a 10 MiB virtual disk. This example mounts the volume both at "V:/" and at "C:/Mount/vhd_mount": $vhdpath = 'C:\Mount\temp.vhdx' $mountpath = 'C:\Mount\vhd_mount' # create and mount the physical disk as a RAW volume new-vhd -path $vhdpath -fixed -sizebytes (10 -shl 20) mount-vhd -path $vhdpath # create a partition on the disk, format it as NTFS, and assign # the DOS device name "V:" and label "vhd" $nd = (get-vhd -path $vhdpath).DiskNumber new-volume -disknum $nd -filesys ntfs -drive V -friendly vhd # set a folder mountpoint mkdir $mountpath add-partitionaccesspath -drive V -accesspath $mountpath If no drive letter is desired, use the -accesspath option of the new-volume cmdlet instead of the -driveletter option. The following command dismounts the disk: dismount-vhd -path $vhdpath The mountpoint on the empty directory remains set but inaccessible once the disk is dismounted. You can can delete this directory if the disk won't be mounted again. Or, while the disk is mounted, you can remove the mountpoint via remove-partitionaccesspath. [Steve Barnes] Interesting Eryk. I have found that PyFilesystem2 (https://pypi.org/project/fs/) can create "file systems", both temporary and memory, for use from within python code without needing Admin permissions **but** at the moment they do not have any way of setting maximum sizes/available spaces.