Overview of linux partitions file systems directory structures

  • 2020-05-15 03:23:34
  • OfStack

1. How to represent hard disk and partition in Linux


When the Linux kernel reads the optical drive, hard disk and other resources, it does so in the form of "device files". Therefore, in the linux system, the hard disk and partition are represented as different files. The specific expressions are as follows:

Hard disk: for IDE interface of hard disk device, expressed as "hdX forms of file name:" for the SCSI interface of hard disk device, is expressed as "sdX" in the form of a file name, including "X" for a, b, c, d letters such as serial number. For example, the first IDE device (hard disk) in the system is represented as "hda" and the second SCSI device (hard disk) is represented as "sdb".

Partition: represents the partition, based on the file name of the hard disk device, after which the corresponding numeric serial number interface of the partition (no matter the primary partition, the extended partition, the logical partition) is added. For example, the first partition in the first IDE hard disk is represented as: "hda1", the second partition is represented as "hda2", the third primary partition in the second SCSI hard disk is represented as "sdb3", and the fifth partition is represented as "sdb5".

It is important to note that since there are only four primary partitions in the hard disk, the primary and extended partition Numbers are limited to 1 to 4, while the logical partition Numbers will always start at 5. For example, even if the first IDE hard drive has one primary partition and one extended partition, the serial number of the newly created logical partition should start at 5 and be represented as "hda5", and the second logical partition should be represented as "hda6".


2. File system types used in Linux

The file system (File System) type determines how and how efficiently to store and read file data into a partition, and the file system type needs to be selected when formatting the partition. In the windows operating system, the common file system types include FAT32, NTFS and so on. On the linux system, the most commonly used file systems include the following two formats.

EXT3: the 3rd generation extended file system, which is the default file system type used in most linux systems, is a typical journaling file system. Its characteristic is to maintain a disk access record of log data, easy to recover, performance and stability more excellent. The previous EXT2 file system is being phased out.

SWAP: exchange file system, mainly used for Linux system to establish swap partition. Swap partitions act as virtual memory, relieving physical memory problems to a certain extent. It is recommended to set the swap partition size to 1.5~2 times of physical memory. If the physical memory of the server is large enough (such as 8G or above), virtual memory can not be set. Swap partitions are not used to store data such as user box directories directly.


3. Directory structure in Linux

In linux system, all directories and file data are organized into a "tree" directory structure. All partitions, directories, files, etc. have the same starting point -- "root directory". The Linux system can only have 1 and directory, unlike the windows system, which has 1 and directory per partition, this point needs to be distinguished.

boot: store the files necessary to start Linux system, including kernel files, startup menu configuration files, etc. For culinary system security reasons, the "/boot" directory is usually divided into separate partitions called "/boot" partitions.

bin: stores the most basic user commands in the linux system, and ordinary users have the authority to execute them

dev: storage of linux system hard disk, keyboard, mouse, optical drive and other equipment files

etc: to store the configuration files of the linux system and various programs. The configuration files are called "/etc"

home: holds the default working directory (also known as the host directory) for all normal system users. For example, the host directory corresponding to the user account "teacher" is located at "/home/teacher/". If the server needs to provide a large number of ordinary users, it is recommended to divide the "/home" directory into separate partitions to facilitate the backup of user data

root: this directory is the host directory for linux system administrator (superuser) root. By default only the host directory for root users is under the root directory instead of under "/home".

sbin: stores the most basic administrative commands in the linux system, and only general administrator users have the authority to execute them.

usr: stores other user applications, often divided into subdirectories for different types of applications.

var: the "/var" directory is usually divided into separate partitions.

tmp: stores temporary files used during system operation.


Related articles: