[dm-crypt] Toggle read-only status of mapping
dm-crypt at dennis.birkholz.biz
Thu Oct 25 19:10:30 CEST 2012
Am 25.10.2012 17:20, schrieb Milan Broz:
> On 10/25/2012 04:50 PM, Dennis Birkholz wrote:
>> Am 25.10.2012 12:15, schrieb Milan Broz:
>> The reason is relatively easy: if my raid is read-only, it can crash and
>> I can reassemble it without a problem, but I cannot make it read-only if
>> the crypt-mapping is read-write.
> If you raid is mapped read-write, and there is a device failure, it either
> continue to be read-write (in degraded mode, that's exactly what "redundant"
> in RAID means) or the array is lost completely (then you must deactivate
> mapped device anyway).
> And raid allows resync while read-write so I really do not see real
> use for this switch.
> (And even read-only fs mount sometime means filesystem journal reply,
> specifically after fs crash.)
I know how this works, just to wrap it up:
I have a RAID5 with 5 devices that are in a e-sata box where the e-sata
connection seems to be quite fragile: sometimes the port-multiplier in
the box starts to make problems and than one device after another drops
away. If my raid is read-write, the devices are marked unclean if they
drop out, if the raid is read-only, the devices are not marked unclean.
The contents of the raid is quite static so I only change something
every few days. If I just can change everything to rw before putting
something on the raid and switch it back to ro afterwards would be
really nice (and yes, I know of raid bitmap and I am going to change the
fragile e-sata box anyway in the future). Assembling the raid again
after it crashed and I restarted the e-sata box is the real problem here...
> Anyway, it is easily to be done with dmsetup:
> NAME=<your crypt device name>
> # load identical but read-only table into inactive slot
> dmsetup reload $NAME --readonly --table "$(dmsetup table --showkeys $NAME)"
> # switch tables
> dmsetup resume $NAME
Thanks for the info!
More information about the dm-crypt