File System Checks

Modified on Thu, 29 Jun, 2023 at 12:51 PM

The best recovery option is to always keep a recent snapshot of your instance and/or data backups that you can revert to when there is problem with accessing an instance. 

By default, the Nectar images do not regularly run a file system check. This article covers turning on the regular check of the root partition on boot of the instance, and turning off the regular check.

Checking the current settings with tune2fs

The device storing the file system mounted at root "/" can be identified with lsblk. In this example, the device is vda1.

ubuntu@myinstance:~$ lsblk 
NAME   MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda    252:0    0  30G  0 disk 
└─vda1 252:1    0  30G  0 part /

The default Nectar images use ext4 file system. We can see more information about this file system with tune2fs, including when it was last checked.

ubuntu@myinstance:~$ sudo tune2fs -l /dev/vda1
...(snipped)...
Last mounted on:          /
Last mount time:          Wed Jun 28 07:22:53 2023
Last write time:          Wed Jun 28 07:22:52 2023
Mount count:              15
Maximum mount count:      -1
Last checked:             Mon Feb  6 23:50:49 2023

We can see in this example the file system has been mounted 15 times without being checked. We can see "Maximum mount count" is set to -1, which means it is not regularly checked.

Turning on regular checking of the file system

Usually we can unmount file systems and check them, but the root file system is a bit harder to do this with. We can make the file system checked every boot by setting the maximum mount count to 1. We work on /dev/vda1 in this example because it was identified in the previous section as the root filesystem.

ubuntu@myinstance:~$ sudo tune2fs -c 1 /dev/vda1
tune2fs 1.44.1 (24-Mar-2018)
Setting maximal mount count to 1

After the instance has been rebooted, we can see it has been checked ("Last checked" has been updated).

ubuntu@u1804:~$ sudo tune2fs -l /dev/vda1
...(snipped)...
Last mounted on:          /
Last mount time:          Thu Jun 29 02:29:26 2023
Last write time:          Thu Jun 29 02:29:25 2023
Mount count:              1
Maximum mount count:      1
Last checked:             Thu Jun 29 02:29:25 2023

Turning off regular checking of the file system

The maximal mount count can be set to -1 to turn off regular checking of the file system. We work on /dev/vda1 in this example because it was identified in the previous section as the root file system.

ubuntu@myinstance:~$ sudo tune2fs -c -1 /dev/vda1
tune2fs 1.44.1 (24-Mar-2018)
Setting maximal mount count to -1

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article