Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to know what the easiest way is to determine (without root privilege) whether a block device (say sdb) or any part of it is mounted (and which part of it).

Checking /proc/mounts for sdb is not enough because sdb or one of its partitions may be used by LVM. You can check /sys/block/sdb/sdb*/holders/ but you get dm-x entries which have to be resolved to /dev/mapper names in order to check /proc/mounts. Possible but if there is an easier solution... (which should not require root privilege)

share|improve this question
up vote 4 down vote accepted

This is essentially a matter of checking a whole bag of corner cases.

  • A drive can appear in /proc/mounts
  • A drive can be used as swap (use /proc/swaps)
  • A drive can be part of an active LVM pv (use pvdisplay)
  • A drive can be part of a dm-mapper RAID group (use /proc/mdstat)
  • A drive can be directly accessed by an application (e.g. Oracle supports writing directly to a drive or partition instead of a filesystem) (use fuser)
  • A drive can be directly accessed by a virtual machine (use fuser)
  • A drive can be referenced by a loopback device (e.g: mount /dev/sda -o offset=1M /foo) (use losetup -a)

These are just the examples I came up with given a minute and a half to think about it. I'm sure there's a dozen others.

This last example I think is the most interesting and few people know about it. It allows you to mount a filesystem without using partitions. Just specify the starting offset and Linux will transparently create a loopback device. The example above yields the following:

# cat /proc/mounts
/dev/loop0 /foo ext4 relatime,data=ordered 0 0

# losetup -a
/dev/loop0 [0005]:2048 (/dev/sda), offset 1048576

Why would you do that? Typically it involves situations where things have previously gone horribly wrong.

Also bear in mind that with the namespacing feature now in mainline (see unshare), different processes can have different views about what's mounted and what isn't. Here things start to get a little bit red-pill.

share|improve this answer

There is much more ways to mount devices, all of them can be combined, so it's like often, up to you to find out.

i.e. what's used by lvm: pvdisplay

So you need include also nfs, cifs, raid, loop, crypt, and so on. A good starting point is always /proc/mounts, as you have already mentioned.

share|improve this answer

Have you thought about using the output of mount ?

share|improve this answer
You consider the output of mount superior to the content of /proc/mounts? – Hauke Laging Jan 31 '14 at 2:19
This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. – Anthon Jan 31 '14 at 3:07

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.