LPI Linux Certification/Maintaining The Integrity Of Filesystems
Candidates should be able to maintain a standard filesystem, as well as the extra data associated with a journaling filesystem.
- Key knowledge area(s):
- 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:
- xfs tools (such as xfs_metadump and xfs_info)
To check filesystems consistency, use fsck.
fsck [options] -t [fstype] device [fsck-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.
- -a: Automatically repair.
- -r: Interactively repair.
fsck -t msdos /dev/fd0 -a fsck -t reiserfs /dev/hda2 -r
Checking extended filesystems
To check extended filesystems consistency, use e2fsck.
e2fsck [options] device
- -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
e2fsck -ay /dev/fd0 e2fsck -f /dev/hda2
Debugging extended filesystems
The debugfs program is an interactive file system debugger. It can be used to examine and change the state of an ext2 file system.
- Help: Give an help on all the command available.
- Stats: Give a statistics of the media.
- Stat file: Give a statistic of the file on the media.
- logdump: Dump the journal's media into a file
stat haut.gif Inode: 14 Type: regular Mode: 0644 Flags: 0x0 Generation: 67558 User: 0 Group: 0 Size: 3786 File ACL: 0 Directory ACL: 0 Links: 1 Blockcount: 8 Fragment: Address: 0 Number: 0 Size: 0 ctime: 0x3ddf3840 -- Sat Nov 23 09:11:44 2002 atime: 0x3ddf3840 -- Sat Nov 23 09:11:44 2002 mtime: 0x3ddf3840 -- Sat Nov 23 09:11:44 2002 BLOCKS: (0-3):55-58 TOTAL: 4
Dumping extended filesystems info
To print the super block and blocks group information of an extended filesystem, use dumpe2fs.
dumpe2fs [options] device
- -b: print the bad blocks of the filesystem.
- -h: Display only the superblock information.
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
To tune an extended filesystem, use tune2fs.
tune2fs [options] device
- -i#: Interval between filesystem checks [d|m|w].
- -l: List the contents of the filesystem superblock.
- -L: Set the volume label of the filesystem.
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 ...
- Build an ext2 file system, with a block size of 2048 bytes, on a floppy.
- Change the label of the floppy to BACKUP.
- Try to add a journal on the floppy media.
- Use debugfs to validate your floppy file system information, and check when it was last accessed.
- Use watch to monitor the size when you copy a big file.
- Create a shell script to list all files on the floppy bigger than 100 Kb.
- Display file system usage for all MSDOS file systems.
- Which directory MUST exist in / to qualify this OS as Linux?
- What is the file system usage of /proc?