使用tune2fs
可以设置最大挂载计数-c
(在启动时启动e2fsck之前)以及实际(当前)挂载计数-C
。我正在寻找一种读取这两个值的方法。
答案 0 :(得分:2)
手册页有-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
所以你可以成功
function mount_count()
{
tune2fs -l "$1" |
grep '^Mount count:' |
grep -oP '\d+'
}
现在你可以
mounted=$(mount_count /dev/sda1)
echo "Volume sda1 has already been mounted $mounted times since last check"