3

When I type mount, I should get a list of mounted file systems. But I get nothing.

I have the necessary files:

/proc/mounts 
/etc/mtab -> /proc/mounts

Also, cat /etc/mtab works fine. I get the correct output, such as:

/dev/root / ext4 ro,relatime,data=ordered 0 0
....

What files does mount need to print the correct output? I always thought, that /etc/mtab is sufficient. Where does mount get its information from, if not from /etc/mtab ?

6
  • You say "you get nothing". What exactly does that mean? Does it return to command prompt right away, or does mount just hang and not return anymore? Often, if it doesn't return and just hangs, the problem is related to stale NFS mount points.
    – replay
    Jan 1, 2014 at 18:37
  • no, it does not hang. It simply prints nothing. Same as if I ran echo -n Jan 1, 2014 at 18:41
  • could you try mount -l and separately check if mount is not aliased to anything using alias mount
    – Ketan
    Jan 1, 2014 at 19:18
  • As further diagnosis, you might want to run strace on mount: strace -o tracemount.txt mount and inspect tracemount.txt for any discrepancies.
    – Ketan
    Jan 1, 2014 at 19:29
  • What operating system (distribution, version, etc.)? What does type mount say? Jan 1, 2014 at 23:15

1 Answer 1

1

If you're trying to determine what file the mount command makes use of I'd run it through strace and see what system calls are made, and what files are accessed as a result.

Example

In looking at the output on my Fedora 19 system I noticed the following file getting opened when I run mount.

$ strace -o mount_strace.log mount

Now grep'ing for open calls.

$ grep open strace_mount.log 
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
open("/lib64/libmount.so.1", O_RDONLY|O_CLOEXEC) = 3
open("/lib64/libblkid.so.1", O_RDONLY|O_CLOEXEC) = 3
open("/lib64/libuuid.so.1", O_RDONLY|O_CLOEXEC) = 3
open("/lib64/libselinux.so.1", O_RDONLY|O_CLOEXEC) = 3
open("/lib64/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
open("/lib64/libdl.so.2", O_RDONLY|O_CLOEXEC) = 3
open("/lib64/libpcre.so.1", O_RDONLY|O_CLOEXEC) = 3
open("/lib64/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3
open("/run/mount/utab", O_RDWR|O_CREAT|O_CLOEXEC, 0644) = -1 EACCES (Permission denied)
open("/proc/self/mountinfo", O_RDONLY|O_CLOEXEC) = 3
open("/sys/block/dm-1/dm/name", O_RDONLY|O_CLOEXEC) = 3
open("/sys/block/dm-2/dm/name", O_RDONLY|O_CLOEXEC) = 3

The one that looks to be responsible is this /proc file, /proc/self/mountinfo.

Sample

$ tail /proc/self/mountinfo
36 16 0:7 / /sys/kernel/debug rw,relatime shared:22 - debugfs debugfs rw
37 17 0:12 / /dev/mqueue rw,relatime shared:23 - mqueue mqueue rw,seclabel
38 34 0:30 / /tmp rw shared:24 - tmpfs tmpfs rw,seclabel
39 17 0:31 / /dev/hugepages rw,relatime shared:25 - hugetlbfs hugetlbfs rw,seclabel
40 16 0:32 / /sys/kernel/config rw,relatime shared:26 - configfs configfs rw
41 35 0:33 / /proc/sys/fs/binfmt_misc rw,relatime shared:27 - binfmt_misc binfmt_misc rw
44 34 8:1 / /boot rw,relatime shared:28 - ext4 /dev/sda1 rw,seclabel,data=ordered
45 34 253:2 / /home rw,relatime shared:29 - ext4 /dev/mapper/fedora_greeneggs-home rw,seclabel,data=ordered
110 22 0:34 / /run/user/1000/gvfs rw,nosuid,nodev,relatime shared:92 - fuse.gvfsd-fuse gvfsd-fuse rw,user_id=1000,group_id=1000
113 16 0:35 / /sys/fs/fuse/connections rw,relatime shared:95 - fusectl fusectl rw

You can see the mounts there. As with most /proc files, there are additional fields in this file, but the 5th column looks to be the mounts.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .