Linux: allow mounting NTFS volumes with ntfs3#1695
Linux: allow mounting NTFS volumes with ntfs3#1695mammothcoding wants to merge 5 commits intoveracrypt:masterfrom
Conversation
|
@mammothcoding Your results are useful confirmation for #1660 conclusion. I agree with the general direction of this P but I can't merge it as-is. Please revise the following:
Once these points are addressed, this can be considered as an opt-in mitigation for affected Linux users. |
| MountNtfsWithNtfs3CheckBox = new wxCheckBox( FilesystemSizer->GetStaticBox(), wxID_ANY, _("LINUX_PREF_MOUNT_NTFS_WITH_NTFS3"), wxDefaultPosition, wxDefaultSize, 0 ); | ||
| FilesystemSizer->Add( MountNtfsWithNtfs3CheckBox, 0, wxALL, 5 ); | ||
|
|
||
| wxStaticText* MountNtfsWithNtfs3HelpStaticText; | ||
| MountNtfsWithNtfs3HelpStaticText = new wxStaticText( FilesystemSizer->GetStaticBox(), wxID_ANY, _("LINUX_PREF_MOUNT_NTFS_WITH_NTFS3_HELP"), wxDefaultPosition, wxDefaultSize, 0 ); | ||
| MountNtfsWithNtfs3HelpStaticText->Wrap( 600 ); | ||
| FilesystemSizer->Add( MountNtfsWithNtfs3HelpStaticText, 0, wxLEFT|wxRIGHT|wxBOTTOM|wxEXPAND, 5 ); | ||
|
|
There was a problem hiding this comment.
This is currently added in the shared generated wx UI path. Since the preference is Linux-only, please ensure this checkbox and its help text are only exposed on TC_LINUX builds, or are explicitly hidden on non-Linux Unix platforms.
| string DetectFilesystemType (const DevicePath &devicePath) | ||
| { | ||
| list <string> args; | ||
| args.push_back ("-o"); | ||
| args.push_back ("value"); | ||
| args.push_back ("-s"); | ||
| args.push_back ("TYPE"); | ||
| args.push_back ("--"); | ||
| args.push_back (devicePath); | ||
|
|
||
| try | ||
| { | ||
| return StringConverter::ToLower (StringConverter::Trim (Process::Execute ("blkid", args, 2000))); | ||
| } | ||
| catch (...) | ||
| { | ||
| return string(); | ||
| } | ||
| } |
There was a problem hiding this comment.
This duplicates the DetectFilesystemType helper added in CoreUnix.cpp. Please consolidate this into a single Linux helper used by both the native dm-crypt path and the auxiliary-image path.
| static string DetectFilesystemType (const DevicePath &devicePath) | ||
| { | ||
| list <string> args; | ||
| args.push_back ("-o"); |
There was a problem hiding this comment.
Please use uncached probing here, e.g. add -p so this calls blkid -p -o value -s TYPE -- <device>. VeraCrypt reuses /dev/mapper/veracryptN names, so relying on cached blkid results would be a bad failure mode.
| string DetectFilesystemType (const DevicePath &devicePath) | ||
| { | ||
| list <string> args; | ||
| args.push_back ("-o"); |
There was a problem hiding this comment.
Please use uncached probing here, e.g. add -p so this calls blkid -p -o value -s TYPE -- <device>. VeraCrypt reuses /dev/mapper/veracryptN names, so relying on cached blkid results would be a bad failure mode.
| <entry lang="en" key="LINUX_PREF_TAB_MOUNT_OPTIONS_FS">Filesystem</entry> | ||
| <entry lang="en" key="IDT_LINUX_PREF_TAB_MOUNT_OPTIONS">Mount options:</entry> | ||
| <entry lang="en" key="LINUX_PREF_MOUNT_NTFS_WITH_NTFS3">Mount NTFS volumes with the Linux kernel ntfs3 driver</entry> | ||
| <entry lang="en" key="LINUX_PREF_MOUNT_NTFS_WITH_NTFS3_HELP">When enabled, VeraCrypt detects NTFS filesystems and mounts them with ntfs3 instead of ntfs-3g/fuseblk. This can avoid suspend or hibernate hangs on systems where user-space FUSE filesystems are frozen while the kernel is syncing filesystems. The ntfs3 kernel module must be available and allowed by the distribution.</entry> |
There was a problem hiding this comment.
Please make this text more explicit that the preference applies only when VeraCrypt detects TYPE=ntfs via blkid. If detection fails, the normal mount path is used. If ntfs3 is unavailable or blacklisted by the distribution, users should not be left with the impression that the FUSE path was definitely avoided.
| <entry lang="ru" key="LINUX_PREF_MOUNT_NTFS_WITH_NTFS3">Монтировать NTFS-тома через драйвер ядра Linux ntfs3</entry> | ||
| <entry lang="ru" key="LINUX_PREF_MOUNT_NTFS_WITH_NTFS3_HELP">Если включено, VeraCrypt определяет файловые системы NTFS и монтирует их через ntfs3 вместо ntfs-3g/fuseblk. Это может предотвратить зависания при ждущем режиме или гибернации на системах, где пользовательские FUSE-файловые системы замораживаются, пока ядро синхронизирует файловые системы. Модуль ядра ntfs3 должен быть доступен и разрешён дистрибутивом.</entry> |
There was a problem hiding this comment.
It is preferable to keep entries in English for this PR and have a separate PR for translation so that it can reviewed by maintainer of the Russian translation.
|
Thanks for the note about translation changes. I removed the Russian language and Russian documentation updates from this PR in 2411942, so this PR now keeps only the code changes plus English strings/docs. If this PR is accepted, I can follow up with a separate Russian translation PR based on the final English text. |
Summary
This PR allows Linux users to mount NTFS volumes with the in-kernel
ntfs3driver instead ofntfs-3g/fuseblk.It intentionally does not add sleep hooks, automatic dismounting, or arbitrary filesystem type passthrough. It adds a narrow Linux-only
ntfs3path for NTFS volumes.Motivation
This is related to #1660.
On recent Linux/systemd combinations, NTFS VeraCrypt volumes mounted through
ntfs-3gappear asfuseblk. During suspend/hibernate, systemd may freezeuser.slicewhile the kernel sleep path tries to sync FUSE-backed filesystems. If the userspacentfs-3gdaemon is frozen, the sleep path can hang.Mounting the NTFS filesystem with the Linux in-kernel
ntfs3driver avoids the FUSE userspace daemon path.What changed
ntfs3as a valid Linux value for--filesystem.ntfs3.VolumeCreationOptions::FilesystemType::NTFSmapping, becausentfs3is a Linux mount driver for the NTFS filesystem, not a separate on-disk format.blkidand mount them withntfs3automatically. This applies to the Linux native dm-crypt path and to the fallback auxiliary-image mount path.ntfs3kernel module must be available and allowed by the distribution. Some distributions blacklist it by default and require administrator action before it can be loaded.--filesystem=ntfs3.Local validation
I reproduced the affected setup on openSUSE Tumbleweed with:
6.19.11-1-default259.5+suse1.26.24ntfs-3g:2022.10.3fuse3:3.18.2The affected NTFS VeraCrypt volume previously mounted as
fuseblkand hibernation could hang. I then opened the VeraCrypt volume without mounting its filesystem and mounted the virtual device with:findmntthen reported:With the VeraCrypt volume left mounted as
ntfs3, hibernation and resume completed successfully and the volume remained mounted after resume.Patched binary validation:
make NOGUI=1.make).veracrypt --text --helpincludes the newntfs3help text and example.--filesystem=ntfs3is accepted by the command-line parser.--filesystem=definitely-not-allowedis still rejected as an unknown option.Live patched-binary mount validation:
--filesystem=ntfs3.findmntreported the mounted filesystem asntfs3on/dev/mapper/veracrypt1.Favorite-volume validation:
MountNtfsWithNtfs3preference.--load-preferences --auto-mount favorites;findmntreportedntfs3.Favorites -> Mount Favorite Volumes;findmntreportedntfs3.ntfs3, hibernation and resume completed successfully and the volume remained mounted after resume.