Destination replication pool/datasets are not read only

Matt_G

Explorer
Joined
Jan 24, 2016
Messages
65
My server has two pools.
MainPool and BackupPool.
I have a daily periodic snapshot task of the whole MainPool (recursive) and it is being replicated to BackupPool.
Note that I did not make any datasets on BackupPool.
The replication process made all the datasets on the BackupPool first time it ran.

Yesterday I ran a zfs get all BackupPool and noticed that readonly=off.
So I checked all the datasets and they are readonly=off as well.
I was under the impression that readonly would be on for those datasets.
Now I am thinking I should turn it on myself but thought I would ask first.
Should I?
If I do, will it break replication?
 

Chris Moore

Hall of Famer
Joined
May 2, 2015
Messages
10,080
So I checked all the datasets and they are readonly=off as well.
I was under the impression that readonly would be on for those datasets.
Now I am thinking I should turn it on myself
Why?
 

Matt_G

Explorer
Joined
Jan 24, 2016
Messages
65
Well, I was going to say because I think it's safer that way in the event of a cryptolocker scenario, but since it isn't mounted anyways...I guess it really doesn't matter that much, does it?
 

Chris Moore

Hall of Famer
Joined
May 2, 2015
Messages
10,080
Well, I was going to say because I think it's safer that way in the event of a cryptolocker scenario, but since it isn't mounted anyways...I guess it really doesn't matter that much, does it?
That is what I was thinking.
 

Matt_G

Explorer
Joined
Jan 24, 2016
Messages
65
I wonder what the reason was for the dev's to design it so they would be created read only. They had to have one...
 
Joined
Jul 3, 2015
Messages
926
readonly=on is the default when replicated to a second server so not sure why yours isn't set to that. However I see no harm in setting readonly=on on your replica parent dataset and I don't believe that will hurt anything.
 

Matt_G

Explorer
Joined
Jan 24, 2016
Messages
65
Out of curiosity, I have set it to on and will see tomorrow if tonight's replication task runs ok.
 

Apollo

Wizard
Joined
Jun 13, 2013
Messages
1,458
I don't think readonly is set by default upon replication to a backup volume.
Normally, you would run the following command"

zfs set readonly=on -r pool_name before setting replication.

If you set the backup volume to Readonly while it has no dataset replicated yet, then upon importing the volume, you will get errors related to not being able to mount the dataset. Not an issue if your snapshots are present.
Not having mounted dataset will only make your life difficult if you want to perform zfs diff between snapshots. This will not be possible unless you are able to mount the dataset.
You can of course change the zfs readonly state once to :
[cms]zfs set readonly=on[/CMD] then reboot (best option) wait for the import to finalize, then set volume back to read only.
With non mounted vloume, you will not be able to list files within them, until you mount them.

If you were to replicate a readonly volume with none of the datasets mounted, you can still do it without issues. In general, snapshot replication is not dependent on Readonly status.
So having readonly set to on on a backup volume is a safe and proper way of handling things. By the way, having it set to readonly will also (should not allow snapshot to be destroyed automatiaclly when they have expired).

PS. All my backups done through replication are set to readonly=on.
However, if some of the datasets are not mounted, I can decide to do so once and revert to readonly=on when done.
 
Joined
Jul 3, 2015
Messages
926
I don't think readonly is set by default upon replication to a backup volume.
Normally, you would run the following command"

zfs set readonly=on -r pool_name before setting replication.

When setting up replication via the FreeNAS UI then I'm quite sure readonly to the replica system is default by design.

Just to avoid confusion I am not saying that readonly is set on the primary but on the replica target.
 
Joined
Jul 3, 2015
Messages
926
By the way, having it set to readonly will also (should not allow snapshot to be destroyed automatiaclly when they have expired).
Im pretty sure this statement is not true.

Edit: Just checked and even if you set the dataset to readonly=on your snapshots still get destroyed when they expire on both primary and replica.
 
Last edited:
Joined
Jul 3, 2015
Messages
926
Further to this I've just done a test on a new 11.1-U6 system and readonly is off on the replica. Im confident this behaviour has changed as when I look at all my other older systems their replica is readonly=on and even though they are now up-to-date running 11.1-U6.3 this is still the case. Im sure this behaviour has changed a couple of times throughout the years.
 

Matt_G

Explorer
Joined
Jan 24, 2016
Messages
65
I don't think readonly is set by default upon replication to a backup volume.
Per the documentation:
The target dataset on the receiving system is automatically created in read-only mode to protect the data. To mount or browse the data on the receiving system, create a clone of the snapshot and use the clone. Clones are created in read/write mode, making it possible to browse or mount them. See Snapshots for more information on creating clones.
Replication Tasks
 

Apollo

Wizard
Joined
Jun 13, 2013
Messages
1,458
Im pretty sure this statement is not true.

Edit: Just checked and even if you set the dataset to readonly=on your snapshots still get destroyed when they expire on both primary and replica.
There must be the -d option on the replication to delete stale snapshots, otherwise snapshots shouldn't be destroyed on the replica.
 
Top