Data Recovery from Linux filesystem corruption

For a FREE DIAGNOSIS call our data recovery centre now on 0870 7424 008


The structure of the Linux file system

The Linux file system treats everything as a file. This includes images, text files, programs, directories, partitions and hardware device drivers.

Each filesystem contains a control block, which holds information about that filesystem. The other blocks in the filesystem are inodes, which contain information about individual files, and data blocks, which contain the information stored in the individual files.

There is a substantial difference between the way the user sees the Linux filesystem (first sense) and the way the kernel (the core of a Linux system) actually stores the files. To the user, the filesystem appears as a hierarchical arrangement of directories that contain files and other directories (i.e., subdirectories). Directories and files are identified by their names. This hierarchy starts from a single directory called root, which is represented by a "/" (forward slash).

(The meaning of root and "/" are often confusing to new users of Linux. This because each has two distinct usages. The other meaning of root is a user who has administrative privileges on the computer, in contrast to ordinary users, who have only limited privileges in order to protect system security. The other use of "/" is as a separator between directories or between a directory and a file, similar to the backward slash used in MS-DOS.)

The Filesystem Hierarchy Standard (FHS) defines the main directories and their contents in Linux and other Unix-like operating systems. All files and directories appear under the root directory, even if they are stored on different physical devices (e.g., on different disks or on different computers). A few of the directories defined by the FHS are /bin (command binaries for all users), /boot (boot loader files such as the kernel), /home (users home directories), /mnt (for mounting a CDROM or floppy disk), /root (home directory for the root user), /sbin (executables used only by the root user) and /usr (where most application programs get installed).

To the Linux kernel, however, the filesystem is flat. That is, it does not:

  • have a hierarchical structure
  • differentiate between directories, files or programs
  • identify files by names. Instead, the kernel uses inodes to represent each file.

An inode is actually an entry in a list of inodes referred to as the inode list. Each inode contains information about a file including

  • its inode number (a unique identification number)
  • the owner and group associated with the file
  • the file type (for example, whether it is a regular file or a directory)
  • the file's permission list
  • the file creation, access and modification times
  • the size of the file
  • the disk address (i.e., the location on the disk where the file is physically stored).

The inode numbers for the contents of a directory can be seen by using the -i option with the familiar ls (i.e., list) command in a terminal window:

ls -i


The df command is used to show information about each of the filesystems which are currently mounted on (i.e., connected to) a system, including their allocated maximum size, the amount of disk space they are using, the percentage of their disk space they are using and where they are mounted (i.e., the mountpoint). (Here filesystems is used as a variant of the first meaning, referring to the parts of the entire hierarchy of directories.)

df can be used by itself, but it is often more convenient to add the -m option to show sizes in megabytes rather than in the default kilobytes:

df -m

A column showing the type of each of these filesystems can be added to the filesystem table produced by the above command by using the --print-type option, i.e.:

df -m --print-type

This command generates a column labeled Type. For a Red Hat Linux installation on a home computer most of the entries in this column will probably be ext3 and/or ext2.

> Overview: Linux native file system

> Overview: Linux journaling file system

> Overview: Linux support for non Linux file systems


> Back to the main LINUX data recovery page

> Back to the MAIN data recovery page