External drive assignments and Veracrypt

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15498
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

External drive assignments and Veracrypt

Post by ChrisGreaves »

Untitled3.png
My new HP15/Win11 seems to be switching drives on me and I can’t figure it out.

For ten years now (WinXP/7/10/11) I have used a daily 465GB USB drive to backup each night, and a weekly 931GB drive on Sundays to accumulate changes from the daily backup (after which the daily reverts to a mirror image of my data partition)
The daily backup BATch file runs fine.
The weekly version of the BATch file trips over itself.

My weekly physical procedure is unchanged: I plug the daily backup into a USB port and when the little light flashes (“recognized!”) I plug in the weekly drive.
The daily drive always appeared as Harddisk2 and the weekly drive always appeared as Harddisk3 (NOT as shown in the image above). The batch file then assigns Harddisk2 to Y: and Harddisk3 to Z: and the batch file does its job.

Last Sunday and, I think, the Sunday before, I thought that the weekly backup was taking far too long. That’s when I noticed that the Harddisk assignments had flipped around when the second USB drive was plugged in (so my weekly run was copying the entire weekly 931GB onto the daily 463GB drive!)

This is not critical; once a week I can fire up Veracrypt and assign the drives manually before calling the batch file. The batch file will detect that Y and Z are assigned and skip its own assignment procedure and the batch file will run as it should.

I suspect that something has happened since I began running Win11 two months ago. I am paranoid/fanatical about daily and weekly backups because my mind runs faster than my body and I regularly screw up a file ....

Question: What might I examine to resolve this switcheroo?

I see the same switch in assignments through the panel in TrueCrypt, so I suspect that this is a Win11 feature rather than a bug in Veracrypt.

I have experimented with plugging in each drive singly (each plug in sets the USB drive as Harddisk2), and when switching the sequence in which I plug in (weekly 931GB before daily 463GB) makes no difference.
I have a piece of red electrical tape on the daily and blue on the weekly to reduce the chance of error on my part.
It is as if Win11 assigns the drives according to size, so that the 931 GB will always have a lower Harddisk identifier than the smaller 463 GB drive.

Thanks for any experimental suggestions.
Chris
You do not have the required permissions to view the files attached to this post.
An expensive day out: Wallet and Grimace

User avatar
John Gray
PlatinumLounger
Posts: 5401
Joined: 24 Jan 2010, 08:33
Location: A cathedral city in England

Re: External drive assignments and Veracrypt

Post by John Gray »

Is one familiar with USBDLM?
John Gray

Venison is quiet deer, and quite dear.

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15498
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: External drive assignments and Veracrypt

Post by ChrisGreaves »

John Gray wrote:
11 Apr 2023, 15:38
Is one familiar with USBDLM?
Thank you John.
One was not familiar with USBDLM, but that first page told one that "If Windows has problems with the USB drives itself then USBDLM cannot fix it."

Now one already had the feeling that one's problems here were caused by Win11 itself, that is, one was having problems with Windows 11 recognizing the USB drives.
One was having problems with drive letters only because one was having problems with Win11's shuffling the sequence of the USB drives.
Here is the relevant part of my batch file that uncrypts the two drives (daily and weekly):-

Code: Select all

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::	Mount both backup drives Y and Z
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
		%pause%
		if exist Y:\nul goto 20MountedY
		Title %0 -                     Mounting drive Y
		"C:\Program Files\VeraCrypt\VeraCrypt.exe" /q /l Y  /v \Device\Harddisk2\Partition1
		%pause%
		if exist Y:\nul goto 20MountedY
		echo I could not mount the FIRST backup drive
		pause
		goto 90exit
:20MountedY
		echo :20MountedY
		%pause%
		for /f %%a in ('wmic path win32_localtime get dayofweek /format:list ^| findstr "="') do (set %%a)
		if not %dayofweek%==0 goto 25Purging

		if exist Z:\nul goto 20MountedZ
		Title %0 -                     Mounting drive Z
		"C:\Program Files\VeraCrypt\VeraCrypt.exe" /q /l Z  /v \Device\Harddisk3\Partition1
		%pause%
		if exist Z:\nul goto 20MountedZ
		echo I could not mount the SECOND backup drive
		
:20MountedZ
		echo :20MountedZ
		%pause%
One (other) will see that one has elected to use drive letter "Y" to decrypt to "\Device\Harddisk2\Partition1", which works fine as long as the second USB drive is not plugged in, but when both drives are plugged in "\Device\Harddisk2\Partition1" always points to the weekly drive, regardless of (a) which USB sockets receive the drives and (b) which sequence those two USB drives are plugged in,

You will note that (this) one does a DayOfWeek (DOW) test, so one could splice in some extra code to effect the shuffle on Sundays and gain the upper hand over Windows. But then one anticipates that the first Sunday after implementing the code, Win11 ("evil one") might come to its senses and go back to behaving.

It is the identification of the USB drives as "\Device\Harddisk2\Partition1" and "\Device\Harddisk2\Partition2" which is giving one headaces, rather than the drive letters themselves.

Cheers, Chris
An expensive day out: Wallet and Grimace

User avatar
John Gray
PlatinumLounger
Posts: 5401
Joined: 24 Jan 2010, 08:33
Location: A cathedral city in England

Re: External drive assignments and Veracrypt

Post by John Gray »

The point of USBDLM is to stop Windows "shuffling" USB drive letters, by assigning them a fixed drive letter. Wouldn't having a fixed drive letter assist you in your endeavours?

In all my time writing BATch files I have never used the "\Device\Harddisk2\Partition1" construct, but simply made use of volume names and drive letters!
John Gray

Venison is quiet deer, and quite dear.

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15498
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: External drive assignments and Veracrypt

Post by ChrisGreaves »

John Gray wrote:
11 Apr 2023, 16:22
The point of USBDLM is to stop Windows "shuffling" USB drive letters, by assigning them a fixed drive letter. Wouldn't having a fixed drive letter assist you in your endeavours?
Thanks John.
Fixed drive letters would indeed help me, but I think that drive letters being shuffled or re-assigned is not the problem here.
Veracrypt, and its preceding TrueCrypt, assign the drive letter by mounting a device, as in

Code: Select all

"C:\Program Files\VeraCrypt\VeraCrypt.exe" /q /l Y  /v \Device\Harddisk2\Partition1
where the parameter "/L Y" assigns the Letter Y to the device "Harddisk2\Partition1".
In that sense ***I*** am assigning the drive letters (correctly), but the device identity change seems to be being triggered by the physical USB drive being inserted.
In the past, my HDD/SSD in the laptop was Partition0, and the next USB drive inserted was Partition1 and the one after that Partition2.

Each night I insert the Daily USB drive 463 GB and run the backup, except on Sunday nights I insert that drive and then insert the Weekly USB drive 931 GB, which, being the second drive inserted, became known as "Partition2"

That behaviour has changed. Now, regardless of the sequence of insertion, regardless of the USB socket used, that weekly drive always ends up being Partition1 when it is inserted with the daily drive; Win11 seems to "bump up" the smaller drive to "Partition2" in favour of the bigger drive.
Which I find odd.
In all my time writing BATch files I have never used the "\Device\Harddisk2\Partition1" construct, but simply made use of volume names and drive letters!
I am with you there!
The only batch file (of 157 in T:\BatLap\) that uses Device rather than letter is :fanfare: my backup batch file.
Because my backup batch file uses True/VeraCrypt, which program assigns the drive letter to the mounted volume.

Cheers, Chris
An expensive day out: Wallet and Grimace

User avatar
StuartR
Administrator
Posts: 12577
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: External drive assignments and Veracrypt

Post by StuartR »

I think that Veracrypt options for Favorite Volumes should let you assign a drive letter to the partition
StuartR


User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15498
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: External drive assignments and Veracrypt

Post by ChrisGreaves »

StuartR wrote:
12 Apr 2023, 11:23
I think that Veracrypt options for Favorite Volumes should let you assign a drive letter to the partition
Thanks Stuart, Veracrypt does that, "lets me assign a drive letter to the partition".
I've been using that for years.

The immediate problem is "which partition"? because Win 11 changes the partition device number of a plugged-in drive as soon as the second drive is plugged in.

(1) I start with only Harddisk0, the SSD containing the boot and data partitions.
(2) I plug in my daily 463 GB drive, and that becomes Harddisk1
(3) When I plug in my weekly 931 GB drive, that drive becomes Harddisk1, and the daily drive jumps to be Harddisk2. :scratch: :scratch:
This behaviour is visible regardless of whether I interrogate devices with trueCrypt or Veracrypt.

I suspect that this is a feature either of my HP15 laptop or of Win11.

In the meantime, for my weekly backup run, I can mount the two backup drives manually and when the batch file runs, the batch file will see that drives Y: and Z: are available and will bypass the Veracrypt mounting commands.

I am mainly puzzled that plugging in USB drives no longer assigns Harddisk numbers chronologically, as it used to.
Cheers, Chris
An expensive day out: Wallet and Grimace

User avatar
StuartR
Administrator
Posts: 12577
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: External drive assignments and Veracrypt

Post by StuartR »

One of the options in Veracrypt is to use the Volume ID instead of the partition number. This should do what you need.
You do not have the required permissions to view the files attached to this post.
StuartR


User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15498
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: External drive assignments and Veracrypt

Post by ChrisGreaves »

StuartR wrote:
12 Apr 2023, 14:07
One of the options in Veracrypt is to use the Volume ID instead of the partition number. This should do what you need.
Thanks Stuart. I didn't know that.
I have upgraded to version 1.25.9 and worked my way through "Command Line Usage"
with this little batch file as a workbench

Code: Select all

		Title %0 -                     Mounting drives Y and Z
		"C:\Program Files\VeraCrypt\VeraCrypt.exe" /auto /L Y /v \\?\Volume{E70CF6AD1D4083E9EF3094B30B25FB6993EA4AFF1956070F7527701E3D065A2D}\
pause
		Title %0 -                     Mounting drive Y
		"C:\Program Files\VeraCrypt\VeraCrypt.exe" /q /l Y  /v 1F90EF960FFFEC9139EEF5D214850C432B55DAA6D6D581EF2885EAF2BFC25127
pause
		Title %0 -                     Mounting drive Z
		"C:\Program Files\VeraCrypt\VeraCrypt.exe" /q /l Z  /v \Device\Harddisk3\Partition1
pause
I have tried using both the 32-character volume-id available from the favorites screen as well as a typed-in Volume name ("Red463GB" and "Blue931GB") but have not been able to auto-mount from a command line in a batch file.

I can mount manually from Veracrypt by selecting the device, but in no way (after an hour of experimentation) have I been able to get the USB drives mounted to the point where all I need do is key in a password. Right now I am focused on the first command in that batch file; the next two lines were earlier essays.
Are you mounting your drive(s) from the command line/batch or script file?
Thanks
Chris
An expensive day out: Wallet and Grimace

User avatar
StuartR
Administrator
Posts: 12577
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: External drive assignments and Veracrypt

Post by StuartR »

I just define the drives that I want mounted as favourites and then use the command

Code: Select all

C:\Program Files\VeraCrypt\veracrypt" /auto favorites /cache favorites /quit
StuartR


User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15498
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: External drive assignments and Veracrypt

Post by ChrisGreaves »

StuartR wrote:
12 Apr 2023, 21:22
I just define the drives that I want mounted as favourites and then use the command

Code: Select all

C:\Program Files\VeraCrypt\veracrypt" /auto favorites /cache favorites /quit
:clapping: Thank you Stuart.
I ran a small test in my "bothvolumes.bat" file and it worked.
In particular the text batch files picked up my Named volumes (Red463GB and Blue931GB) which to me is encouraging, because now I can visually check the assignments by the coloured tap on the drives. :clapping:


I will run a regular daily batch file tonight, and follow that with a weekly backup.
Cheers, and Thanks again, Chris
(next day) The daily backup ran perfectly last night, but i was too tired to trust myself running the two-drive weekly, so that is postponed until this evening. Chris
An expensive day out: Wallet and Grimace