[ Linux  ]

Linux file system 笔记

整理自 TLDP: Introduction to Linux


“On a UNIX system, everything is a file; if something is not a file, it is a process.”

Sorts of files

Table. File types in a long list (ls -l):

Symbol Meaning
- Regular file
d Directory
l Link
c Special file
s Socket
p Named pipe
b Block device

About partitioning

Why partioning?

To achieve higher data security in case of disaster.


Partition layout and types

There are two kinds of major partitions on a Linux system:

Maybe there is a /boot partition for holding the kernel files.

Mount points

All partitions are attached to the system via a mount point. (使用mount命令)。

Usually, all partitions are connected through the root partition.

During system startup, all the partitions are thus mounted, as described in the file /etc/fstab.

On a running system, information about the partitions and their mount points can be displayed using the df command. (The df command only displays information about active non-swap partitions.)

More file system layout

The Linux file system is usually thought of in a tree structure.

Table: Subdirectories of the root directory


The file system in reality

Every partition has its own file system. In a file system, a file is represented by an inode, a kind of serial number containing information about the actual data that makes up the file: to whom this file belongs, and where is it located on the hard disk.

Every partition has its own set of inodes; throughout a system with multiple partitions, files with the same inode number can exist.

When a hard disk is initialized to accept data storage, usually during the initial system installation process or when adding extra disks to an existing system, a fixed number of inodes per partition is created. (inode 枯竭问题)

inode 包含以下信息:

The only information not included in an inode, is the file name and directory. These are stored in the special directory files.