How can I see if a (disk) block device is in use?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

from userspace, how can I reliably see if a (hard disk) block device
(say /dev/sda) is in use (either by the kernel, say through md or by
any userspace application such as dd)?

I would like to perform this check in a generic way, i.e. not per-se md related.


Although the question is non-md specific, it is slightly related to
this behaviour:

$sfdisk -R /dev/sdb
<race condition>
$mdadm --assemble /dev/md0 --run /dev/sda /dev/sdb /dev/sdc

mdadm: cannot open device /dev/sdc1: No such file or directory
mdadm: /dev/sdc1 has no superblock - assembly aborted

$sfdisk -R /dev/sdb
<race condition>
$sleep 1
$mdadm --assemble /dev/md0 --run /dev/sda /dev/sdb /dev/sdc

this works


Regards,
-- 
Leon
-
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux