Is it possible to configure software RAID 5 on linux that uses system RAM for write cache? I have a file server with 8GB of RAM ... would be really cool if I could dedicate 4GB to write cache. If so, how is this done? Thanks.
Asked
Active
Viewed 6,195 times
2
-
Note that any synchronous writes will still have to wait for the disks; this is more common than you'd think. – Chris S Mar 30 '11 at 02:32
-
Right that's fine -- but I'm looking to implement "write back" cache without purchasing an expensive hardware RAID controller. Is that possible? – ensnare Mar 30 '11 at 02:45
-
6Just be aware that this is incredibly dangerous. Writes that are in your cache but have not been comitted to disk can (will) corrupt your data if power is lost unexpectedly (crash, pull out power plug, etc). Any decent RAID controller won't let you (or makes it really hard) to enable write cache unless you have a battery backup unit on the card itself, and there's a reason for that. – Mark Henderson Mar 30 '11 at 04:12
-
That makes a lot of sense. I have a UPS unit protecting the server and am hoping that can sufficiently protect the data. – ensnare Mar 30 '11 at 05:48
-
If you don't care about protecting your data against drive failure, then why not just use RAID0 and stripe it all the way across? – Avery Payne Jan 26 '14 at 03:23
1 Answers
4
That's kinda awkward due to read-write cache is always there in despite of having RAID or a single disk block device. But there's one knob which can add more RAM for RAID's own stripe-cache: /sys/block/mdYOUR_MD_NUMBER/md/stripe_cache_size
stripe_cache_size (currently raid5 only) number of entries in the stripe cache. This is writable, but there are upper and lower limits (32768, 16). Default is 128.
This knob is addressed to lower "partial write" performance issue, AFAIS. It's meaning is number of cache pages (4k) per every disk drive in RAID.
![](../../users/profiles/67675.webp)
poige
- 9,171
- 2
- 24
- 50
-
Thanks! What are the units, KB or MB? Seems that 32MB would be pretty small for a write cache? – ensnare Mar 30 '11 at 02:45
-
That's not MBs or KBs. As doc says: "*number of entries* in the stripe cache". You can check `free -m` before setting it to 32768 and after. You'll see. :) – poige Mar 30 '11 at 02:50
-
@ensnare, actually this is number of cache pages (4k) per every disk drive in RAID. – poige Sep 06 '12 at 06:24
-
Is it per data disk, or disks total? Since it's RAID5, you got N disks in array, but N-1 of data. – Marcin Sep 07 '12 at 13:09
-
1@Marcin, `N - 1` of data has nothing to do with it, since usual layout of RAID-5, for e. g., is parity spread across all of the disks. So it seems to be reasonable to assume **literally** *per every disk drive of RAID*. `free -m` before/after should tell for sure, though. – poige Sep 07 '12 at 15:28