Loading...
X

How to know when the ext4/ext3/ext2 filesystem was created and when it was last mounted

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'

Output example:

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'

Output example:

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'

Output example:

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'

Output example:

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'

Output example:

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'

Output example:

Lifetime writes:          9 TB

Conclusion

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”.


Leave Your Observation

Your email address will not be published. Required fields are marked *