Menu

Mount to a folder (not a drive letter only)

2018-10-12
2022-03-02
  • Dmitrii Evdokimov

    The old PGPdisk had the option to mount to a folder on Windows like DFS or Linux.

    The VeraCrypt requires to select a free drive letter to mount.
    Yes, someone can create a link (by the 'mklink' command) and be happy, but all these used letters still remain in the system as a waste.

     
    👍
    1
  • neos6464

    neos6464 - 2018-10-15

    You can manually remount a veracrypt volume to a folder path and free the drive letter using mountvol. For instance, if you mounted a VeraCrypt volume to drive letter X: and want it at C:\Mount instead, do the following in cmd:

    mkdir C:\Mount
    mountvol (observe the volume GUID currently assigned to X:)
    mountvol X: /D (free X:)
    mountvol C:\Mount \\?\{<Volume GUID>}

    X: is now free to be used for other things, except for mounting another VeraCrypt volume to it (the volume bound to C:\Mount still has the device name \Device\VeraCryptVolumeX, which will cause VeraCrypt to fail trying to mount anything to X:)

    Note that VeraCrypt will still list the volume as mounted to X: even though it's not. Dismount works normally. The next time you mount this volume with VC, you only need to do step 3 above (free the drive letter), the mount created at step 4 reactivates automatically.

    But I definitely second your request. This would be very useful, as currently you need to run a script like the one above to automate such a procedure.

     

    Last edit: neos6464 2018-10-15
  • Dmitrii Evdokimov

    I used mklink /d /j C:\Mount X:\ for the first time only. Then it also remembers specified paths after usual Dismount without new commands. But users worry about waste letters and same content. Once a user had cleaned double data as she thought.

     
  • neos6464

    neos6464 - 2018-10-16

    The mountvol sequence above lets you free X: (i.e. it is not wasted, there are no duplicate trees, and from the point of view of the system X: has nothing to do with your encrypted volume anymore).

    mklinking to X: obviously does not let you free X:, because as soon as you do, your link is broken

     
  • Dmitrii Evdokimov

    Thank you for sharing of your nice solution. I understood it. I had just dropped a note for other readers and, I hope, for the author too, for some ideas.

     
  • Adrian Kentleton

    @neos6464: your idea does not work for me (Windows 7, VC 1.22, 32-bit); whatever I do, I get both a test volume mounted to a drive letter, and a folder (shown as a shortcut), and can read and write to the volume at both locations. That is, the original drive letter allocation is not removed from Windows Explorer.

    Inspired by your idea, I wrote a batch script to automate mounting a test volume, as follows:

    @echo off
    :: Create a variable with mount options
    set op0=/q /v F:\testvol /l Z /hash sha512 /p testvol /c n /nowaitdlg /m rm
    :: Mount volume using mount options variable
    veracrypt %op0%
    :: Write GUID into file; read GUID from file into a variable
    mountvol Z: /l > F:\testvol.txt
    for /f %%a in (F:\testvol.txt) do set op1=%%a
    :: Remove the original mount point
    mountvol Z: /d
    :: Mount to folder using GUID variable, only on first run
    if exist F:\firstrun.txt goto skip01
    if not exist F:\firstrun.txt echo firstrun > F:\firstrun.txt
    mountvol F:\vc1 %op1%
    :skip01
    echo. & echo Press any key to dismount F:\testvol
    pause > nul
    veracrypt /d Z /q /f /w /s
    exit

    What am I doing wrong, please?

     
  • neos6464

    neos6464 - 2018-10-17

    Looks like you have to call mountvol Z: /d twice. Not sure why...
    Let me know if that works, and thanks for the script - saved me a bit of upcoming work :)

     
  • Adrian Kentleton

    Hi @neos6464, yes, that sorts it, script now works as expected. So, script now is:

    @echo off
    :: Create a variable with mount options
    set op0=/q /v F:\testvol /l Z /hash sha512 /p testvol /c n /nowaitdlg /m rm
    :: Mount volume using mount options variable
    veracrypt %op0%
    :: Write GUID into file; read GUID from file into a variable
    mountvol Z: /l > F:\testvol.txt
    for /f %%a in (F:\testvol.txt) do set op1=%%a
    :: Remove the original mount point (NB need to run the command twice)
    mountvol Z: /d
    mountvol Z: /d
    :: Mount to folder using GUID variable, only on first run
    if exist F:\firstrun.txt goto skip01
    if not exist F:\firstrun.txt echo firstrun > F:\firstrun.txt
    mountvol F:\vc1 %op1%
    :skip01
    echo. & echo Press any key to dismount F:\testvol
    pause > nul
    veracrypt /d Z /q /f /w /s
    exit

    I don't understand why you have to duplicate mountvol Z: /d either! Doesn't make much sense, given normal successful usage of the command.

    Like you and Dmitrii, I'd like to see an in-built ability to mount to a folder. However, I guess the developers have to prioritise sorting out core issues first, particularly those caused by the proliferation of proprietary configurations these days, caused by different manufacturers' GPT/UEFI/SecureBoot etc implementations.

    So, I'm always looking for ways to make VC work the way I'd like it to by external means if necessary, and it had never occurred to me to try using mountvol to acheive that particular objective. Thanks again for pointing this possibility out.

     

    Last edit: Adrian Kentleton 2018-10-17
    • Raccoon

      Raccoon - 2022-03-02

      I don't understand why you have to duplicate mountvol Z: /d either!

      I think this may be a simple asynchronous timing issue. If you add a TIMEOUT /T 1 then it will probably be caught up. /T 2 to make doubly sure.

      Why hasn't the dev added direct support for volume mount point folders?

       
  • Mati

    Mati - 2021-12-07

    my solution: just remove drive letter for encrypted disk in disk management. that's all. then just mount it whatever letter you want in veracrypt

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.