Please try Linux kernel at http://people.canonical.com/~khfeng/lp1682456/
I cherry-picked two commits into Xenial kernel: 3fe7292f621a4fc9a52aff3a61dde21f24317810 md: fix refcount problem on mddev when stopping array. a841891c56826e6086a8a24ed9c036b71d023d75 md: changes for MD_STILL_CLOSED flag -- You received this bug notification because you are a member of Kernel Packages, which is subscribed to linux in Ubuntu. https://bugs.launchpad.net/bugs/1682456 Title: md devices may leave remnants in /sys/class/block after removal Status in linux package in Ubuntu: Confirmed Bug description: 1. root@x1:~# cat /proc/version_signature Ubuntu 4.4.0-72.93-generic 4.4.49 2. attached 3. # lsb_release -rd Description: Ubuntu 16.04.2 LTS Release: 16.04 4. # apt-cache policy linux-image-`uname -r` linux-image-4.4.0-72-generic: Installed: 4.4.0-72.93 Candidate: 4.4.0-72.93 Version table: *** 4.4.0-72.93 500 500 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages 500 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages 100 /var/lib/dpkg/status 5. After stopping an md device, the sysfs and /dev entry should be removed: mdadm --stop /dev/md0 && [ "`test -e /sys/class/block/md0`" = "1" ]; echo $rc should return 0; 6. /dev/md0 is gone, but /sys/class/block/md0 remains I believe this is related to this thread here: https://www.spinics.net/lists/raid/msg54859.html ProblemType: Bug DistroRelease: Ubuntu 16.04 Package: linux-image-4.4.0-72-generic 4.4.0-72.93 ProcVersionSignature: Ubuntu 4.4.0-72.93-generic 4.4.49 Uname: Linux 4.4.0-72-generic x86_64 AlsaDevices: total 0 crw-rw---- 1 root audio 116, 1 Apr 12 21:55 seq crw-rw---- 1 root audio 116, 33 Apr 12 21:55 timer AplayDevices: Error: [Errno 2] No such file or directory: 'aplay' ApportVersion: 2.20.1-0ubuntu2.5 Architecture: amd64 ArecordDevices: Error: [Errno 2] No such file or directory: 'arecord' AudioDevicesInUse: Error: command ['fuser', '-v', '/dev/snd/seq', '/dev/snd/timer'] failed with exit code 1: CRDA: N/A Date: Thu Apr 13 14:32:17 2017 IwConfig: Error: [Errno 2] No such file or directory: 'iwconfig' Lsusb: Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub MachineType: QEMU Standard PC (i440FX + PIIX, 1996) PciMultimedia: ProcEnviron: TERM=xterm PATH=(custom, no user) LANG=en_US.UTF-8 SHELL=/bin/bash ProcFB: ProcKernelCmdLine: BOOT_IMAGE=/boot/vmlinuz-4.4.0-72-generic root=UUID=4c974bc3-8fe8-41b5-a563-23b2dcf974c9 ro console=tty1 console=ttyS0 RelatedPackageVersions: linux-restricted-modules-4.4.0-72-generic N/A linux-backports-modules-4.4.0-72-generic N/A linux-firmware N/A RfKill: Error: [Errno 2] No such file or directory: 'rfkill' SourcePackage: linux UpgradeStatus: No upgrade log present (probably fresh install) dmi.bios.date: 04/01/2014 dmi.bios.vendor: SeaBIOS dmi.bios.version: Ubuntu-1.8.2-1ubuntu2 dmi.chassis.type: 1 dmi.chassis.vendor: QEMU dmi.chassis.version: pc-i440fx-yakkety dmi.modalias: dmi:bvnSeaBIOS:bvrUbuntu-1.8.2-1ubuntu2:bd04/01/2014:svnQEMU:pnStandardPC(i440FX+PIIX,1996):pvrpc-i440fx-yakkety:cvnQEMU:ct1:cvrpc-i440fx-yakkety: dmi.product.name: Standard PC (i440FX + PIIX, 1996) dmi.product.version: pc-i440fx-yakkety dmi.sys.vendor: QEMU To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1682456/+subscriptions -- Mailing list: https://launchpad.net/~kernel-packages Post to : kernel-packages@lists.launchpad.net Unsubscribe : https://launchpad.net/~kernel-packages More help : https://help.launchpad.net/ListHelp