Troubleshooting: findmnt

 

  • I am using

    mount -o bind /some/directory/here /foo/bar

    I want to check /foo/bar though with a bash script, and see if its been mounted? If not, then call the above mount command, else do something else. How can I do this?

    CentOS is the operating system.

    You can use findmnt to solve it by passing the directory to the -M option;

    # findmnt -M /home/blackswan/point
    TARGET                SOURCE           FSTYPE OPTIONS
    /home/blackswan/point /dev/sda1[/test] ext4   rw,relatime,errors=remount-ro
    

     

  • I am currently using the last version of owncloud. Since the installation, I cannot login anymore. A quick look at /var/log/apache2/error.log explains why :WARNING: could not create relation-cache initialization file “global/pg_internal.init.7826”: No space left on device
    DETAIL: Continuing anyway, but there’s something wrong.
    WARNING: could not create relation-cache initialization file “base/17999/pg_internal.init.7826”: No space left on device
    DETAIL: Continuing anyway, but there’s something wrong.

You can check the space left on your root  device using -D option.

# findmnt -D /
SOURCE    FSTYPE  SIZE  USED AVAIL USE% TARGET
/dev/sda1 ext4   39.1G  7.1G   30G  18% /
  • Is there a Linux command to easily find out which partition/mount a directory or file is on?

    (This is probably a RTM question, and I feel guilty for asking it, but somehow, I can’t find a good answer on google just yet..

You can easily find this using the -T command options; this tells you where a particular path is mounted.

# findmnt -T /home/blackswan/Documents
TARGET SOURCE    FSTYPE OPTIONS
/      /dev/sda1 ext4   rw,relatime,errors=remount-ro
#

Helpful links:

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s