A couple of days ago, I was asked how to check the last mount time of the ext2/ext3/ext4 filesystem. The solution is straightforward as it does not require anything more then tune2fs
utility.
$ sudo tune2fs -l /dev/mapper/enc-root | grep "Last\|created" Last mounted on: / Filesystem created: Sat Aug 3 16:11:50 2013 Last mount time: Fri Aug 30 21:04:14 2013 Last write time: Fri Aug 30 21:04:14 2013 Last checked: Sat Aug 3 16:11:50 2013
Pretty print mounted devices:
$ mount | awk '/dev.*ext/ {print $1}' | xargs -I DEVICE sh -c '{ mount | grep DEVICE | awk "{ print "----- device " $1 " mounted on " $3 }"; sudo tune2fs -l DEVICE | grep "Last|created"; }' ----- device /dev/mapper/enc-root mounted on / Last mounted on: / Filesystem created: Sat Aug 3 16:11:50 2013 Last mount time: Fri Aug 30 21:04:14 2013 Last write time: Fri Aug 30 21:04:14 2013 Last checked: Sat Aug 3 16:11:50 2013 ----- device /dev/sdb1 mounted on /media/3927ea4d-b079-407e-9151-f0a9f97b5640 Last mounted on: <not available> Filesystem created: Wed Jun 19 20:12:47 2013 Last mount time: n/a Last write time: Sun Sep 1 23:57:52 2013 Last checked: Wed Jun 19 20:12:47 2013
Notice the
sudo
command in the above example.