码迷,mamicode.com
首页 > 系统相关 > 详细

文件(file)1————An introduction to Linux filesystems

时间:2018-08-08 15:42:21      阅读:226      评论:0      收藏:0      [点我收藏+]

标签:RoCE   nec   points   programs   instead   top   mail   arch   des   

这里讲的主要是关于文件,目录以及一部分磁盘的相关知识。主要依据是操作系统第4章 文件管理(参考书:王道的书)和鸟哥的私房菜的第567章。

 在系统运行时,计算机以进程为基本单位进行资源的调度和分配;而在用户进行的输入、输出中,则以文件为基本单位。


1、什么是文件?

  从比喻的角度来讲,操作系统是图书管理员对于书的管理,则文件就是图书馆的书。

  从底层向上的角度来讲,数据项:用于描述一个对象的某种属性值,如姓名,日期或证件号(注意这三个例子中的一个就是数据项)

             --->记录:一组相关数据项的集合,如一个考生报名记录包括:姓名,出生日期,学号,身份证号等等。

             --->文件:由创建者所定义的一组相关数据集合,逻辑上可分为结构文件(类似于记录组成)和无结构文件(字符流,又称流式文件,在Linux下使用od反汇编的二进制文件?)两种。

                对于结构文件分为顺序文件和索引文件。其中的顺序文件分为串结构和顺序结构。

 另外,我拜读了 

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 are in it.After the system is booted,all other filesystems are mounted on standard .well-defined mount points as subdirectories of the 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 are not device drivers,rather they are files that represent each divice on the computer and facilitate(帮助) 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 are required to boot the system.

/media :A place to mount external removable media devices such as USB thumb drives that may be connected to the host.

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

/opt   :Optional files(鸟叔书中称为第三方协力文件) such as vendor supplied application programs should be located here.

/root  :This is not the root (/) filesystem. It is the home directory for the root user.

/sbin :System binary files. These are 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 files stored here may be deleted at any time without prior notice.

/usr  :(Unix software resource,like ProgramFiles in windows)These are shareable, read-only files, including executable binaries and libraries, man files, and other types of documentation.

/var  :Variable data files are stored here. This can include things like log files, MySQL, and other database files, web server data files, email inboxes, and much more.

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

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

  3、All the black directories do not need to be present during the boot sequence, but will be mounted later, during the startup sequence that prepares the host to perform useful work.

Linux unified directory structure

  In windows you need to know a file or program is located on which hard drives,such as C: D: E:.Then you can use cd command to change to the correct directory to locate the desired file. Each hard drive has its own separate and complete directory tree.But linux filesystem unifies all physical hard drives and partitions into a single directory structure.

  This can work only because a filesystem, such as /home, /tmp, /var, /opt, or /usr can be created on separate physical hard drives, a different partition, or a different logical volume from the / (root) filesystem and then be mounted on a mountpoint (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 will be mounted onto the root filesystem and become an integral part of that directory tree.

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

Mounting 

 A mount point is simply a directory, like any other, that is created as part of the root filesystem. So, for example, the home filesystem is mounted on the directory /home. Filesystems can be mounted at mount points on other non-root filesystems but this is less common.

The Linux root filesystem is mounted on the root directory (/) very early in the boot sequence. Other filesystems are 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 way to remember that is that fstab stands for "file system table," and it is a list of filesystems that are to be mounted, their designated mount points, and any options that might be needed for specific filesystems.

Filesystems are mounted on an existing directory/mount point using the mountcommand. 

 

文件(file)1————An introduction to Linux filesystems

标签:RoCE   nec   points   programs   instead   top   mail   arch   des   

原文地址:https://www.cnblogs.com/SsoZhNO-1/p/9196739.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!