Question

With tune2fs one can set the maximum mount count -c (before e2fsck kicks in on boot) and also the actual (current) mount count -C. I'm looking for a way to read these two values.

Was it helpful?

Solution

the man page has -l:

sehe@desktop:~$ sudo tune2fs -l /dev/mapper/debian-uburoot  | grep count
Inode count:              1310720
Block count:              5241856
Reserved block count:     262092
Mount count:              12
Maximum mount count:      -1

So you could make it

function mount_count() 
{ 
    tune2fs -l "$1" | 
      grep '^Mount count:' | 
      grep -oP '\d+'
}

Now you can

mounted=$(mount_count /dev/sda1)
echo "Volume sda1 has already been mounted $mounted times since last check"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top