Before we get into this, two things:

I'd parse the array device members from /proc/mdstat unless there's something easiler to parse.

I'd parse the location of drives-by-partition-id from "lsblk -bfr". That shows mount points too.

So that lets you figure out:

   lsblk: mount-point -> mounted device (an md device in this case)
   mdstat: md device -> sdXn names of its partition components
   sdXm: -> sdX the physical device you want to spin down

for the current state of the system. From the below it sounds like the mdstat step isn't correct.

On 05Jun2020 22:30, Patrick O'Callaghan <pocallag...@gmail.com> wrote:
That doesn't seem to be what's happening:

1) Starting from a fresh reboot, with the array unmounted but active
according to mdadm, I make it inactive:

# echo inactive > /sys/block/md127/md/array_state

(At this point I can make it active again using "echo active ...")

I presume that that just idles the md device; not changing its members.

In particular, it still believes that sda1 and sdb1 (to invent some device names) are its members.

Check /proc/mdstat to be sure.

In fact, look at /proc/mdstat after every md change; you'll find out what the md system thinks this way.

2) I now delete the component drives:

# echo 1 > /sys/block/sdd/device/delete
# echo 1 > /sys/block/sde/device/delete

After a timeout, the drives spin down. So far so good.

I think you should remove the md device before you do this. At least "mdadm --stop". See what /proc/mdstat says after doing that.

I'd be concerned that md would treat device deletion like drive failure. Deconfigure the md device first.

3) To spin them up again, I do:

# echo "- - -" > /sys/class/scsi_host/host6/scan

They come up with different numbers (/dev/sd[fg])

However the md system does not detect them:

The md system probably doesn't even know they need detecting, because it still has the old spec.

# mdadm -A
mdadm: an md device must be given in this mode

You probably want --auto-detect instead. -A is for manually constructing the array.

It's very possible (indeed likely) that I'm stopping the array in the
wrong way, but I don't see any other way to do it. The mdadm man page
mentions '-A' as the way to start an array, but doesn't talk about how
to stop it, so it could just be leaving out-of-date status information
around and that's what's confusing it.

Looks like --stop should delete/deconfigure the array. --auto-detect should find unconfigured array members and make new md devices from them.

Cheers,
Cameron Simpson <c...@cskk.id.au>
_______________________________________________
users mailing list -- users@lists.fedoraproject.org
To unsubscribe send an email to users-le...@lists.fedoraproject.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/users@lists.fedoraproject.org

Reply via email to