5

I have a raid5 array with quite large disks, so reconstruction is really slow in case of a power outage. Thankfully, there is the --write-journal option for linux md raid. The man page lists the --write-journal option in the For create, build, or grow: section, so I supposed it should work in grow mode, and tried to add a write journal on the fly:

# mdadm --grow /dev/md1 --write-journal /dev/ssd/md1-journal
mdadm: :option --write-journal not valid in grow mode

Does anyone know whether I can add a write journal to an existing array? And if so, how?

0

3 Answers 3

5

It kind of should work like this:

# mdadm --manage /dev/md42 --readonly --add-journal /dev/loop3
mdadm: Journal added successfully, making /dev/md42 read-write
mdadm: added /dev/loop3

However, currently (using kernel 4.18, mdadm 4.1-rc) that only seems to be possible for arrays that were created with journal in the first place. The above output was procuded after:

# mdadm --create /dev/md42 --level=5 --raid-devices=3 /dev/loop[012] --write-journal /dev/loop3
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md42 started.
# mdadm --manage /dev/md42 --fail /dev/loop3 --remove /dev/loop3
mdadm: set /dev/loop3 faulty in /dev/md42
mdadm: hot removed /dev/loop3 from /dev/md42

Creating an array without journal, all attempts to add a journal fail:

# mdadm --create /dev/md42 --level=5 --raid-devices=3 /dev/loop[012]
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md42 started.
# mdadm --manage /dev/md42 --readonly --add-journal /dev/loop3
mdadm: /dev/md42 does not support journal device.
# mdadm --manage /dev/md42 --readwrite --add /dev/loop3
# echo journal > /sys/block/md42/md/dev-loop3/state
bash: echo: write error: Invalid argument

So it just doesn't seem to be possible yet.

I have found a discussion on the linux-raid mailing list that this is a planned feature. If it has been implemented since, I don't see how. Perhaps contact the mailing list yourself to remind mdadm devs there are people who want this to work!

You might have to resort to mdadm --create to re-create the raid or edit metadata of the array. Either option is a bit dangerous.

1
  • 1
    I had to remove the internal bitmap before i was able to add a journal. mdadm --grow /dev/md42 --bitmap=none; echo resync > /sys/block/md42/md/consistency_policy; mdadm --manage /dev/md42 --add-journal /dev/loop3
    – Brain2000
    Commented Dec 16, 2020 at 17:20
0

This PDF states it is possible: https://events.static.linuxfound.org/sites/events/files/slides/2016_vault_write_journal_cache_v2.pdf

mdadm --manage /dev/md0 --add-journal /dev/sdf

1
  • Well, @frostschutz's answer already mentions the --add-journal option, as well as that it did not work yet in 1018. This answer really does not add to that by citing a 2016 presentation.
    – P.Péter
    Commented Jul 11, 2019 at 9:34
0

The raid should be in read-only state. See --add-journal in http://man7.org/linux/man-pages/man8/mdadm.8.html

Try: mdadm --manage /dev/md0 --readonly --add-journal /dev/sdf

3
  • This does not work on debian stretch, I will try it on buster later. Do you know what version of mdadm and kernel this requires?
    – P.Péter
    Commented Aug 26, 2019 at 14:03
  • 1
    Doesn't work. I ended recreating my array (dangerous! backup!): mdadm --create /dev/md0 --assume-clean --level=5 --raid-devices=3 --write-journal=/dev/sdd2 /dev/sda1 /dev/sdc1 /dev/sdb1 -k journal --bitmap=none Commented Sep 5, 2019 at 0:05
  • You have to do it in two commands. mdadm --readonly /dev/md0 then mdadm --manage /dev/md0 --addjournal /dev/sdf ... don't forget it you already have a bitmap, you may have to remove that first.
    – Brain2000
    Commented Jun 18, 2020 at 20:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .