Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to understand the file system of Linux and related mount commands

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the relevant knowledge of "how to understand the Linux file system and related mount commands". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Linux file system

Like the concept of windows's C disk D disk E disk, this "file system" or "organizational system" is at the software level and is an "internal" system of the linux system, just like an "idea" in your head that does not have to rely on any reality.

: idea: linux system organization is-- the whole system starts from the root and gradually expands down according to the tree directory, classifying and storing files for different purposes, / read as "slash", English slash; when it writes a path, the first / represents the root, namely root, the other / represents the path separator, but all read as "slash" or "slash".

OK, now let's turn "ideal" into "reality".

: idea: when the system starts, a partition is first mounted to /, which can be understood to mean that the partition is assigned / this strange "drive letter" (note that in windows, this symbol is used as the command parameter guide symbol, while the backslash\, the English backslash as the path separator, the habit is different, just like the British driving on the left, it's not surprising).

This partition, which is mounted as /, is called the root partition (whether it is the primary partition or the logical partition). From then on, it has a special status in the whole linux system, because all the hard drives in the computer, including all other partitions on it, whether it is the primary partition or the logical partition, will take this "root partition" as the backbone, begin to build the linux tree, and eventually become a branch or leaf on the tree. In the whole linux system structure, there is only one root (root partition), and there can be no second partition (in fact, any partition can be mounted as /, or the windows partition. It's just that the purpose of mounting the root partition is to boot the system, and you won't be able to boot the system without the linux kernel and its required system files. So this root partition is not mysterious.

: idea: your other partitions can only be mounted to a directory under / (root partition), such as "/ mnt" or "/ media" or "/ whatsoever" directory, depending on what you like. After mounting, when you read and write data to this directory, you are actually reading and writing data to another partition mounted to that directory. Multiple partitions can only be mounted to multiple different directories at the same time, such as "/ mnt/a", "/ media/123" or "/ home/anywhere". Any directory under / can be used to mount other partitions as a "platform". Of course, the directories needed by the system can not be used, ha, you can create your own.

Once mounted, the data on your hard drive can be found in a way like / path/to/anywhere; if you don't mount it, you can't find it.

To use a vulgar analogy, "/" is equivalent to c:\, while "/ etc, / bin, / sbin, / lib" are probably equivalent to c:\ windows and c:\ program files, "/ home" is equivalent to c:\ Documents and Settings, and when you mount the second partition to "/ mnt/partition2", this directory is equivalent to d:\

Mount

Mount is used to mount a file system and needs to be executed by the root user. A disk can be divided into several partitions, on which a file system can be created, and a mount point provides an entry to mount the file system of a partition to a directory, which is called a mount point. and the contents of the file system can be accessed through this mount point.

For example, a hard disk is represented as / dev/sda in Linux, then the partition on it should be represented as / dev/sda1, / dev/sda2.

# mount # output the current mount information of the system

# mount / dev/sda1 / mnt # Mount sda1 to / mnt

# cd / mnt # access content directly through / mnt

# mount-o remount,rw / mnt # remount sda1 to / mnt and make it readable and writable

# mount-a # Mount the file system configured with fstab file

Umount

Umount, in contrast to mount, unloads a mount point, that is, cancels the entry.

# umount / mnt # unmount the file system at the mount point / mnt

# umount-a # unmount all mounted file systems

This is the end of the content of "how to understand the Linux file system and related mount commands". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report