How to verify fstab file

Verify static filesystem information defined in the fstab file after applying modifications to ensure that system will boot without any problems. It is especially important in remote locations or places where you cannot easily perform emergency operations.

Display static filesystem information defined in fstab file.

$ cat /etc/fstab 
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
#                
# / was on /dev/vda1 during installation
UUID=9d749b55-a024-4d89-b1c0-950bd38b98d8 /               ext4    errors=remount-ro 0       1
# swap was on /dev/vda5 during installation
UUID=33d7420a-1ab7-4872-8944-369c37354d1b none            swap    sw              0       0
/dev/sr0        /media/cdrom0   udf,iso9660 user,noauto     0       0

Verify /etc/fstab file contents.

$ sudo findmnt --verify
/media/cdrom0
   [W] udf,iso9660 seems unsupported by the current kernel
   [W] cannot detect on-disk filesystem type

0 parse errors, 0 errors, 2 warnings

Verify /etc/fstab file contents and display verbose output.

$ sudo findmnt --verify --verbose
/
   [ ] target exists
   [ ] FS options: errors=remount-ro
   [ ] UUID=9d749b55-a024-4d89-b1c0-950bd38b98d8 translated to /dev/vda1
   [ ] source /dev/vda1 exists
   [ ] FS type is ext4
none
   [ ] UUID=33d7420a-1ab7-4872-8944-369c37354d1b translated to /dev/vda5
   [ ] source /dev/vda5 exists
   [ ] FS type is swap
/media/cdrom0
   [ ] target exists
   [ ] userspace options: user,noauto
   [ ] source /dev/sr0 exists
   [W] udf,iso9660 seems unsupported by the current kernel
   [W] cannot detect on-disk filesystem type

0 parse errors, 0 errors, 2 warnings

Verify static ext4 filesystem type information defined in particular file (mounted file systems table).

$ sudo findmnt --verify --tab-file /etc/mtab --type ext4
/                                          
   [W] recommended root FS passno is 1 (current is 0)                                  

0 parse errors, 0 errors, 1 warning        

Sample static filesystem information file that deliberately contains multiple errors.

$ cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
#                
# / was on /dev/vda1 during installation
UUID=9d749b55-a024-4d89-b1c0-950bd38b98d8 /               ext3    errors=remount-ro
UUID=9d749b55-a024-4d89-b1c0-950bd38b98d8 /opt             xt4    errors=remount-ro 0       
# swap was on /dev/vda5 during installation
UUID=33d7420a-1ab7-4872-8944-369c37354d1b none            swap    sw              0       0
/dev/sr0        /media/cdrom0   udf,iso9660 user,noauto     0    

Verify this inconsistent and erroneous file contents.

$ sudo findmnt --verify
/
   [E] ext3 does not match with on-disk ext4
   [W] recommended root FS passno is 1 (current is 0)
/opt
   [W] xt4 seems unsupported by the current kernel
   [E] xt4 does not match with on-disk ext4
/media/cdrom0
   [W] udf,iso9660 seems unsupported by the current kernel
   [W] cannot detect on-disk filesystem type

0 parse errors, 2 errors, 4 warnings

Exit code will indicate that there was an error.

$ echo $?
1

Display verbose output to investigate it further.

$ sudo findmnt --verify --tab-file /etc/fstab --verbose
/
   [ ] target exists
   [ ] FS options: errors=remount-ro
   [ ] UUID=9d749b55-a024-4d89-b1c0-950bd38b98d8 translated to /dev/vda1
   [ ] source /dev/vda1 exists
   [E] ext3 does not match with on-disk ext4
   [W] recommended root FS passno is 1 (current is 0)
/opt
   [ ] target exists
   [ ] FS options: errors=remount-ro
   [ ] UUID=9d749b55-a024-4d89-b1c0-950bd38b98d8 translated to /dev/vda1
   [ ] source /dev/vda1 exists
   [W] xt4 seems unsupported by the current kernel
   [E] xt4 does not match with on-disk ext4
none
   [ ] UUID=33d7420a-1ab7-4872-8944-369c37354d1b translated to /dev/vda5
   [ ] source /dev/vda5 exists
   [ ] FS type is swap
/media/cdrom0
   [ ] target exists
   [ ] userspace options: user,noauto
   [ ] source /dev/sr0 exists
   [W] udf,iso9660 seems unsupported by the current kernel
   [W] cannot detect on-disk filesystem type

0 parse errors, 2 errors, 4 warnings
Milosz Galazka's Picture

About Milosz Galazka

Milosz is a Linux Foundation Certified Engineer working for a successful Polish company as a system administrator and a long time supporter of Free Software Foundation and Debian operating system.