查找文件系统上次挂载的时间

查找文件系统上次挂载的时间

我想查明上次在 L​​inux(Debian)上挂载文件系统的时间。有什么帮助吗?

答案1

更新:嗯,这太简单了

$ sudo tune2fs -l /dev/sda1
tune2fs 1.41.11 (14-Mar-2010)
Last mounted on:          /
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem state:         clean
Errors behavior:          Continue
Filesystem OS type:       Linux
Inode count:              7028736
Filesystem created:       Sat Nov 14 20:49:49 2009
Last mount time:          Wed Jun  9 18:19:42 2010
Last write time:          Thu Jun  3 09:38:18 2010
Mount count:              20
Maximum mount count:      32

并且tune2fs也处理 ext4 分区,只是我手边没有。

答案2

我刚刚通过读取(或任何其他 PID)找到了一种用于 NFS 的方法/proc/self/mountstats。它给出了以秒为单位的年龄:

device 1.2.3.4:/HOME mounted on /mnt/HOME with fstype nfs statvers=1.1
[...]
    age:    1047998
[...]

答案3

供将来参考,msw 编辑历史中最初的“不太简单”的答案如下:


根据include/linux/ext3_fs.h挂载时间存储在 ext3 分区的超级块中的偏移量 0x2c 处:

...
/*
 * Structure of the super block
 */
struct ext3_super_block {
/*00*/  __le32  s_inodes_count;     /* Inodes count */
    __le32  s_blocks_count;     /* Blocks count */
    __le32  s_r_blocks_count;   /* Reserved blocks count */
    __le32  s_free_blocks_count;    /* Free blocks count */
/*10*/  __le32  s_free_inodes_count;    /* Free inodes count */
    __le32  s_first_data_block; /* First Data Block */
    __le32  s_log_block_size;   /* Block size */
    __le32  s_log_frag_size;    /* Fragment size */
/*20*/  __le32  s_blocks_per_group; /* # Blocks per group */
    __le32  s_frags_per_group;  /* # Fragments per group */
    __le32  s_inodes_per_group; /* # Inodes per group */
    __le32  s_mtime;        /*  Mount time  <--------------------------------------  */
/*30*/  __le32  s_wtime;        /* Write time */
...

(我冒昧地让它Mount time更容易被找到。)

相关内容