Very weird problem here:
I umounted the filesystem on a md (RAID1) device.
Then:
mdadm --stop /dev/md1 mdadm: Cannot get exclusive access to /dev/md1:Perhaps a running process, mounted filesystem or active volume group?
Huh?
lsof /dev/md1 <nothing!>
I remounted the fs and tried lsof <fs> and it was empty too.
I can't seem to find any reason why mdadm --stop should not allow stopping this array. Any ideas? Anything other than lsof that can help find out why?
I should also mention (confess?) that the array I'm trying to stop is my /boot partition (on a running system booted from it!). Don't ask...
Yet I see nothing that would constitute an "open" file in it, unless the low level kernel boot stuff keeps something there "open"? If so, though, why can I umount it?
The source for mdadm --stop says:
216 /* Get EXCL access first. If this fails, then attempting 217 * to stop is probably a bad idea. 218 */ 219 close(fd); 220 fd = open(devname, O_RDONLY|O_EXCL); 221 if (fd < 0 || fd2devnum(fd) != devnum) { 222 if (fd >= 0) 223 close(fd); 224 fprintf(stderr, 225 Name ": Cannot get exclusive access to %s:" 226 " possibly it is still in use.\n", 227 devname); 228 return 1; 229 }
So it's failing to get O_RDONLY|O_EXCL open on /dev/md1.
Still would like to know why though.