Jump to content

LPI Linux Certification/Maintaining The Integrity Of Filesystems

From Wikibooks, open books for an open world

Detailed Objectives

[edit | edit source]

(LPIC-1 Version 5.0)

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.

The following is a partial list of the used files, terms and utilities:

  • du
  • df
  • fsck
  • e2fsck
  • mke2fs
  • tune2fs
  • xfs_repair
  • xfs_fsr
  • xfs_db

Checking filesystems

[edit | edit source]

To check filesystems consistency, use fsck.

fsck [options] -t [fstype] device [fsck-options]

Common options:

-A: Go through the /etc/fstab file and try to check all file systems. Typically used at boot time from a script.
-t fslist: Specify the type of file system to be checked. With -A, only filesystems that match fslist are checked
-C: Display completion/progression bar.

Common fsck-options:

-a: Automatically repair.
-r: Interactively repair.

Examples:

fsck -t msdos /dev/fd0 -a
fsck -t reiserfs /dev/hda2 -r

Checking extended filesystems

[edit | edit source]

To check extended filesystems consistency, use e2fsck.

e2fsck [options] device

Common options:

-b: Use an alternate super block filename.
-c: This option makes badblocks program to run and marks all the bad blocks.
-f: Force checking even if the filesystem seems clean.
-a or -p: Automatically repair.
-y: non-interactive mode

Examples:

e2fsck -ay /dev/fd0
e2fsck -f /dev/hda2

/usr/lib/debug /usr/lib/debug/.build-id /usr/lib/debug/.build-id/00 /usr/lib/debug/.build-id/00/f25a7575b32d815a0d44afef1e9728b2b73e26 /usr/lib/debug/.build-id/00/f25a7575b32d815a0d44afef1e9728b2b73e26.debug /usr/lib/debug/.build-id/10/3d2c09a9bdc29888885c48109933c75e44663a /usr/lib/debug/.build-id/10/3d2c09a9bdc29888885c48109933c75e44663a.debug /usr/lib/debug/.build-id/13 /usr/lib/debug/.build-id/13/3abe344cde4ffef5a53479fac7c81bafb6e21a /usr/lib/debug/.build-id/13/3abe344cde4ffef5a53479fac7c81bafb6e21a.debug /usr/lib/debug/.build-id/43 /usr/lib/debug/.build-id/43/bcc311b1d6a6f32daf50dd63bf2180ab82dc90 /usr/lib/debug/.build-id/43/bcc311b1d6a6f32daf50dd63bf2180ab82dc90.debug /usr/lib/debug/.build-id/50 /usr/lib/debug/.build-id/50/bff171879889b755b937f511b1b235498fba8d /usr/lib/debug/.build-id/50/bff171879889b755b937f511b1b235498fba8d.debug /usr/lib/debug/.build-id/6d /usr/lib/debug/.build-id/6d/6243efea770beba54aefb8db5d85ddd36ae8c3 /usr/lib/debug/.build-id/6d/6243efea770beba54aefb8db5d85ddd36ae8c3.debug /usr/lib/debug/.build-id/76 /usr/lib/debug/.build-id/76/d35de43753c7ff333dd51f91ecbf5c7986e4fa /usr/lib/debug/.build-id/76/d35de43753c7ff333dd51f91ecbf5c7986e4fa.debug /usr/lib/debug/.build-id/a9 /usr/lib/debug/.build-id/a9/7f35946075b329d7464b2c1c3350080819c618 /usr/lib/debug/.build-id/a9/7f35946075b329d7464b2c1c3350080819c618.debug /usr/lib/debug/.build-id/b8 /usr/lib/debug/.build-id/b8/76d35e830768b5a5486a7ead2d18ed788324a5 /usr/lib/debug/.build-id/b8/76d35e830768b5a5486a7ead2d18ed788324a5.debug /usr/lib/debug/.build-id/d7/24af1b54d9d90564088140b56afeeb98f3d301 /usr/lib/debug/.build-id/d7/24af1b54d9d90564088140b56afeeb98f3d301.debug /usr/lib/debug/usr /usr/lib/debug/usr/lib64 /usr/lib/debug/usr/lib64/libwx_gtk2u_adv-3.0.so.0.5.0-3.0.5.1-1.el8.x86_64.debug /usr/lib/debug/usr/lib64/libwx_gtk2u_aui-3.0.so.0.5.0-3.0.5.1-1.el8.x86_64.debug /usr/lib/debug/usr/lib64/libwx_gtk2u_core-3.0.so.0.5.0-3.0.5.1-1.el8.x86_64.debug /usr/lib/debug/usr/lib64/libwx_gtk2u_html-3.0.so.0.5.0-3.0.5.1-1.el8.x86_64.debug /usr/lib/debug/usr/lib64/libwx_gtk2u_propgrid-3.0.so.0.5.0-3.0.5.1-1.el8.x86_64.debug /usr/lib/debug/usr/lib64/libwx_gtk2u_qa-3.0.so.0.5.0-3.0.5.1-1.el8.x86_64.debug /usr/lib/debug/usr/lib64/libwx_gtk2u_ribbon-3.0.so.0.5.0-3.0.5.1-1.el8.x86_64.debug /usr/lib/debug/usr/lib64/libwx_gtk2u_richtext-3.0.so.0.5.0-3.0.5.1-1.el8.x86_64.debug /usr/lib/debug/usr/lib64/libwx_gtk2u_stc-3.0.so.0.5.0-3.0.5.1-1.el8.x86_64.debug /usr/lib/debug/usr/lib64/libwx_gtk2u_xrc-3.0.so.0.5.0-3.0.5.1-1.el8.x86_64.debug /usr/lib/debug /usr/lib/debug/.build-id /usr/lib/debug/.build-id/ea /usr/lib/debug/.build-id/ea/b65cabc1e1cd7e1801e2a874178eb1b46252e8 /usr/lib/debug/.build-id/ea/b65cabc1e1cd7e1801e2a874178eb1b46252e8.debug /usr/lib/debug/usr /usr/lib/debug/usr/lib64 /usr/lib/debug/usr/lib64/libwx_gtk2u_gl-3.0.so.0.5.0-3.0.5.1-1.el8.x86_64.debug /usr/lib/debug /usr/lib/debug/.build-id /usr/lib/debug/.build-id/0a /usr/lib/debug/.build-id/0a/9cfbf6fa20e173be209d005846d4d83d2eccc8 /usr/lib/debug/.build-id/0a/9cfbf6fa20e173be209d005846d4d83d2eccc8.debug /usr/lib/debug/usr /usr/lib/debug/usr/lib64 /usr/lib/debug/usr/lib64/libwx_gtk2u_media-3.0.so.0.5.0-3.0.5.1-1.el8.x86_64.debug /usr/lib/debug /usr/lib/debug/.build-id /usr/lib/debug/.build-id/34 /usr/lib/debug/.build-id/34/9d6bc71cf4f405919844e52630e2a38865b55e /usr/lib/debug/.build-id/34/9d6bc71cf4f405919844e52630e2a38865b55e.debug /usr/lib/debug/usr /usr/lib/debug/usr/lib64 /usr/lib/debug/usr/lib64/erlang /usr/lib/debug/usr/lib64/erlang/lib /usr/lib/debug/usr/lib64/erlang/lib/asn1-5.0.12 /usr/lib/debug/usr/lib64/erlang/lib/asn1-5.0.12/priv /usr/lib/debug/usr/lib64/erlang/lib/asn1-5.0.12/priv/lib /usr/lib/debug/usr/lib64/erlang/lib/asn1-5.0.12/priv/lib/asn1rt_nif.so-22.3.4.1-1.el8.x86_64.debug /usr/lib/debug /usr/lib/debug/.build-id /usr/lib/debug/.build-id/57 /usr/lib/debug/.build-id/57/831dc482ea0c229def270864a66b785b79121d /usr/lib/debug/.build-id/57/831dc482ea0c229def270864a66b785b79121d.debug /usr/lib/debug/usr /usr/lib/debug/usr/lib64 /usr/lib/debug/usr/lib64/erlang /usr/lib/debug/usr/lib64/erlang/erts-10.7.2.1 /usr/lib/debug/usr/lib64/erlang/erts-1

Dumping extended filesystems info

[edit | edit source]

To print the super block and blocks group information of an extended filesystem, use dumpe2fs.

dumpe2fs [options] device

Common options:

-b: print the bad blocks of the filesystem.
-h: Display only the superblock information.

Example:

dumpe2fs -h /dev/fd0
dumpe2fs 1.26 (3-Feb-2002)
Filesystem volume name:   floppy
Last mounted on:          <not available>
Filesystem state:         clean
Errors behavior:          Continue
Filesystem OS type:       Linux
Inode count:              184
Block count:              1440
Reserved block count:     72
Free blocks:              1258
Free inodes:              168
First block:              1
Block size:               1024
First inode:              11
Inode size:               128
...

Tuning extended filesystems

[edit | edit source]

To tune an extended filesystem, use tune2fs.

tune2fs [options] device 

Common options:

-i#: Interval between filesystem checks [d|m|w].
-l: List the contents of the filesystem superblock.
-L: Set the volume label of the filesystem.

Examples:

tune2fs -L floppy /dev/fd0
tune2fs -l /dev/fd0
(Same output as dumpe2fs -h /dev/fd0)
tune2fs 1.26 (3-Feb-2002)
Filesystem volume name:   floppy
Block count:              1440
Reserved block count:     72
Free blocks:              1258
Free inodes:              168
First block:              1
Block size:               1024
First inode:              11
Inode size:               128
...

Exercises

[edit | edit source]
  1. Build an ext2 file system, with a block size of 2048 bytes, on a floppy.
  2. Change the label of the floppy to BACKUP.
  3. Try to add a journal on the floppy media.
  4. Use debugfs to validate your floppy file system information, and check when it was last accessed.
  5. Use watch to monitor the size when you copy a big file.
  6. Create a shell script to list all files on the floppy bigger than 100 Kb.
  7. Display file system usage for all MSDOS file systems.
  8. Which directory MUST exist in / to qualify this OS as Linux?
  9. What is the file system usage of /proc?