Re: How to find disk is in use?



phil-news-nospam@xxxxxxxx wrote:




I don't know of a specific feature that would let the kernel tell you this
directly. So I suspect what you will need to do is codify into your program
what the relationship between /dev/sda3 and /dev/sda is. In other words,
for a test of a full device, the program needs to know _all_ the possible
partition device names and run the test against them all to see if any of
them is busy. I also suggest that you do NOT read the partition table to
get a shortcut of a subset of partitions to test if this is an application
that you may be distributing to others (maybe there are conditions under
which it could be used where the on-disk partition table does not reflect
that actual set of busy partitions known to the active kernel). You can
get what the kernel thinks are "the partitions" in /proc/partitions.


If you are at a kernel level and have the "sysfs" feature active, you can
derive a set of common names for the whole-to-partition device relationship
within /sys/block for each respective device.

Since I can write over a partition table even with a partition on that
disk mounted, I can say that attempting to open the whole device for
writing is not going to be prevented by a busy partition. Maybe you have
already discovered this and thus seek a better way.

No I have not discoverd this, of course, I am looking for better way. I
have not started writing code for this feature yet, just preparing.
However I am thinking in the same angle. For example:
1) Do what ever "# fdisk -l /dev/sdc" command would do, basically
reading the partition table
Or this can be done through sys/block also... what is the better
method...???
2) Do what ever # umount /dev/sdc[1-..N] , if some process is running
on that parition.
3) Do what ever lsof and fuser does

By the way I keeping distance from /proc filesystem as it can get
obsloute any time

.



Relevant Pages

  • [PATCH 2.6] POWER5 Virtual Ethernet Checkum offload
    ... The following patch adds checksum offloading for the POWER5 Virtual ... communicating support this feature (i.e. both partition have this patch ... in the case where one of the OS in a partition does support ...
    (Linux-Kernel)
  • Re: How to find disk is in use?
    ... I don't know of a specific feature that would let the kernel tell you this ... I also suggest that you do NOT read the partition table to ... that actual set of busy partitions known to the active kernel). ...
    (comp.os.linux.development.system)
  • Re: Laufwerksicherung wie ohne zusätzliche Partition?
    ... Acronis True Image ... Also optionales Feature. ... Um auf eine "versteckte" Partition zuzugreifen bedarf es nur der ... Macht Acronis auch nicht. ...
    (de.comp.hardware.laufwerke.festplatten)
  • Re: Extending cdboot with options "Press any key to boot from CD" prompt
    ... >>installation CDs. ... IMHO this feature is quite useful for installation ... Windows bootloaders that refuse to boot if their partition is not active ...
    (freebsd-current)
  • Re: Question for Rick C.
    ... of a DDR formated partition without the DDR DVD-RAM? ... FR-2 Feature for automatically returning to input monitor ...
    (rec.arts.movies.production.sound)