rossoreed
Posts: 35
Joined: Mon Dec 30, 2013 9:48 am

/var/log mounted in tmpfs

Sun Dec 20, 2015 9:59 pm

I'm writing a script which will be used on Raspberry Pi's that will be configured in 2 ways;
a) Pi's that are have /var/log mounted on a physical drive
b) Pi's that have their /var/log mounted as tmpfs
I need a conditional statement that will differentiate between the 2, so if /var/log is mounted in tmpfs - the script will run, but if mounted on a physical drive then it wont.

To achieve this;

if /var/log = tmpfs {
...run my script
}

Any help would be appreciated.

User avatar
rpdom
Posts: 17174
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: /var/log mounted in tmpfs

Mon Dec 21, 2015 4:39 am

You don't say what language this is to be scripted in, but I'll assume Bash

Code: Select all

if ( mount | grep "on /var/log "| grep -q "^tmpfs " )
then
  echo "/var/log is tmpfs"
fi

rossoreed
Posts: 35
Joined: Mon Dec 30, 2013 9:48 am

Re: /var/log mounted in tmpfs

Sun Dec 27, 2015 4:55 pm

rpdom, sorry it's taken so long to reply, but thanks, that's a great solution and it works very well.
Exactly what I was looking for.

Paul

Return to “Beginners”