Linux software RAID array is in auto-read-only mode (BASH)

mdadm may sometimes send a "degraded array alert" reporting that at least one array is in auto-readonly

md1 : active (auto-read-only) raid1 sdc1[1] sdd1[0]

This most commonly happens after a restart/power-event and isn't usually an issue - MD arrays will be auto-read-only until they're first written too. It happens to try and help make array assembly a bit safer - nothing's written to disk until it actually needs to be

Details

  • Language: BASH

Snippet

# Assuming md1 is the array in auto-read-only

# Look for md1 to find which mount point is used for the array
lsblk | less

# If a mount point was found, verify it's mounted (replace $MOUNTPOINT 
# with the path) and cd there

mountpoint $MOUNTPOINT
cd $MOUNTPOINT

# Write to disk
touch test
rm test

# Verify that the array is no longer auto-read-only
cat /proc/mdstat

# If no mountpoint was found, then you *can* use mdadm to make the array readwrite 
# though there isn't really any need
mdadm --readwrite /dev/md1

Usage Example

cat /proc/mdstat | head -n 4 # show only the first 4 lines
Personalities : [raid1] 
md5 : active (auto-read-only) raid1 sde[0] sdb[2]
      3906887488 blocks super 1.2 [2/2] [UU]
      bitmap: 0/30 pages [0KB], 65536KB chunk

# Find a mount point underpinned by that array
lsblk | less
md5                                9:5    0   3.7T  0 raid1 
  VolGroupRaid-lvmusic           253:10   0   320G  0 lvm   /mnt/music

# Verify it's mounted
mountpoint /mnt/music
/mnt/music/ is a mountpoint

# cd into it and write a file
cd /mnt/music
touch test
rm test

# Verify it's now read-write
cat /proc/mdstat | head -n4
Personalities : [raid1] 
md5 : active raid1 sde[0] sdb[2]
      3906887488 blocks super 1.2 [2/2] [UU]
      bitmap: 0/30 pages [0KB], 65536KB chunk