Table of Content

Weight: 2

Description: Candidates should be able to maintain a standard filesystem, as well as the extra data associated with a journaling filesystem.

Key Knowledge Areas:

  • Verify the integrity of filesystems
  • Monitor free space and inodes
  • Repair simple filesystem problems

Terms and Utilities:

du
df
fsck
e2fsck
mke2fs
debugfs
dumpe2fs
tune2fs
XFS tools (such as xfs_metadump and xfs_info)

fsck

root@dclab-u1504s:/myspace# ls /sbin/*fsck*
/sbin/dosfsck  /sbin/e2fsck  /sbin/fsck  /sbin/fsck.cramfs  /sbin/fsck.ext2  /sbin/fsck.ext3  /sbin/fsck.ext4  /sbin/fsck.ext4dev  /sbin/fsck.fat  /sbin/fsck.minix  /sbin/fsck.msdos  /sbin/fsck.nfs  /sbin/fsck.vfat

root@dclab-u1504s:/myspace# ls -l /sbin/*fsck*
lrwxrwxrwx 1 root root      8 Nov 12  2014 /sbin/dosfsck -> fsck.fat
-rwxr-xr-x 1 root root 257112 Feb 16  2015 /sbin/e2fsck
-rwxr-xr-x 1 root root  35800 Aug  4 18:25 /sbin/fsck
-rwxr-xr-x 1 root root  31408 Aug  4 18:25 /sbin/fsck.cramfs
lrwxrwxrwx 1 root root      6 Sep 20 06:26 /sbin/fsck.ext2 -> e2fsck
lrwxrwxrwx 1 root root      6 Sep 20 06:26 /sbin/fsck.ext3 -> e2fsck
lrwxrwxrwx 1 root root      6 Sep 20 06:26 /sbin/fsck.ext4 -> e2fsck
lrwxrwxrwx 1 root root      6 Sep 20 06:26 /sbin/fsck.ext4dev -> e2fsck
-rwxr-xr-x 1 root root  59472 Nov 12  2014 /sbin/fsck.fat
-rwxr-xr-x 1 root root  72616 Aug  4 18:25 /sbin/fsck.minix
lrwxrwxrwx 1 root root      8 Nov 12  2014 /sbin/fsck.msdos -> fsck.fat
-rwxr-xr-x 1 root root    333 Apr  6  2015 /sbin/fsck.nfs
lrwxrwxrwx 1 root root      8 Nov 12  2014 /sbin/fsck.vfat -> fsck.fat

hardlink check 

root@dclab-u1504s:/myspace# find /sbin -samefile /sbin/e2fsck
/sbin/e2fsck

softlink check 

root@dclab-u1504s:/myspace# find /sbin -lname "e2fsck"
/sbin/fsck.ext4
/sbin/fsck.ext2
/sbin/fsck.ext4dev
/sbin/fsck.ext3

boot and fsck

fsck on umount fs only
fsck will avoid running multiple filesystemchecks on the same physical disk.
Some journaling filesystems, such as ReiserFS and XFS, might have a pass value of 0 because the journaling code, rather than fsck, does the filesystem consistency check and repair

root@dclab-u1504s:/myspace# 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/sda1 during installation
UUID=bb1f38c8-4af9-4e33-ae34-389cd3496734 /               ext4    errors=remount-ro 0       1
# swap was on /dev/sda5 during installation
UUID=dbc82d1f-d7eb-4afc-b1de-22f31f9dfd74 none            swap    sw              0       0
/dev/fd0        /media/floppy0  auto    rw,user,noauto,exec,utf8 0       0
/dev/sdb        /myspace        ext4    defaults,usrjquota=aquota.user,grpjquota=aquota.group,jqfmt=vfsv0       1       3 

root@dclab-u1504s:/myspace# blkid /dev/sda1
/dev/sda1: UUID="bb1f38c8-4af9-4e33-ae34-389cd3496734" TYPE="ext4" PARTUUID="1d4280cc-01"
root@dclab-u1504s:/myspace# blkid /dev/sdb
/dev/sdb: UUID="579506c9-2dee-4e12-aeba-8e88c3ea6453" TYPE="ext4"

root@dclab-u1504s:/myspace# fsck.ext4 /dev/sdb
e2fsck 1.42.12 (29-Aug-2014)
/dev/sdb is mounted.
e2fsck: Cannot continue, aborting.

root@dclab-u1504s:/myspace# umount /myspace 
umount: /myspace: target is busy
        (In some cases useful info about processes that
         use the device is found by lsof(8) or fuser(1).)
root@dclab-u1504s:/myspace# cd /
root@dclab-u1504s:/# umount /myspace 
root@dclab-u1504s:/# fsck.ext4 /dev/sdb
e2fsck 1.42.12 (29-Aug-2014)
/dev/sdb: clean, 15/1310720 files, 128957/5242880 blocks

root@dclab-u1504s:/# fsck UUID="579506c9-2dee-4e12-aeba-8e88c3ea6453"
fsck from util-linux 2.25.2
e2fsck 1.42.12 (29-Aug-2014)
/dev/sdb: clean, 15/1310720 files, 128957/5242880 blocks

root@dclab-u1504s:/# e2fsck  UUID="579506c9-2dee-4e12-aeba-8e88c3ea6453"
e2fsck 1.42.12 (29-Aug-2014)
/dev/sdb: clean, 15/1310720 files, 128957/5242880 blocks

XFS

[root@dclab-centos7 ~]# fdisk -l /dev/sda

Disk /dev/sda: 107.4 GB, 107374182400 bytes, 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000ade64

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048   209715199   104344576   8e  Linux LVM
[root@dclab-centos7 ~]# blkid /dev/sda1
/dev/sda1: UUID="7ae21490-a730-4421-9369-d291bb59d6b5" TYPE="xfs" 
[root@dclab-centos7 ~]# blkid /dev/sda2
/dev/sda2: UUID="buU0me-u0F6-05Lh-xeM8-yOgG-FCfH-xerE9t" TYPE="LVM2_member" 

Quiz questions

1. In which two ways can a Linux file system become full?
2. Where are lost files stored when they are recovered during a filesystem check?
3. How does du differ from df?
4. What is debugfs, and for which filesystems is it available?
5. Why are deleted files often found during a filesystem check?
Answers to quiz questions
1. Run out of space, and run out of available inodes.
2. lost+found in the root directory of the filesystem.
3. du reads the disk like ls, while df display summary information only.
4. debugfs shows filesystem information. It's available for ext2/3. Tools do exist for other filesystems, but do not have the name.
5. Linux allows open files to be deleted. The files stay on the disk, but their directory entries are removed.