veracrypt / VeraCrypt

Disk encryption with strong security based on TrueCrypt
https://www.veracrypt.fr
Other
6.72k stars 935 forks source link

Volume corruption when trying to dismount - Win11 #1380

Open Daniel9132 opened 1 month ago

Daniel9132 commented 1 month ago

Expected behavior: Unmount normally without corrupting anything

Observed behavior: Mounted filesystem is being corrupted for unkown reasons.

Steps to reproduce: When trying to dismount a volume something is locking it. Using "File Locksmith" from Windows PowerToys or "LockHunter" shows nothing or just Windows explorer. I did NOT try to force dismount just try repeatedly. And then completely out of the blue the volume is corrupted in Windows Explorer showing 0 bytes with no file system under properties. When trying to access the volume it says "Path not available. File letter R:\ can't be accessed. disk structure is damaged and not readable". The volume is still mounted in Veracrypt and i can see the properties of the volume but the filesystem of the mounted volume is not readable by windows explorer anymore. Even after dismounting and remounting again veracrypt shows no issues but the filesystem is not readable in windows explorer.

This happened twice in a row. After the first corruption i did format the volume and did the backups again. I'm doing backups from my Desktop PC to external HDDs in a USB Dock with 2 SATA Slots connected via UASP over USB 3.0. I confirmed the dock wasn't the problem. I'm backing up 2x 4tb HDDs and 1x 10tb + 1x 12tb. The two 4tb volumes have no issues whatsoever after repeatedly trying but the 10tb and 12tb got corrupted twice in a row after a longer backup session. I used CrystalDiskInfo and Gsmartcontrol to confirm there is no hardware issue. Temperature of the HDDs is not the issue. I was trying again after cooling them down.

But it's only causing it on the 10tb and 12tb disk. Both are the newest volumes i have with really low numbers of lifetime hours and on/off cycles as well as no signs of issues.

Screenshots Screenshot 2024-07-27 030313

Your Environment Windows 11 23H2 Build 22631.3880 Veracrypt 1.26.7 64bit Mounted Volumes are NTFS

thany commented 4 weeks ago

Interesting. You mentioned backups. Backup software typically doesn't access your files directly like any bog standard program would, but rather goes through the Shadow Copy service. They do that in order to backup files that are locked by other software. This might be why you're not seeing which files are in use, even if you're on elevated privileges.

It might be helpful to the devs, and perhaps to yourself as well, if you can dial down on when exactly this problem occurs, more so than "twice in a row". I personally cannot believe that this triggers your problem:

  1. Reboot computer
  2. Mount volume
  3. Dismount volume

I'm pretty sure your backup process is in there somewhere. When does that happen, when does it finish, does its process remain active after doing its thing, and most importantly: which backup software are you even using?

Daniel9132 commented 4 weeks ago

To add further context: I'm using an external SATA Docking Station with USB 3.0 using the UASP protocol which tunnels SATA through USB. For backup software I'm using FreeFileSync(.org) for many years now. Beginning with Windows 7, then 10 and now Win11. According to their documentation it only uses the Shadow Copy service when using the option to copy locked files which is disabled by default. I never used it. https://freefilesync.org/manual.php?topic=volume-shadow-copy There is however an option enabled by default called "Fail-safe file copy" which creates a temporary *.ffs_temp file before overwriting the target.

I have to state that the Backup-Software does not cause any issues, during or after the use of it.

I tried mounting the volume as "removable media" in veracrypt for the whole process, but no success.

The corruption always happens when i try to dismount the volume. After the next mounting the volume is corrupted.

I could backup a few TB today, but after dismounting, shutting off everything and coming back later the corruption happened again. I never had this issue before even with Win11. I suspect a recent Windows Update doesn't play well with veracrypt or the mount/dismount process.

andry81 commented 4 weeks ago

I've keep getting USB drives disconnection issues in VeraCrypt.

These are different cases, but all around USB drives: https://github.com/veracrypt/VeraCrypt/issues/1257 https://github.com/veracrypt/VeraCrypt/issues/1151 https://github.com/veracrypt/VeraCrypt/issues/990

Seems OS version is not related to the issue with USB drives.

Daniel9132 commented 4 weeks ago

I've keep getting USB drives disconnection issues in VeraCrypt.

These are different cases, but all around USB drives: #1257 #1151 #990

Seems OS version is not related to the issue with USB drives.

This seems unrelated to my issue. I don't have any USB disconnects or error messages at all.

The corruption happens at dismount or mount of the volume.

I'm trying a container-file approach now, maybe it happens only with whole-volume-encryption.

Daniel9132 commented 3 weeks ago

I want to give an update: I'm seeing USB disconnects now as well :(

Daniel9132 commented 3 weeks ago

@andry81 @thany I want to give an update again: I identified the issue and "fixed" it. It was NOT veracrypt but a Windows driver issue.

The problem where USB issues after all. To be specific: issues with the default windows driver uaspstor.sys. UASP is used since Windows 8 as default if the connected hardware is UASP capable. There are issues with the microsoft-supplied uasp drivers since at least 2015 that where never truly fixed. I never had issues with my setup until Microsoft updated the uaspstor.sys and usbstor.sys (for BOT Bulk-Only-Transfer) on June 12th 2024. The issues present itself as wildy varying transfer speeds and sometimes even disconnects of the drive. You can find it in the windows event log viewer when you search in the category "windows-protocols" > "system" for "UASP" with the Event-ID 129.

There are various workarounds floating around online and i tried all of them, but it seems all of them stopped working on the latest Windows 11.

My fix was the renaming of the .sys files. It wasn't possible in Windows and the Safe Mode. I made an Ubuntu Live USB Stick and mounted my Windows drive from there. Then rename the "uaspstor.sys" in the System32/drivers folder to "uaspstor.sys.old" and copy the "usbstor.sys" in place and rename it to "uaspstor.sys". I guess you have to do it again when microsoft decides to update these two drivers.

This way Windows mounts the dock with UASP so you can access the SMART data which is a nice side effect. But the drives themselves get mounted with the mentioned BOT mode. You can see it in the device manager under "drives" as "USB device" and not "SCSI device" when it mounts via UASP.

This way my transfer speeds where way faster than before because it had constantly high speeds and there are no more disconnects. For easier dismounting i mount the drives in veracrypt as "removable disk". I didn't have to do forced dismounts anymore. This didn't work at all with the UASP mounting.

I hope that i can help some lost souls if they ever find this post. These issues with UASP are floating around at least since 2015 and not every device seems affected, but when it is you have a bad time finding a fix.

Daniel9132 commented 3 weeks ago

Another update: seems like the issue isn't completely solved. The drives sometimes freeze completely, no data transfer and no reaction in windows or veracrypt. At least it doesn't corrup partitions anymore at least until now.

Windows 11 is frustrating to say the least.