Document (file) 1 ———— An introduction to Linux filesystems

Source: Internet
Author: User
Tags volatile

This is mainly about files, directories, and some disk-related knowledge. The main basis is the 4th chapter of the operating system document management (reference: kingly book) and bird's private cuisine of the No. 567 chapter.

When the system is running, the computer schedules and assigns the resources to the basic units of the process, while in the input and output of the user, the file is the base unit.


1. What is a file?

From the point of view of metaphor, the operating system is the librarian for the management of books, then the document is the library book.

From the bottom-up point of view, a data item: A property value that describes an object, such as name, date, or ID number (note that one of the three examples is a data item)

---> Records: A set of related data items, such as a candidate registration record including: Name, date of birth, student number, ID number, etc.

---> Files: A set of related data sets defined by the creator, logically divided into structural files (similar to record composition) and unstructured files (character streams, also known as streaming files, using OD disassembly binaries under Linux)? ) Two kinds.

For structure files, it is divided into sequential files and index files. The sequential file is divided into string structure and sequential structure.

In addition, I read David both's three documents an introducition to Linux Filesystems,an Introduction to Linux ' s EXT4 filesystem and Everything is Files

For a deep understanding of what a document is (a brief description of the three articles above):

These three articles from 3 aspects of the document, the first one is from a high-level to tell the concept of the Linux file system. The corresponding second article describes the special file system type EXT4 from low-level. The last article is to say that the topic everything is files.

First article:

first, the computer needs to store all kinds of data in HDD or usbmemory stick. Because 1, standard volatile RAM will lose content after he loses power (such as DDR3 DDR4), and Flash RAM is too expensive (such as USB and solid State drive SSD)2, Standard RAM is still more expensive than disk space, with 16GB of RAM vs. a 2TB hard drives 71 times times more expensive. Today, a typical RAM is probably $0.0000000043743750/byte. (Note: This price is given in the article, I probably forget some of the east of Kingston DDR3 8G 450/16/1024/1024/1024/6.8=$0.000000007703 seems to be a double? )。

The filesystems is then defined from different angles (definitions): (filesystems is) 1, the entire LINUX directory structure starting at the top (/) Root directory;2, A specific type of data storage Format,such as EXT34,BTRS,XFS and so on. (Linux supports almost types of filesystems), 3, A partition or logical volume formatted with A specific type of Filesys Tem that can is mounted on a specified mount point on a Linux filesystem.

1. Basic filesystem function is to provide space for non-volatile storage of data. All filesystems need to provide a namespace --that are, a naming and organizational methodology. It also defines the logical structure of data on a disk, such as the use of directories for organizing files Inst EAD of just dumping them all together in a single,huge conglomeration (mixture) of files.

Once the namespace has been defined,a metadata structure are necessary to provide the logical foundation For that namespace.

Filesystem also require an application programming Interface (API) that provide access to system function calls which Manip Ulate filesystem objects like files AMD directories. APIs provide for tasks such as Creating,moving,and deleting files. It also provides algorithms that determine things like where a file is placed on filesystem.

Modern filesystem also provide a security Model,which is a scheme for defining access rights of files and directories.

The final building block is the software required to implement all of these functions. Linux Use a Two-part software implementation as a-to improve both system and programmer efficiency.

(First part) Virtual File System provides a single set of commands for the Kernel,and developers, to access all types of filesystems.

(Second part) The FILESYSTEM-SPECIFIC device drivers (device driver for a specific file system) interprets the standard set of filesystem commands to O NES secific to the type of filesystem on the Paratition or logical volume.

Directory Structure--------Tree-like Hierarchy

The Linux directory structure is well defined and documented in the Linux Filesystem Hierarchy Standard (FHS).

/: The root filesystem is the top-level directory of the filesystem. All the things (such as files executables and libraries) required to boot is in it. After the system was Booted,all other filesystems was mounted on standard. Well-defined mount points as subdirectories of T He root filesystem.

/bin:this directory contains user executable files.

/boot:contains the static bootloader and kernel executable and configuration files required to boot the Linux computer.

/dev:this deirectory contains the device files for every hardware device attached to the system. These is not device drivers,rather they is files that represent each divice on the computer and facilitate (help) access to Those devices.

/etc:contains The Local System configuration files for the host computer.  

/home:home directory storage for user files. Each user has a subdirectory in/home.

/lib:contains Shared library files that is required to boot the system.

/media:a Place-to-mount external removable media devices such as USB thumb drives that may is connected to the H Ost.

/mnt:a temporary mountpoint for regular filesystems (as-not-removable media) that can is used while the A Dministrator is repairing or working on a filesystem.

/opt:optional files (called third-party collaborative documents in Bird's-uncle's book) such as vendor supplied application programs should is located here.

/root:this is not the root (/) filesystem. It's the home directory for the root user.

/sbin:System binary Files. These is executables used for system administration.

/tmp:temporary directory. Used by the operating system and many programs to store temporary files. Users may also store files here temporarily. Note that the files stored here is deleted at any time without prior notice.

/usr: (Unix software resource, likeProgramFiles in Windows) These is shareable, read-only files, includ ing executable binaries and libraries, mans files, and other types of documentation.

/var:variable data files is stored here. This can include things. log files, MySQL, and other database files, Web server data files, email inboxes, and much MO Re.

1. All the red directories and their subdirectories cannot is created as a separate filesystem and mounted at Star Tup time. This is because they (specifically, their contents) must being present at boot time on order for the system to boot properly.

2, The/media and/mnt directories is part of the root filesystem, but they should never contain any data. Rather, they is simply temporary mount points.

3. All the black directories don't need to being present during the boot sequence, but would be mounted later, during the star Tup sequence that prepares, the host to perform useful work.

Linux Unified directory Structure

In the Windows need to know a file or program are located on which hard Drives,such as C:d: E:. Then you can use a CD command to the correct directory to locate the desired file. Each of the own separate and complete directory tree. But the Linux filesystem unifies all physical hard drives and partitions to a single directory structure.

This can work only because a filesystem, such as/home,/tmp,/Var,/opt, OR/USR can created on separate physical hard drives, a different partition, or a different logical volume from the/(root) filesystem and then being mounted on a MOUNTP Oint (directory) as part of the root filesystem tree. Even removable drives such as a USB thumb drive or an external USB or ESATA hard drive would be mounted onto the root files Ystem and become an integral part of the that directory tree.

One good reason to does this are apparent during an upgrade from one version of a Linux distribution to another, or changing From one distribution to another. There is other reasons for maintaining certain parts of the Linux directory tree as separate filesystems.

Mounting

A mount point is simply a directory, such as any other, which is created as part of the root filesystem. So, for example, the home filesystem are mounted on the directory/home. Filesystems can be mounted at mount points on the other non-root filesystems it's less common.

The Linux root filesystem is mounted to the root directory (/) very early in the boot sequence. Other filesystems is mounted later, by the Linux startup programs, either RC under SYSTEMV or by SYSTEMD in newer Linux releases.  mounting of Filesystems during the startup process is managed by The/etc/fstab configuration file. An easy-to-remember that's that's fstab stands for "File system table," and it's a list of filesystems that's is Mounted, their designated mount points, and any options that might is needed for specific filesystems.

Filesystems is mounted on a existing Directory/mount point using the Mountcommand.

Document (file) 1 ———— An introduction to Linux filesystems

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.