查看磁盘mount的时间点

  sre

ext文件系统

使用命令tune2fs查看文件系统最后一次挂载时间:

[root@localhost ~]# tune2fs -l /dev/vdb1
tune2fs 1.42.9 (28-Dec-2013)
Filesystem volume name:   <none>
Last mounted on:          /data
Filesystem UUID:          d08ec62d-f07e-46d3-942d-9a7c0cedaa83
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem features:      has_journal ext_attr resize_inode dir_index filetype needs_recovery extent 64bit flex_bg sparse_super large_file huge_file uninit_bg dir_nlink extra_isize
Filesystem flags:         signed_directory_hash 
Default mount options:    user_xattr acl
Filesystem state:         clean
Errors behavior:          Continue
Filesystem OS type:       Linux
Inode count:              3932160
Block count:              15728384
Reserved block count:     786419
Free blocks:              15435461
Free inodes:              3932148
First block:              0
Block size:               4096
Fragment size:            4096
Group descriptor size:    64
Reserved GDT blocks:      1024
Blocks per group:         32768
Fragments per group:      32768
Inodes per group:         8192
Inode blocks per group:   512
Flex block group size:    16
Filesystem created:       Tue Jun  4 15:30:31 2019
Last mount time:          Tue Jun  4 22:55:00 2019
Last write time:          Tue Jun  4 22:55:00 2019
Mount count:              2
Maximum mount count:      -1
Last checked:             Tue Jun  4 15:30:31 2019
Check interval:           0 (<none>)
Lifetime writes:          132 MB
Reserved blocks uid:      0 (user root)
Reserved blocks gid:      0 (group root)
First inode:              11
Inode size:           256
Required extra isize:     28
Desired extra isize:      28
Journal inode:            8
Default directory hash:   half_md4
Directory Hash Seed:      f4218ae5-8383-48d5-ac2e-14b8b52f39b6
Journal backup:           inode blocks

得到输出:

Last mount time:          Tue Jun  4 22:55:00 2019

NFS文件系统

用命令cat /proc/self/mountstats,通过age来判断,这个表示nfs挂载后的时间,单位为秒。
例如:

device 172.16.79.47:/nfs/elk-data-elasticsearch-0-pvc-7aa2098b-0bda-4e5e-ae79-22c5b244f5af mounted on /var/lib/kubelet/pods/3689e0bc-d3be-4c6a-994f-aff61c4c52bc/volumes/kubernetes.io~nfs/pvc-
7aa2098b-0bda-4e5e-ae79-22c5b244f5af with fstype nfs4 statvers=1.1  opts:   rw,vers=4.1,rsize=1048576,wsize=1048576,namlen=255,acregmin=3,acregmax=60,acdirmin=30,acdirmax=60,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=172.16.79.47,local_
lock=none   age:    24357440
    impl_id:    name='',domain='',date='0,0'
    caps:   caps=0x3ffdf,wtmult=512,dtsize=32768,bsize=0,namlen=255
    nfsv4:  bm0=0xfdffbfff,bm1=0x40f9be3e,bm2=0x803,acl=0x3,sessions,pnfs=not configured
    sec:    flavor=1,pseudoflavor=1
    events: 5913123 18088147 1603 1114516 5148933 11343 25160163 17316286 204 9061 94 2045058 10296700 541 249723 681106 2325 249354 0 19 2187230 3 0 0 0 0 0 
    bytes:  224133906 66606505872 0 0 637249990 65740946536 155904 16248743 
    RPC iostats version: 1.0  p/v: 100003/4 (nfs)
    xprt:   tcp 765 0 1 0 0 9457336 9457336 0 12812820 0 31 221968 3355489
    per-op statistics
            NULL: 0 0 0 0 0 0 0 0
            READ: 10004 10004 0 2044876 638290788 264 3111 3715
           WRITE: 1468813 1468813 0 66070386444 258511088 140623 741384 917992
          COMMIT: 58045 58045 0 10912612 6036680 1967 15116 18018
            OPEN: 244846 244846 0 77364596 90972688 8939 121452 136298
    OPEN_CONFIRM: 0 0 0 0 0 0 0 0
     OPEN_NOATTR: 3358 3358 0 860324 1130192 65 493 607
    OPEN_DOWNGRADE: 73 73 0 16060 12848 1 9 12
           CLOSE: 247623 247623 0 52498420 43581648 4898 51198 59629
         SETATTR: 1162 1162 0 273212 306768 14 175 222
          FSINFO: 1 1 0 180 164 0 0 0
           RENEW: 0 0 0 0 0 0 0 0
     SETCLIENTID: 0 0 0 0 0 0 0 0
    SETCLIENTID_CONFIRM: 0 0 0 0 0 0 0 0
            LOCK: 1192 1192 0 299492 133504 21 142 177
           LOCKT: 1 1 0 232 96 0 0 0
           LOCKU: 953 953 0 207288 106736 16 118 144
          ACCESS: 570732 570732 0 111865048 95882976 11256 121534 158573
         GETATTR: 5913150 5913150 0 1111679888 1419156000 94905 1290493 1748542
          LOOKUP: 255006 255006 0 55112160 74195988 2052 35869 47864
     LOOKUP_ROOT: 0 0 0 0 0 0 0 0
          REMOVE: 9118 9118 0 1792040 1057688 81 2751 3333
          RENAME: 243360 243360 0 66203600 36990720 4465 59235 66698
            LINK: 4 4 0 1084 1168 0 0 0
         SYMLINK: 2 2 0 552 664 0 0 0
          CREATE: 149 149 0 37216 49468 57 57 119
        PATHCONF: 1 1 0 172 116 0 0 0
          STATFS: 80162 80162 0 15072768 12825920 1859 14422 19022
        READLINK: 0 0 0 0 0 0 0 0
         READDIR: 403 403 0 85572 1591688 3 91 107
     SERVER_CAPS: 28 28 0 5040 4592 0 6 8
     DELEGRETURN: 1912 1912 0 397932 305920 1347 1350 2732
          GETACL: 0 0 0 0 0 0 0 0
          SETACL: 0 0 0 0 0 0 0 0
    FS_LOCATIONS: 0 0 0 0 0 0 0 0
    RELEASE_LOCKOWNER: 0 0 0 0 0 0 0 0
         SECINFO: 0 0 0 0 0 0 0 0
    FSID_PRESENT: 0 0 0 0 0 0 0 0
     EXCHANGE_ID: 0 0 0 0 0 0 0 0
    CREATE_SESSION: 0 0 0 0 0 0 0 0
    DESTROY_SESSION: 0 0 0 0 0 0 0 0
        SEQUENCE: 0 0 0 0 0 0 0 0
    GET_LEASE_TIME: 0 0 0 0 0 0 0 0
    RECLAIM_COMPLETE: 0 0 0 0 0 0 0 0
       LAYOUTGET: 0 0 0 0 0 0 0 0
    GETDEVICEINFO: 0 0 0 0 0 0 0 0
    LAYOUTCOMMIT: 0 0 0 0 0 0 0 0
    LAYOUTRETURN: 0 0 0 0 0 0 0 0
    SECINFO_NO_NAME: 0 0 0 0 0 0 0 0
    TEST_STATEID: 0 0 0 0 0 0 0 0
    FREE_STATEID: 770 770 0 111588 67760 12 86 103
    GETDEVICELIST: 0 0 0 0 0 0 0 0
    BIND_CONN_TO_SESSION: 0 0 0 0 0 0 0 0
    DESTROY_CLIENTID: 0 0 0 0 0 0 0 0
            SEEK: 0 0 0 0 0 0 0 0
        ALLOCATE: 0 0 0 0 0 0 0 0
      DEALLOCATE: 0 0 0 0 0 0 0 0
     LAYOUTSTATS: 0 0 0 0 0 0 0 0
           CLONE: 0 0 0 0 0 0 0 0

输出为age: 24357440,单位秒。

其他文件系统

在日志/var/log/messages 中搜索文件系统关键字:

grep XFS  /var/log/messages
grep EXT4 /var/log/messages
grep NTFS /var/log/messages

LEAVE A COMMENT

Captcha Code