Tuning and troubleshooting file systems


In this article I’ll show you how to troubleshoot and find useful information about your server’s file system. There are a lot of useful commands available on Linux distributions and some may have enhanced capabilities than the ones presented in this article. Also note that I’m not able to cover each command’s parameters and features so I’ll just make an overview image of the available utilities on Linux distributions. For this example I’ll be using a CentOS machine.

Getting information about the file system:

lsblk command can be used to display block devices, it offers a tree like structure that can be easily interpreted. With this command you can find all sort of useful information such as disk/partitions/sizes/device type and so on:

lsblk

List block devices in Linux

Another useful command is the blkid which can be used to view the UUID and the file system type of system block devices:

blockdevices

list Linux block devices ID

To find out detailed information regarding a specific partition use the dumpe2fs command. It can be used with the -h parameter to display a human friendly output:

dumpe2fs -h /dev/sda1

dumpe2fs

Get partition information on Linux machines

With tune2fs command you can change all parameters that are displayed by dumpe2fs. There are a lot of parameters supported with this tool and I’ll let you explore the man page for this command (man tune2fs ). Note that it’s not very common that you have to change file system parameters because default values work in most scenarios. I recommend playing with these parameters if you know what you’re doing or in a testing environment.

Another useful tool to troubleshoot file systems  performance is debugfs. Note that it’s best that you not use this tool on a mounted file system:

[root@localhost /boot/grub]# debugfs /dev/sda2
debugfs 1.41.12 (17-May-2010)
debugfs:

Type help to view available commands within the debugfs utility. You can achieve similar output as dumpe2fs by typing status or show_super_status. Note that debugfs can be used to change state of different file systems such as ext2, 3 ,4.

Checking inodes information:

Inodes information can be seen by using df command with the -ih parameters:

indoes

Get inode information on Linux

 

Debugfs command supports multiple options with which you can check and modify inode information. With lsdel you can list deleted inodes that you can later restore if needed:

lsdel

Check deleted inodes in Linux

Then you can execute undelete inode_number file to undelete an inode. This will actually restore the file if it’s respective inode is found.

You can dump all deleted inodes to a file much faster by using the following command:

echo lsdel | debugfs /dev/sda1 > deletedindoes

With the logdump -i inode_number command you can view a specific inode information. This option will dump the content of the file system journal.

dump_inode, or cat options can be used with debugfs to dump an inode to a file or to the standard output.

Note that commands presented above work only with ext2 ,ext3 and ext4 file systems. If you are using other file systems such as xfs, you have to use their dedicated tools to perform troubleshooting operations.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s