什么是根文件系统(rootfs=Root Fils System)

来源:互联网 发布:php while循环 编辑:程序博客网 时间:2024/06/06 08:49

Linux系统中的根文件系统,Root FileSystem,简称为rootfs;

 

关于rootfs,之前一直很迷惑,不知道所要表达的真正的含义;

即便是通过buildroot自己建立了相关的rootfs之后,还是没能很明白的理解,到底rootfs是啥。

 

现在,突然,有那么一点明白了。

rootfs,其实就是,针对特定的操作系统的架构,一种实现的形式;

具体表现为,特定的文件夹,文件夹之间的关系,即组织架构,以及特定的各种文件;

 

再详细解释为:

Linux中的rootfs,就是那些文件夹和文件,

包括什么根文件目录’/’

系统相关的配置文件目录/etc

存放系统启动相关配置的/etc/init

存放系统相关的工具 /sbin

存在用户的工具/usr/bin

等等,诸如此类的,文件夹和文件;

 

而对应的,实际上,Windows系统中,貌似从来没听说过什么rootfs。

那是因为,实际上,Windows系统的拥有者Microsoft微软,可以说是,从来就没有给Windows操作系统开源,没有给你看源代码。

所以就没必要给你讨论内部的源代码的架构了。

但是实际上,对应的,每个版本的Windows,我指的是从Windows 95/98/XP/Win7,这些版本的系统,很明显,有很多系统相关的文件夹和文件的。

比如:

假设系统安装在C盘:

c:\windows\ 用于存放,系统相关的文件

c:\windows\system32 其中很多可执行文件(工具),都是系统相关的工具

C:\Program Files 默认的软件安装目录,本身也存在了,操作系统自带的,很多已经安装好的软件,比如上网用的IE

C:\Users (win7中有的,其他版本的windows也有类似目录)用处用于相关数据和配置

即,诸如此类的,各种系统相关的,且是固定的文件夹,文件,本质上,就是和Linux中的rootfs的概念,是想通的,一致的。

 

换句话说,如果你的操作系统类型定下来了,是Linux还是Windows,那么,和此操作系统相关的,系统级别的,固定位置的,文件夹和文件,都必须是存在的,否则,很可能,或者说必然,会导致操作系统出现无法正常运行,甚至无法启动等等问题。

 

所以,从这方面来说,所谓的rootfs,根文件系统,就是那些,能让操作系统正常运行的,文件夹和文件的大集合。

如此,才算对rootfs,有个相对感性和容易理解的解释。

来自于 The Linux Information Project 的一个定义:

The root filesystem is the filesystem that is contained on the same partition on which the root directory is located, and it is the filesystem on which all the other filesystems are mounted (i.e., logically attached to the system) as the system is booted up (i.e., started up).

A partition is a logically independent section of a hard disk drive (HDD). A filesystem is a hierarchy of directories (also referred to as adirectory tree) that is used to organize files on a computer system. On Linux and and other Unix-like operating systems, the directories start with the root directory, which contains a series of subdirectories, each of which, in turn, contains further subdirectories, etc. A variant of this definition is the part of the entire hierarchy of directories (i.e., of the directory tree) that is located on a single partition or disk.

The exact contents of the root filesystem will vary according to the computer, but they will include the files that are necessary for booting the system and for bringing it up to such a state that the other filesystems can be mounted as well as tools for fixing a broken system and for recovering lost files from backups. The contents will include the root directory together with a minimal set of subdirectories and files including /boot/dev/etc/bin/sbin and sometimes /tmp (for temporary files).

Only the root filesystem is available when a system is brought up in single user mode. Single user mode is a way of booting a damaged system that has very limited capabilities so that repairs can be made to it. After repairs have been completed, the other filesystems that are located on different partitions or on different media can then be mounted on (i.e., attached to) the root filesystem in order to restore full system functionality. The directories on which they are mounted are called mount points.

The root filesystem should generally be small, because it contains critical files and a small, infrequently modified filesystem has a better chance of not becoming corrupted. A corrupted root filesystem will generally mean that the system becomes unbootable (i.e., unstartable) from the HDD, and must be booted by special means (e.g., from a boot floppy).

A filesystem can be mounted anywhere in the directory tree; it does not necessarily need to be mounted on the root filesystem. For example, it is possible (and very common) to have one filesystem mounted at a mount point on the root filesystem, and another filesystem mounted at a mount point contained in that filesystem.


0 0
原创粉丝点击