Книга: Fedora™ Unleashed, 2008 edition

Physical Structure of the File System on the Disk

Physical Structure of the File System on the Disk

If you were to visualize the file system on the physical disk, it would resemble a series of boxes known as blocks. The first block on the disk is a special block that contains the boot sector; subsequent blocks contain the operating system, applications, and your data.

Each individual block is made up of smaller groups of data:

? A superblock (called by that name because it contains redundant information about the overall file system).

? Redundant file system descriptors — All the redundant information is useful for reliability and recovery from disasters and errors.

? A bitmap of the block.

? A bitmap of the inode table.

? Information from the inode table.

? The data blocks themselves.

Inodes and File Attributes

The information that constitutes a file in the ext2/ext3 file system begins with the inode. The inode contains the following description of the file: the file type, its access rights, its owners, several different time stamps, the file size, and pointers to data blocks that hold the file information. When you want to access a file, the kernel uses those pointers to calculate where the data resides physically on the disk.

File attributes are also stored in the inode. The chattr command enables the root operator to manipulate some special attributes of files on an ext2/3 file system. One of the most interesting uses of the chattr command is to make a file immutable, meaning that it cannot be deleted, renamed, written to, or modified by anyone, even root (at least until the immutable attribute is unset). To make a file immutable (the word means unalterable; not capable of change):

# chattr +i filename

and to change it back:

# chattr -i filename

Another interesting flag is the s flag, which tells the system to zero out all the blocks used for that file when the file is deleted. To observe the existing attributes of a file, use:

# lsattr filename

The chattr utility is part of the e2fsprogs package.

A file's attributes include its access permissions. The traditional Unix system of permissions is controlled with chmod. Posix Access Control Lists extend this functionality.

ACL supports permissions for users and groups beyond the traditional owner/group/world scheme. They enable finer-grained control of permissions for files.

To learn more about Access Control Lists, visit the Posix ACLs for Linux website: http://acl.bestbits.at/.

How big are these blocks? The default size is 1,024 bytes, but the size can be made smaller or larger when the file system is first created. The optimum size is determined by the application of the particular machine. If you typically use very large files, a larger block size can speed up disk I/O operations at the expense of slower I/O for smaller files; the reverse is also true. For an individual system, block size might require monitoring over time and benchmarking before an optimal value is determined. For most users, the defaults have been found satisfactory.

Оглавление книги


Генерация: 1.212. Запросов К БД/Cache: 3 / 1
поделиться
Вверх Вниз