Monday, December 12, 2016

What is a file system?




What is a file system?

Any computer file is stored on some kind of a storage with a given capacity. Actually, each storage is a linear space for reading or both reading and writing digital information. Each byte of information on the storage has its own offset from the storage start (address) and is referenced by this address. A storage can be presented as a grid with a set of numbered cells(each cell is a single byte). Any file saved to the storage gets a number of these cells.
Generally, computer storages use a pair of sector and in-sector offset to reference any byte of information on the storage. The sector is a group of bytes (usually 512 bytes) that is a minimum addressable unit of the physical storage. For example, byte 1040 on a hard disk will be referenced as a sector #3 and offset in sector 16 bytes ([sector]+[sector]+[16 bytes]). This scheme is applied to optimize storage addressing and use a smaller number to reference any portion of information on the storage.
To omit the second part of the address (in-sector offset), files storing begins in the sector start and occupy the whole sectors (e.g.: 10-byte file occupies the whole sector, 512-byte file also occupies the whole sector, at the same time, 514 byte file occupies two whole sectors).

Each file is stored on 'unused' sectors and can be read then by a known position and size. However, how do we know what sectors are used or unused? Where are file size and position stored? Where is a file name? These answers are given by a file system.

As a whole, file system is structured data representation and a set of metadata describing the stored data. A file system not only serves for the purposes of the whole storage but is also a part of an isolated storage segment – disk partition. Usually, the file system operates blocks, not sectors. File system blocks are groups of sectors which optimize storage addressing. Modern file systems generally use block sizes from 1 to 128 sectors (512-65536 bytes). Files are usually stored from the start of a block and take entire blocks.


Immense write/delete operations to file system cause file system fragmentation. As a result files aren't stored as whole fragments and are divided into fragments. For example, a storage is entirely taken by files with size about 4 blocks (e.g. a collection of pictures). User wants to store a file that will take 8 blocks and therefore deletes the first and the last files. By doing this it clears the space on 8 blocks, however, the first segment is near to the storage start, and the second – to the storage end. In this case 8-block file is split into two parts (4 blocks for each part) and takes free space 'holes'. The information about both fragments as parts of a single file is stored to file system.

In addition to user’s files, the file system also contains its own parameters (such as block size), file descriptors (including file size, file location, its fragments etc.), file names and directory hierarchy. It may also store security information, extended attributes and other parameters.

To comply with diverse requirements as storage performance, stability and reliability plenty of file systems are developed to serve certain user purposes.

1 comment: