Skip to content

Instantly share code, notes, and snippets.

@ScriptingSquirrel
Created June 13, 2018 19:25
Show Gist options
  • Save ScriptingSquirrel/53d7d6ccfb46d6ee57f1b8f9bc4ddefa to your computer and use it in GitHub Desktop.
Save ScriptingSquirrel/53d7d6ccfb46d6ee57f1b8f9bc4ddefa to your computer and use it in GitHub Desktop.
Shrink existing Linux software RAID array

Current state of RAID array:

$ cat /proc/mdstat 
Personalities : [raid1] [linear] [multipath] [raid0] [raid6] [raid5] [raid4] [raid10]
md125 : active raid1 sdf4[1] sde4[0] sdg4[2]
      1922130944 blocks super 1.2 [3/3] [UUU]

unused devices: <none>

Modify RAID array /dev/md125:

# mark disk as failed and remove (`sdg4` in this example)
mdadm --fail /dev/md125 /dev/sdg4
mdadm --remove /dev/md125 /dev/sdg4

# shrink to new size
mdadm --grow --raid-devices=2 /dev/md125

Verify:

$ cat /proc/mdstat 
Personalities : [raid1] [linear] [multipath] [raid0] [raid6] [raid5] [raid4] [raid10]
md125 : active raid1 sdf4[1] sde4[0]
      1922130944 blocks super 1.2 [2/2] [UU]

unused devices: <none>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment