Allow the shell "mount" command to use the -t ntfs option

Problem/Justification
When running a windows VM, we occasionally need to restore a file from a previous snapshot. When the -t ntfs option was available, we would simply clone the zvol, mount it, and pluck out the file that we needed. Now that the option has been removed, we need to use an additional VM in order to mount the zvol in order to fetch the file. This breaks the ability to automate audits, quickly restore files, etc. Allowing the use of “mount -t ntfs” would return our ability to automate audits, and to quickly restore single files.

Impact
With the ability restored, we would be able to very quickly restore single files from zvols that are housing ntfs filesystems. There would be no negative impact, as users wouldn’t be able to accidentally stumble on this. A user that is manually running the “mount” command would already be aware of any implications.

User Story 1
A file is accidentally deleted from a windows VM. An administrator is notified and clones the snapshot from the desired timeframe. The administrator then uses the “-t ntfs” option to mount the zvol. They copy the file out that they need. After, they unmount the zvol, then destroy the clone.

User Story 2
A series of VMs are all using zvols. These zvols are replicated elsewhere. An administrator wants to automate mounting, reading a random file, and then unmounting the zvol. This would be done to ensure that the replication is working properly as part of a data resiliency strategy implemented at the organization. Using the “-t ntfs” option for the mount command, they are able to have their script do a full audit from start to finish.

I have absolutely zero experience with mounting NTFS in Linux but I assume you should just be able to modprobe ntfs3 and then mount it as normal?

root@truenas[~]# find /lib/modules/6.12.9-production+truenas/ | grep ntfs
/lib/modules/6.12.9-production+truenas/kernel/fs/ntfs3
/lib/modules/6.12.9-production+truenas/kernel/fs/ntfs3/ntfs3.ko
root@truenas[~]#

Unfortunately, it doesn’t appear to be an option

root@truenas[/home/truenas_admin]# modprobe ntfs3
modprobe: FATAL: Module ntfs3 not found in directory /lib/modules/6.6.44-production+truenas

root@truenas[/home/truenas_admin]# find /lib/modules/6.6.44-production+truenas/ | grep ntfs
root@truenas[/home/truenas_admin]# 

It used to be available, but it does not appear to be anymore.

I should mention: I’m on ElectricEel-24.10.2 .

This was a lot of fun, learnt some nice new bits:

root@truenas[/tmp]# file -s /dev/zvol/data/nvme_backup/VM/workbox_new-e54uf
/dev/zvol/data/nvme_backup/VM/workbox_new-e54uf: symbolic link to ../../../../zd432
root@truenas[/tmp]#
root@truenas[/tmp]# fdisk -l /dev/zd432
Disk /dev/zd432: 100 GiB, 107374182400 bytes, 209715200 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 16384 bytes
I/O size (minimum/optimal): 16384 bytes / 33554432 bytes
Disklabel type: gpt
Disk identifier: 2B57F1FD-3340-4FB4-A290-A8807F32FA26

Device           Start       End   Sectors  Size Type
/dev/zd432p1      2048    206847    204800  100M EFI System
/dev/zd432p2    206848    239615     32768   16M Microsoft reserved
/dev/zd432p3    239616 208651887 208412272 99.4G Microsoft basic data
/dev/zd432p4 208652288 209711103   1058816  517M Windows recovery environment

So, I want 239616 * 512 (starting sector multiplied by the 512 byte sector-size) to get the data partition.

Create a loop device:

root@truenas[/tmp]# sudo losetup -f --show -o 122683392 /dev/zd432
/dev/loop0

And mount it:

root@truenas[/tmp]# sudo mount -t ntfs3 /dev/loop0 /tmp/test
root@truenas[/tmp]# cd test
root@truenas[/tmp/test]# ls
'$Recycle.Bin'             DumpStack.log.tmp      ProgramData                  Windows
'$WinREAgent'              PerfLogs               Recovery                     hiberfil.sys
'Documents and Settings'  'Program Files'        'System Volume Information'   pagefile.sys
 DumpStack.log            'Program Files (x86)'   Users                        swapfile.sys
root@truenas[/tmp/test]#

One done, unmount and detach the loop device:

sudo umount /tmp/test
sudo losetup -d /dev/loop0

Ahh, that may well be why.
I’m on the fangtooth beta, it might not have been included in EE.

I’m hoping it’s included in the next release, that would be lovely. Also, your commands are great, but if you are already root (#) you don’t need to preface your command with sudo. :slight_smile:

As an aside, the same method works with using raw disks (which is where I started using this approach years ago, before FreeNAS could virtualize anything.)

Anyways, you give me hope that it will be available in Fangtooth. Thank you!

1 Like

Force of habit :slight_smile:
Hopefully it will be included, as seems odd for them to have included it only to remove it later.

Auxiliary Paramters


Rsync Service


Swap


Buffer partition


Option to put Syslogs on the System Dataset

2 Likes

Don’t know what you’re talking about, this is extremely user friendly :grin::


(on a sidenote, this used to be a workaround but no idea if it still works or not)