Re: How to find disk is in use?
- From: "adar" <adar_ji@xxxxxxxxx>
- Date: 17 Oct 2006 22:47:32 -0700
Thank you David. Unfortunately it does not work on block device like
/dev/sda, it works provided a partition where a process is running.
For example
Ran fdisk /dev/sdc, without quiting fdisk, I ran fuser -m /dev/sdc, it
did not show me as anybody using it. Actually fdisk was in the process
of making partition.
Later mkfs /dev/sdc1 and ran fuser -m /dev/sdc, it still did not show
me as mkfs using it.
It works on partition though.
Welcome any more suggestions,
-Adar
David Schwartz wrote:
adar wrote:
I am looking for a system call or something similar to check whether
given disk (node /dev/sda, /dev/sdh etc) is in use. This will be
implemented in C language on Linux, so please suggest from C language
point.
For example,
#check-disk-in-use /dev/sda
Yes, in use
#check-disk-in-use /dev/sdh
Not in use
Please understand that user can provide only block device node, not a
partition.
Disk is use means:
A running application is born from this disk
A running application is reading/writing to this disk
Disk or disk partition is mounted and used
RAW read/write is happening on this disk
etc.
Basically if disk is used by any means from system/Linux this program
should be able to identifiy it. My system has 16 disks, and Linux OS
would be born from one of this disk and remaining 15 disk may be used
for data storage and for some application program.
The command 'fuser -m <device>' will do this. If you get no output at
all, then the block device is not in use. If you get output, it is a
list of process IDs of processes using that device along with a code
for how they are using it if appropriate.
If you need to write your own code to do it, obtain the source code to
'fuser' and borrow what you need.
DS
.
- Follow-Ups:
- Re: How to find disk is in use?
- From: Iwo Mergler
- Re: How to find disk is in use?
- From: Kaz Kylheku
- Re: How to find disk is in use?
- References:
- How to find disk is in use?
- From: adar
- Re: How to find disk is in use?
- From: David Schwartz
- How to find disk is in use?
- Prev by Date: Re: question about linux CPU scheduling
- Next by Date: Re: How to find disk is in use?
- Previous by thread: Re: How to find disk is in use?
- Next by thread: Re: How to find disk is in use?
- Index(es):
Relevant Pages
|