linux raid bitmap

A mdadm bitmap, also called a “write intent bitmap”, is a mechanism to speed up RAID rebuilds after an unclean shutdown or after removing and re-adding a disk.

With a bitmap, writing data to the RAID goes like this:

Update bitmap: Mark the RAID chunks you are about to write to as dirty.
Write the data to the RAID.
Update bitmap: Mark the RAID chunks that were just written as clean.
The advantage of a bitmap is that if the system goes down in the middle of a write, the rebuild needs to check only the chunks marked as dirty, rather than the whole multi-TB RAID. This can speed up the rebuild process from taking several hours to completing in just a few seconds.

The drawback is lower write performance under normal use (outside rebuilds), since mdadm does additional disk access to update the bitmap.

external: Stored as a file on a disk outside the RAID. The advantage over an internal bitmap is better write performance during normal use (outside rebuilds).
internal: Stored as RAID metadata. The advantage over an external bitmap is that you don’t need a non-RAID disk and you save a bit on configuration (the path to the bitmap).

mdadm –grow –bitmap=internal

–bitmap=internal: Create an internal bitmap.
–bitmap=/var/bitmap.bin: Create an external bitmap at the specified path. The path must reside outside the RAID. A bitmap=… parameter must be added to the ARRAY entry in /etc/mdadm/mdadm.conf, and the –bitmap=… parameter must be passed if you are assembling the RAID from the command line.
–bitmap=none: Remove/disable any bitmaps.

Leave a Reply

Your email address will not be published. Required fields are marked *