9
Junior Level Linux Certification

101 4.2 maintain the integrity of filesystems

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: 101 4.2 maintain the integrity of filesystems

Junior Level Linux Certification

Page 2: 101 4.2 maintain the integrity of filesystems

Exam Objectives

Key Knowledge Areas

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

Objective 4: Devices, Linux Filesystems, Filesystem Hierarchy Standard

Maintain the integrity of filesystems Weight: 2

Terms and Utilities

du df fsck e2fsck mke2fs debugfs dumpe2fs tune2fs xfs tools

2

Page 3: 101 4.2 maintain the integrity of filesystems

Integrity of Filesystems

3

The main tool for checking filesystems is fsck

like mkfs, its a front end to filesystem-checking routines for various filesystem types.

Ex: $ ls /sbin/*fsck*

/sbin/btrfsck /sbin/fsck /sbin/fsck.ext3 /sbin/fsck.msdos/sbin/dosfsck /sbin/fsck.cramfs /sbin/fsck.ext4 /sbin/fsck.vfat/sbin/e2fsck /sbin/fsck.ext2 /sbin/fsck.ext4dev /sbin/fsck.xfs

Maintain the integrity of filesystems

Page 4: 101 4.2 maintain the integrity of filesystems

Integrity of Filesystems

4

Using fsck to check filesystems

Ex: [root@comp~]# # find the device for LABEL=EXT3TEST[root@comp~]# blkid -L EXT3TEST/dev/sda7[root@comp ~]# # Find label and UUID for /dev/sda7[root@comp ~]# blkid /dev/sda7/dev/sda7: LABEL="EXT3TEST" UUID="7803f979-ffde-4e7f-891c-b633eff981f0" SEC_TYPE="ext2"TYPE="ext3"[root@comp ~]# # Check /dev/sda7[root@comp ~]# fsck /dev/sda7fsck from util-linux-ng 2.16.2e2fsck 1.41.9 (22-Aug-2009)EXT3TEST: clean, 11/7159808 files, 497418/28637862 blocks[root@comp ~]# # Check it by label using fsck.ext3[root@comp ~]# fsck.ext3 LABEL=EXT3TESTe2fsck 1.41.9 (22-Aug-2009)EXT3TEST: clean, 11/7159808 files, 497418/28637862 blocks[root@comp ~]# # Check it by UUID using e2fsck[root@comp ~]# e2fsck UUID=7803f979-ffde-4e7f-891c-b633eff981f0e2fsck 1.41.9 (22-Aug-2009)EXT3TEST: clean, 11/7159808 files, 497418/28637862 blocks[root@comp~]# # Finally check the vfat partition[root@comp ~]# fsck LABEL=DOSfsck from util-linux-ng 2.16.2dosfsck 3.0.9, 31 Jan 2010, FAT32, LFN/dev/sda9: 1 files, 1/513064 clusters

Maintain the integrity of filesystems

Page 5: 101 4.2 maintain the integrity of filesystems

Integrity of Filesystems

5

Error on attempt to check a mounted filesystem

Ex: [root@comp ~]# fsck UUID=a18492c0-7ee2-4339-9010-3a15ec0079bb

fsck from util-linux-ng 2.16.2e2fsck 1.41.9 (22-Aug-2009)/dev/sdb9 is mounted.

WARNING!!! Running e2fsck on a mounted filesystem may causeSEVERE filesystem damage.

Do you really want to continue (y/n)? No

check aborted.

Maintain the integrity of filesystems

Page 6: 101 4.2 maintain the integrity of filesystems

Integrity of Filesystems

6

Monitoring free space

df cmd infos the whole filesystem. with option –T infos the mounted filesystems.

Ex: [root@comp ~]# df -T

Filesystem Type 1K-blocks Used Available Use% Mounted on

/dev/sdb9 ext3 45358500 24670140 18384240 58% /tmpfs tmpfs 1927044 808 1926236 1% /dev/shm/dev/sda2 ext3 772976 17760 716260 3% /grubfile/dev/sda8 xfs 41933232 4272 41928960 1% /mnt/xfstest/dev/sda7 ext3 112754024 192248 106834204

1% /mnt/ext3test/dev/sda9 vfat 2052256 4 2052252 1% /dos

Maintain the integrity of filesystems

with option – i Contains info on blocks contained in an inode

inode number is the file serial number - unique in the filesystem.Inode info: owner, when file was last accessed, size, if it’s a directory, who can read/write to it.

ReiserFS and FAT32 dont have inodes (metadata files and directories are kept elsewhere)

Page 7: 101 4.2 maintain the integrity of filesystems

Integrity of Filesystems

7

Maintain the integrity of filesystems

tune2fs cmd used to info block count; if fs is journaled; convert ext2 to ext3

Ex: [root@comp ~]# tune2fs -l /dev/sda2

du cmd gives info about the filename (or filenames) given as parameters.

Ex: [root@comp ~]# du -hc *

[root@comp ~]# du -shc /usr/*

Page 8: 101 4.2 maintain the integrity of filesystems

Integrity of Filesystems

8

Maintain the integrity of filesystems

debugfs allows to explore inner workings of an ext filesystem.allows to attempt undeletion of files or directories

Ex: [root@comp ~]# debugfs /dev/sdb9

Page 9: 101 4.2 maintain the integrity of filesystems

Fim de sessão

9