Truenas mounts NTFS mobile hard disk for cold backup


For the purpose of data protection, I took the measures of salt and dense cloud backup + mobile hard disk cold backup for the data in truenas.

On the one hand, it is safer to store more data. It is impossible for my hard disk, my mobile hard disk and the hard disk of the cloud manufacturer to crash at the same time;

On the other hand, it also maximizes the convenience of obtaining data when going out without exposing truenas to the public network. After the incident that the company Qunhui exposed a very rare port and was attacked violently, I dare not expose my NAS. I can download data through the cloud service provider and decrypt it; You can also take my mobile hard disk with you when you go out.

In order to maintain data compatibility to the greatest extent and ensure that it can be read on any computer, I chose NTFS for the file format of the mobile hard disk, which can support truenas, windows and MacOS (software required). Of course, the best way is exFAT. MacOS can support exFAT without software. However, at present, no scheme has been found for truenas to support exFAT.

The following is the text.


1、 Mount NTFS mobile hard disk

1. before the first mount, turn on fuse:

System, fine tuning and adding the following two items:

Variables: fuse_ load

Value: Yes

Type: Loader


Variables: fuse_ enable

Value: Yes

Type: rc conf

Then run from the command line (or SSH):

kldload fuse


2. mount the NTFS hard disk:

First, confirm which is your hard disk in the storage and disk. Generally, it can be identified by the size and model (click the right column and check the model). In addition, the name of the hard disk inside truenas generally starts with Ada, and the hard disk you just inserted is usually the last one. For example, if I hang a Seagate 4T hard disk, it is obviously the last one:


After remembering the hard disk name, run it from the command line or SSH:

#Please note that the following hard disk numbers and paths are modified to your own settings

Ls /dev/da1* \
Gpart show /dev/da1* \
MKDIR /mnt/exhdd \
ntfs-3g /dev/da1p1 /mnt/exhdd

Because we need to copy data to the mobile hard disk, I directly mount the read-write format. If you just want to read files, you can add-o -roParameters.

For other parameters of the ntfs-3g command, you can runman ntfs-3gFor instructions.


Note: because I am used to manual mounting after inserting the hard disk, if you want to further achieve automatic mounting after startup (that is, automatic mounting after truenas is restarted), please refer to this article:


2、 Copy data & set automatic copy task

It is recommended to use Rsync instead of CP command to copy data. Rsync provides very rich parameter instructions. See

Here we take the simplest-aRecursive directives (copying files and files in all subfolders), and–excludeExclude instructions. In addition, because the cron scheduling task of UNIX system has no execution result (you can view the cron log or the information in the mail when an error occurs), I am used to passing the command execution result through the>>The command is output to the specified log. I have created a data set to store each program log. This depends on my personal preference.

If you can accept the above preferences, you can view the following and directly copy my commands. If you can’t accept it, please modify the command yourself.

1. simulate data replication to ensure correct configuration

#If there are no folders to exclude, you can delete the exclude parameter directly
#The -n parameter is used to simulate operation and does not operate in practice
#The -v parameter is used to list all the files that will be transferred, and run the simulation with the -n parameter to check whether the configuration is correct
Rsync -a --exclude={'file or folder you want to exclude 1','xxx2','xxx3'} /mnt/media/data /mnt/exhdd/data > > /mnt/media/logs/rsyncdata log
#Please ensure that the destination path and log storage path have been established. If not, run:
mkdir -p /mnt/exhdd/data
mkdir -p /mnt/media/logs

The first path is the source path and the second path is the destination path. After the execution, check the log file to see if the listed files to be transferred are consistent with your expectations. If there are too many files to view, you can also directly pull to the end of the log to view the total size, and then compare the total size you want to transfer from the source path itself. There is no problem in confirming consistency. For example:


Note: if you don’t need to plan a task and only need to perform a copy, then repeat the above command and delete the -n and -v parameters. This is the end of this article for you.


2. set scheduled tasks

Before setting a scheduled task, it is best toFirst, manually execute “remove parameters” once-n、-v” ‘s order, this is because-vParameter, a file depending on the number of files you have will be generated. This log is usually very large. For example, if I have more than 10000 files, a 4.3mb file will be generated.But Rsync actually only transfers and records difference files at a time. So, we do it manually for the first time, and remove-vParameter, which is carried with the planned task-vParameter, so that only the newly added files will be recorded each time it is automatically executed in the future. You can view the detailed log and avoid the log being too large.


Rsync -a --exclude={'file or folder you want to exclude 1','xxx2','xxx3'} /mnt/media/data /mnt/exhdd/data > > /mnt/media/logs/rsyncdata log


After manual execution, let’s set the scheduled task:

The plan I set is to copy it every day at 3 a.m. If your files are updated more frequently and have higher requirements for file versions, you can modify the scheduled time by yourself, such as changing it to run every hour.

Our planning task is run based on cron. For the usage of cron, please refer to article to operate.

[Note 1] the planned tasks of truenas are different from the files in crontab. It is not recommended that you use command line settings to schedule tasks on truenas.

[Note 2] there is a pit. Please note that the quotation marks of the commands in the planned task of turenas will be removed, resulting in incorrect execution of the actual commands. such as–excludeParameter. If the quotation marks inside the braces are removed, the specified path will not be excluded. Therefore, braces can no longer be used to exclude, but can only be added one by one–exclude

Open task, schedule task, add:

Description: it can be added without filling. It is recommended to fill in the text you can understand for future management.

Command: delete the -v and -n parameters from the above simulated command:

Rsync -av –exclude the file or folder you want to exclude 1 –exclude XXX2 –exclude xxx3 /mnt/media/data /mnt/excldd/data > > /mnt/media/logs/rsyncdata log

User identity: root (if you need other users, you may need to modify permissions. See resources for details)

Plan: custom, and then set according to the following figure. You can also study this interface a little. In fact, it is very simple. You can easily set the execution plan you want:

Then, uncheck hide standard output and hide standard error, check enabled, and click save.


3. remove the hard disk

To remove the hard disk and take it out of the door, run the following command and then unplug it:


Umount /mnt/media/exhdd \




reference material