How to know when the ext4/ext3/ext2 filesystem was created and when it was last mounted
February 19, 2021
How to know when the ext4/ext3/ext2 filesystem was created
The ext4, ext3, and ext2 file systems store their creation date. This date can be the first day the disk was used or the day it was last formatted.
You can find out the day the file system was created using the tune2fs and dumpe2fs utilities.
tune2fs allows the system administrator to tune various fine filesystem parameters on Linux ext2, ext3, or ext4 file systems. The current values for these parameters can be displayed using the -l option to tune2fs or dumpe2fs.
So, to see all the parameters, use commands like:
tune2fs -l /dev/PARTITION dumpe2fs /dev/PARTITION
The second command will print too much information, so tune2fs is preferred.
For example, the partition I'm interested in is called /dev/nvme0n1p2, then the commands are as follows:
tune2fs -l /dev/nvme0n1p2 dumpe2fs /dev/nvme0n1p2
The device specifier can be either a file name (for example, /dev/sda1) or a LABEL or UUID specifier: “LABEL=volume-label” or “UUID=uuid”. (i.e. LABEL=home or UUID=e40486c6-84d5-4f2f-b99c-032281799c9d).
You will see the day the file system was created in the “Filesystem created:” field.
In order not to search for a long time, you can immediately filter the required field:
tune2fs -l /dev/PARTITION | grep 'Filesystem create'
Filesystem created: Wed Aug 1 19:40:20 2018
That is, the file system was created on August 1, 2018.
How to find out which file system features are enabled
The ext4, ext3 and ext2 file systems have different tweaks, to find out which features of the filesystem are enabled use a command like:
tune2fs -l /dev/PARTITION | grep 'Filesystem features'
Filesystem features: has_journal ext_attr resize_inode dir_index filetype needs_recovery extent 64bit flex_bg sparse_super large_file huge_file dir_nlink extra_isize metadata_csum
How to find out how many times a filesystem has been mounted
To find out how many times the file system has been connected to the computer, use a command like this:
tune2fs -l /dev/PARTITION | grep 'Mount count'
Mount count: 2824
That is, the file system has been mounted 2824 times.
How to find out the date of the last mount of a filesystem
To find out when the disk was last connected to the computer, use a command like:
tune2fs -l /dev/PARTITION | grep 'Last mount time'
Last mount time: Thu Nov 26 13:48:10 2020
That is, the date of the last mount of this file system is November 26, 2020.
How to find out the date of the last write to disk
To find out when the disk was last written, use a command like:
tune2fs -l /dev/PARTITION | grep 'Last write time'
Last write time: Thu Nov 26 13:48:10 2020
How to find out how much data has been written over the entire time the disk is running
For solid-state drives and hard drives, the total written data is calculated, you can find out this value with a command of the form:
tune2fs -l /dev/PARTITION | grep 'Lifetime writes'
Lifetime writes: 9 TB
Remember that some of the discussed disk properties can be changed with the same tune2fs utility.
You can get even more information about using a hard disk or solid state drive, read about it in the article “How to find out the number of starts and the total working time of a disk in Linux”.
- How to find out the number of starts and the total working time of a disk in Linux (84.8%)
- How to find out when Linux was installed (65.3%)
- How to find out the Bluetooth version for the adapter and peripherals in Linux (53.8%)
- How to find out which process is causing high disk usage in Linux (53.1%)
- How to determine why Linux boots into Emergency mode (53.1%)
- How to split a large file (text or binary) into smaller files (SOLVED) (RANDOM - 50%)