Linux Filesystem Hierarchy 之前言

Linux Filesystem Hierarchy

Version 0.65

Binh Nguyen

<linuxfilesystem(at)yahoo(dot)com(dot)au>

2004-07-30

Chapter 1. Linux Filesystem Hierarchy1.1. Foreward

When migrating from another operatingsystem such as Microsoft Windows to another; one thing that will profoundlyaffect the end user greatly will be the differences between the filesystems.

当从一个操作系统迁移到另一个操作系统的时候,比如,由Microsoft Windows到另外的操作系统;在情绪上,很大程度影响终端用户的一件事是文件系统间的差异。

What are filesystems?

那么,什么是文件系统呢?

A filesystem is the methods and datastructures that an operating system uses to keep track of files on a disk or partition;that is, the way the files are organized on the disk. The word is also used torefer to a partition or disk that is used to store the files or the type of thefilesystem. Thus, one might say I have two filesystems meaning one has twopartitions on which one stores files, or that one is using the extendedfilesystem, meaning the type of the filesystem.

文件系统是操作系统为了跟踪磁盘或者分区上的文件而使用的方法和数据结构;也就是,文件在磁盘上组织的方法。这个词汇也用于提及用来存储文件的分区或者磁盘,或者文件系统的类型。因此,有人可能会说“我有2个文件系统”,意思是他有2个分区,在这2个分区上存储着文件,或者,他正在使用扩展文件系统,这时就意味着文件系统的类型。

The difference between a disk or partitionand the filesystem it contains is important. A few programs (including,reasonably enough, programs that create filesystems) operate directly on theraw sectors of a disk or partition; if there is an existing file system thereit will be destroyed or seriously corrupted. Most programs operate on afilesystem, and therefore won’t work on a partition that doesn’t contain one(or that contains one of the wrong type).

磁盘或分区与它们所包含的文件系统之间的区别是很重要的。有一些程序(包括创建文件系统的程序)直接操作于磁盘或者分区的原始扇区上;如果那上面已经存在了文件系统,则该文件系统会被销毁或者崩溃掉。大部分的程序是操作在文件系统上面的,因此,不会操作在没有文件系统(或者,包含的是错误类型的文件系统)的分区上。

Before a partition or disk can be used as afilesystem, it needs to be initialized, and the bookkeeping data structuresneed to be written to the disk. This process is calledmaking afilesystem.

在能够将一个分区或者磁盘作为文件系统使用之前,首先需要初始化,然后薄记的数据结构需要写入磁盘。这个过程叫做“制作文件系统”。

Most UNIX filesystem types have a similargeneral structure, although the exact details vary quite a bit. The centralconcepts are superblock, inode, data block, directory block, and indirectionblock. The superblock contains information about the filesystem as a whole,such as its size (the exact information here depends on the filesystem). Aninode contains all information about a file, except its name. The name isstored in the directory, together with the number of the inode. A directoryentry consists of a filename and the number of the inode which represents thefile. The inode contains the numbers of several data blocks, which are used tostore the data in the file. There is space only for a few data block numbers inthe inode, however, and if more are needed, more space for pointers to the datablocks is allocated dynamically. These dynamically allocated blocks areindirect blocks; the name indicates that in order to find the data block, onehas to find its number in the indirect block first.

虽然确切的细节上有一些差异,大部分的UNIX文件系统类型具有比较相似的一般性的结构。中心的概念就是,superblock,inode,data block,directoryblock,和 indirection block。

Superblock包含文件系统整体的信息,诸如,它的大小(确切的信息依赖于文件系统)。

inode包含关于一个文件的所有信息,除了该文件的名字之外。该文件的名字,与inode的数量一起,存储在directory里。

directory entry包含,文件名,以及表示该文件的inode的数目。

Inode包含datablocks的数目,data blocks是用于在文件中存储数据。然而,inode中仅有空间用于存储一些data blocks号码,如果需要更多的号码,指向data blocks的指针所使用的更大的空间可以通过动态分配获得。这些动态分配的blocks,就是 indirection blocks;这个名字(indirection blocks, 间接blocks)也表明,为了找到 data block,必须首先在indirect block中找到它的号码。

Like UNIX, Linux chooses to have a singlehierarchical directory structure. Everything starts from the root directory,represented by /, and then expands into sub-directories instead of havingso-called ‘drives’. In the Windows environment, one may put one’s files almostanywhere: on C drive, D drive, E drive etc. Such a file system is called ahierarchical structure and is managed by the programs themselves (programdirectories), not by the operating system. On the other hand, Linux sortsdirectories descending from the root directory / according to their importanceto the boot process.

像UNIX一样,Linux选择单一架构的directory结构。万事都从rootdirectory开始,表示为 / , 然后,扩展到子目录(sub-directory),而不是所谓的‘drives’(驱动器)。在Windows环境中,人们或许会将他们的文件放在任何地方:在C盘,D盘,E盘等。这样的文件系统被称作架构的structure,是由程序自己(programdirectories)管理的,而不是由操作系统。另一方面,Linux根据directories在启动过程中的重要性,将它们从root 目录 / 降序排列。

If you’re wondering why Linux uses thefrontslash / instead of the backslash \ as in Windows it’s because it’s simplyfollowing the UNIX tradition. Linux, like Unix also chooses to be casesensitive. What this means is that the case, whether in capitals or not, of thecharacters becomes very important. So this is not the same as THIS. Thisfeature accounts for a fairly large proportion of problems for new usersespecially during file transfer operations whether it may be via removable diskmedia such as floppy disk or over the wire by way of FTP.

如果你想知道,为什么Linux使用正斜杠 / 而不是如Windows中的饭斜杠\ ,这是因为Linux只是简单的跟随UNIX的传统。Linux,像UNIX一样,选择大小写敏感的方式。这意味着,字符是否大小写变得非常重要。因此 this 和 THIS不同。这个特性为Linux的新用户给出了相当多的问题原因,特别是在通过可移除的磁盘介质诸如 floppy disk,或者经过线缆的FTP进行文件传输操作过程中。

The filesystem order is specific to thefunction of a file and not to its program context (the majority of Linuxfilesystems are ‘Second Extended File Systems’, short ‘EXT2’ (aka ‘ext2fs’ or’extfs2′) or are themselves subsets of this filesystem such as ext3 andReiserfs). It is within this filesystem that the operating system determinesinto which directories programs store their files.

对于文件的功能,而不是它的程序的上下文(大多数Linux 文件系统是’第二扩展文件系统’, 简称’EXT2′(也可以称作’ext2fs’, 或者’extfs2′),或者是他们的子集,诸如ext2和Reiserfs)而言,文件系统是特别的。在该文件系统中,操作系统决定着程序将它们的文件存储到哪些directories中。

If you install a program in Windows, itusually stores most of its files in its own directory structure. A help filefor instance may be in C:\Program Files\[program name]\ or in C:\ProgramFiles\[program-name]\help or in C:\Program Files\[program-name]\humpty\dumpty\doo. In Linux, programs put their documentation into/usr/share/doc/[program-name], man(ual) pages into /usr/share/man/man[1-9] andinfo pages into /usr/share/info. They are merged into and with the systemhierarchy.

如果你在Windows中安装程序,Windwos通常会将程序的大部分文件存储在它自己的目录结构中。例如,帮助文件可能在C:\Program Files\[program name]\ 或者C:\ProgramFiles\[program-name]\help,或者在 C:\ProgramFiles\[program-name]\humpty\dumpty\doo中。

而Linux中,程序将它们的文档放在 /usr/share/doc/[program-name]中,手册放在/usr/share/man/man[1-9]中,info放在/usr/share/info中。他们与系统架构混合成了一体。

As all Linux users know, unless you mount apartition or a device, the system does not know of the existence of thatpartition or device. This might not appear to be the easiest way to provideaccess to your partitions or devices, however it offers the advantage of fargreater flexibility when compared to other operating systems. This kind oflayout, known as the unified filesystem, does offer several advantages over theapproach that Windows uses. Let’s take the example of the /usr directory. Thissub-directory of the root directory contains most of the system executables.With the Linux filesystem, you can choose to mount it off another partition oreven off another machine over the network using an innumerable set of protocolssuch as NFS (Sun), Coda (CMU) or AFS (IBM). The underlying system will not andneed not know the difference. The presence of the /usr directory is completelytransparent. It appears to be a local directory that is part of the local directorystructure.

正如所有的Linux用户知道的那样,除非挂接了一个分区或者设备,系统并不知道那个分区或者设备的存在。这或许不是为你提供的对你的分区或者设备进行访问的最简单的方法,然而,当与其他的操作系统进行对比时,它提供了更大的灵活性这个优势。这种布局,称作统一的(unified)文件系统,相对Windows使用的方法而言,其提供了几个优势。让我们以/usr目录为例。根目录的这个子目录,包含大部分的系统可执行文件。与Linux的文件系统一起,你可以选择在另外的分区或者使用诸如NFS(Sun),Coda(CMU),或者AFS(IBM)的协议通过网络在另外一台机器上挂接该目录(/usr)。下面的系统不会,也不必要知道这之间的差别。/usr目录的存在是完全透明的。好像是本地目录结构的一部分的本地目录。

Compliance requires that:

+————-+——————–+—————-+

| | shareable | unshareable |

+————+———————+—————-+

|static | /usr | /etc |

| | /opt | /boot |

+————+———————-+—————-+

|variable | /var/mail | /var/run |

| | /var/spool/news | /var/lock |

+————-+———————+—————-+

"Shareable" files are defined asthose that can be stored on one host and used on others."Unshareable" files are those that are not shareable. For example,the files in user home directories are shareable whereas device lock files arenot. "Static" files include binaries, libraries, documentation files and other files that donot change without system administrator intervention. "Variable"files are defined as files that are not static.

"可共享的"文件,是存储在一个host上,并能够在其他的hosts上使用的文件。

"不可共享的"文件,是不"可共享的"文件。例如,处于用户home目录下的文件就是可共享的,而device lock 文件则不是。

"静态的"文件,包括二进制,库,文档文件,以及,在没有系统管理员干预的情况下,不会改变的文件。

"可变的"文件,定义为不是"静态的"文件。

Another reason for this unified filesystemis that Linux caches a lot of disk accesses using system memory while it isrunning to accelerate these processes. It is therefore vitally important thatthese buffers are flushed (get their content written to disk), before thesystem closes down. Otherwise files are left in an undetermined state which isof course a very bad thing. Flushing is achieved by ‘unmounting’ the partitionsduring proper system shutdown. In other words, don’t switch your system offwhile it’s running! You may get away with it quite often, since the Linux filesystem is very robust, but you may also wreak havoc upon important files. Justhit ctrl-alt-del or use the proper commands (e.g. shutdown, poweroff, init 0).This will shut down the system in a decent way which will thus, guarantee theintegrity of your files.

选择这个统一的文件系统的另外一个理由是,为了在运行的时候加速对磁盘的访问,Linux使用系统内存(system memory)缓存了很多磁盘访问的数据。因此,在系统关闭之前,很重要的一点是,对这些缓冲区(buffers)进行泛洪(flush)(即,将缓冲区的内容写回到磁盘)。否则的话,磁盘上的文件就处于一种未决的状态,这无疑是一件很不好的事情。在妥当的系统关闭过程中,通过将相应的分区‘去挂接’(unmounting)实现泛洪(flushing)。换句话说,在系统正在运行的时候,不要关掉你的系统。你或许经常暴力关机,因为Linux文件系统很健壮,但是这么多,可能会对重要的文件带来伤害。轻敲ctrl-alt-del或者使用合适的命令(例如,shutdown, poweroff, init0)。这样将以一个比较正确的方式关闭系统,同时保证了文件的完整性。

Many of us in the Linux community have cometo take for granted the existence of excellent books and documents about Linux,an example being those produced by the Linux Documentation Project. We are usedto having various packages taken from different sources such as Linux FTP sitesand distribution CD-ROMs integrate together smoothly. We have come to acceptthat we all know where critical files like mount can be found on any machinerunning Linux. We also take for granted CD-ROM based distributions that can berun directly from the CD and which consume only a small amount of physical harddisk or a RAM disk for some variable files like /etc/passwd, etc. This has notalways been the case.

Linux社区中的大部分人接受了关于Linux的完美的书籍和文档的存在,其中的一个例子是由Linux Documentation Project发行的书籍和文档。我们习惯于从做到良好集成的不同的源,诸如Linux FTP和发行的CD-ROMs来获取各种packages。我们也接受了我们所知的在任何运行Linux的机器上像mount一样的重要文件所存放的位置。我们也接受了基于CD-ROM的发行包能直接从CD中运行,该发行包只消耗了少量的物理硬磁盘或者RAM disk用于一些可变的文件(variablefiles)像 /etc/passwd 等。

During the adolescent years of Linux duringthe early to mid-90s each distributor had his own favorite scheme for locatingfiles in the directory hierarchy. Unfortunately, this caused many problems. TheLinux File System Structure is a document, which was created to help end thisanarchy. Often the group, which creates this document or the document itself,is referred to as the FSSTND. This is short for file system standard".This document has helped to standardize the layout of file systems on Linuxsystems everywhere. Since the original release of the standard, mostdistributors have adopted it in whole or in part, much to the benefit of allLinux users.

在20世纪90年代中期的早几年,Linux还处于未成熟的年份,对于如何在目录架构下放置文件,每一个发行商都有他们自己喜好的模式。不幸地,这却引起了很多的问题。Linux File System Structure 是一个文档,创建它的目的是帮助终结这种无秩序的状态。时常地,创建这个document或者 document itself的group会称作FSSTND。它是 file system standard 的简写。该文档已经帮助标准化了无论何地的Linux system上的文件系统布局。因为该标准的原始版本,大部分的发行商已经完全地或者部分地遵守了它, 这对于所有的Linux用户而言,是很大的裨益。

Since the first draft of the standard, theFSSTND project has been coordinated by Daniel Quinlan and development of thisstandard has been through consensus by a group of developers and Linuxenthusiasts. The FSSTND group set out to accomplish a number of specific goals.The first goal was to solve a number of problems that existed with the currentdistributions at the time. Back then, it was not possible to have a shareable/usr partition, there was no clear distinction between /bin and /usr/bin, itwas not possible to set up a diskless workstation, and there was just generalconfusion about what files went where. The second goal was to ensure thecontinuation of some reasonable compatibility with the de-facto standardsalready in use in Linux and other UNIX-like operating systems. Finally, thestandard had to gain widespread approval by the developers, distributors, andusers within the Linux community. Without such support, the standard would bepointless, becoming just another way oflaying out the file system.

因为该标准的第一稿,FSSTND项目已经由Daniel Quinlan进行组织协调,并且,该标准的开发工作已经通过了由开发人员和Linux拥趸组成的group达成的协议。FSSTND采取步骤以实现一些特别的目标。第一个目标是解决当时的发行包存在的一些问题。在那个时候,不太可能拥有一个可共享的/usr分区,在/bin和/usr/bin之间没有明显的区别,不太可能建立无盘的工作站,并且,什么文件在什么地方也比较混淆。第二个目标,确保与Linux和其他的UNIX类的操作系统已经使用中的事实上的标准的兼容性的持续进行。最终,该标准必将获得开发人员,发行商和Linux社区用户的广泛赞同。如果没有这样的支持,标准会变得没有无的放矢,变成布局文件系统的另外一个方式。

Fortunately, the FSSTND has succeededthough there are also some goals that the FSSTND project did not set out toachieve. The FSSTND does not try to emulate the scheme of any specificcommercial UNIX operating system (e.g. SunOS, AIX, etc.) Furthermore, for manyof the files covered by the FSSTND, the standard does not dictate whether thefiles should be present, merely where the files should be if they are present.Finally, for most files, the FSSTND does not attempt to dictate the format ofthe contents of the files. (There are some specific exceptions when severaldifferent packages may need to know the file formats to work together properly.For example, lock files that contain the process ID of the process holding thelock.) The overall objective was to establish the location where common filescould be found, if they existed on a particular machine. The FSSTND projectbegan in early August 1993. Since then, there have been a number of publicrevisions of this document. The latest,v2.3 was released on January 29, 2004.

幸运地,虽然还有一些目标还没有达成,FSSTND已经成功了。FSSTND并不打算模仿任何特别的商业UNIX操作系统(诸如,SunOS, AIX等)的模式。进一步,对于FSSTND提及的很多文件,标准并没有规定(dictate)文件是否应该出现,如果出现的话,它们应该在哪。最终,对于大部分文件,FSSTND不会尝试规定文件内容的个格式(也有一些例外情况,当为了更好的协同工作,几个不同的packages需要知道文件的格式。例如,lock files包含着持有该lock的process的processID)。主要的目标是建立可以找到common files的存储位置,如果它们确实存在于一台特定的机器上的话。FSSTND项目始于1993年8月上旬。从那时开始,就已经出现了该文档的很多公开的版本。最新的,v2.3版本发行于2004年1月29日。

If you’re asking "What’s the purposeof all this? Well, the answer depends on who you are. If you are a Linux user,and you don’t administrate your own system then the FSSTND ensures that youwill be able to find programs where you’d expect them to be if you’ve alreadyhad experience on another Linux machine. It also ensures that any documentationyou may have makes sense. Furthermore, if you’ve already had some experiencewith Unix before, then the FSSTND shouldn’t be too different from what you’recurrently using, with a few exceptions. Perhaps the most important thing isthat the development of a standard brings Linux to a level of maturity authorsand commercial application developers feel they can support.

如果你要问,所有这些的目的是什么?那么,其答案依赖于你是谁。如果你是Linux用户,并且你不管理你的系统,如果你在另外的Linux机器上有使用经验的话,FSSTND确定你能够在你所期望的地方找到你想要的程序。FSSTND也确定你拥有的任何文档都有意义。进一步,如果你以前使用过UNIX,那么FSSTND不会与你当前使用的有很大不同,除了一些例外情况。或许,最重要的事情是,标准的开发将Linux带到了一个成熟的作者和商业应用程序开发人员感觉他们能够提供支持的层次上。

If you administer your own machine then yougain all the benefits of the FSSTND mentioned above. You may also feel moresecure in the ability of others to provide support for you, should you have aproblem. Furthermore, periodic upgrades to your system are theoreticallyeasier. Since there is an agreed-upon standard for the locations of files,package maintainers can provide instructions for upgrading that will not leaveextra, older files lying around your system inhabiting valuable disk space. TheFSSTND also means that there is more support from those providing source codepackages for you to compile and install yourself. The provider knows, forexample, where the executable for sed is to be found on a Linux machine and canuse that in his installation scripts or Makefiles.

如果你在管理你自己的机器,你会得到上面提到的FSSTND的所有的裨益。如果你有疑问的话,因为其他人为你提供支持的能力,你或许会感觉到更安全。进一步,对你的系统不定时的更新在理论上变得更容易。因为对于文件的位置有一个基于协商的标准,package维护人员可以提供指导进行更新,这并不会留下额外的较老的文件在你的系统里,以免占据有价值的磁盘空间。FSSTND也意味着如果你想自己编译、安装源代码packages,那么可以从提供源代码packages的人员那里获得更多的支持。例如,提供者知道在一个Linux 机器上sed的可执行文件将在哪里找到,并能在他的安装脚本或者Makefiles中使用它。

If you run a large network, the FSSTND mayease many of your NFS headaches, since it specifically addresses the problemswhich formerly made shared implementations of /usr impractical. If you are a distributor,then you will be affected most by the Linux FSSTND. You may have to do a littleextra work to make sure that your distribution is FSSTND?compliant, but yourusers (and hence your business) will gain by it. If your system is compliant,third party add?on packages (and possibly your own) will integrate smoothly withyour system.. Your users will, of course, gain all the benefits listed above,and many of your support headaches will be eased. You will benefit from all thediscussion and thought that has been put into the FSSTND and avoid many of thepitfalls involved in designing a filesystem structure yourself. If you adhere tothe FSSTND, you will also be able to takeadvantage of various features that the FSSTND was designed around. For example,the FSSTND makes "live" CD?ROMs containing everything except some ofthe files in the / and /var directories possible. If you write documentationfor Linux, the FSSTND makes it much easier to do so, which makes sense to theLinux community. You no longer need to worry about the specific location of lockfiles on one distribution versus another, nor are you forced to writedocumentation that is only useful to the users of a specific distribution. TheFSSTND is at least partly responsible for the recent explosion of Linux booksbeing published.

如果你运行一个较大的网络,FSSTND或许能够为你免除很多NFS方面的头疼问题,因为FSSTND特别针对这些问题,而在之前,这些问题还使得/usr的共享实现不太实际。如果你是一个发布者,那么你会收到Linux FSSTND较大的影响。为了确保你的发布是FSSTND兼容的,你或许不得不做一点额外的工作,但是你的用户(同时也是你在做事务)会从中受益。如果你的系统是兼容的,第三方的插件packages(也可能是你自己的)会与你的系统平滑地集成。当然,你的用户会获得上面列出的所有益处,也免除了很多支持的问题。你会从FSSTND的讨论和想法中获得益处,并且避免在你自己设计的文件系统结构中陷入诸多的陷阱中。如果你跟随FSSTND,你也能够利用FSSTND设计中的各种特性。例如,FSSTND制作了’live’ CD-ROMs,包含所有的文件,除了/ 和 /var目录下的一些文件。如果你为Linux写文档,FSSTND将会使得它更容易完成,这对Linux社区很有意义。你再也不需要担心一个distribution 与另一个distribution上的lock files的特定位置,也不需要再写对特定的distribution的用户才有用的文档。FSSTND至少在一定程度上对于正在出版的Linux书籍的急剧增长负有责任。

If you are a developer, the existence ofthe FSSTND greatly eases the possibility for potential problems. You can knowwhere important system binaries are found, so you can use them from inside yourprograms or your shell scripts. Supporting users is also greatly eased, sinceyou don’t have to worry about things like the location of these binaries whenresolving support issues. If you are the developer of a program that needs to integratewith the rest of the system, the FSSTND ensures that you can be certain of thesteps to meet this end. For example, applications such as kermit, which accessthe serial ports, need to know they can achieve exclusive access to the TTYdevice. The FSSTND specifies a common method of doing this so that all compliantapplications can work together. That way you can concentrate on making moregreat software for Linux instead of worrying about how to detect and deal withthe differences in flavors of Linux. The widespread acceptance of the FSSTND bythe Linux community has been crucial to the success of both thestandard and operating system. Nearly everymodern distribution conforms to the Linux FSSTND. If your implementation isn’tat least partially FSSTND compliant, then it is probably either very old or youbuilt it yourself. The FSSTND itself contains a list of some of the distributions that aim to conform to the FSSTND. However, there are somedistributions that are known to cut some corners in their implementation of FSSTND.

如果你是一个开发人员,FSSTND的存在较大地免除了潜在问题的可能性。你可以知道重要的系统可执行文件可以在哪找到,因此,你可以在你的程序或者shell脚本中使用它们。为用户提供支持也得到较大的避免,因为在解决支持方面的问题的时候,你不需要担心像这些二进制文件所在的位置这样的事情。如果你是一个程序的开发人员,而它需要与系统的其他部分集成,FSSTND确保只需要几步就可以满足这一点。例如,应用程序,如kermit,它访问串口,需要知道它们可以对TTY设备完成互斥的访问。FSSTND定义了做这件事的通常的方法,以便所有兼容的应用程序能够一起工作。以这种方式,你可以聚焦于为Linux开发更好的软件,而不是担心怎么检测,并处理这些不同(inflavors of Linux)。Linux社区对FSSTND的广泛接受对于标准以及操作系统的成功都是至关重要的。几乎每一个现代distribution都遵从Linux FSSTND。如果你的实现不是至少部分FSSTND兼容,那么,它或者是很老,或者是你自己构建的。FSSTND本身有一个列表,包含一些distribution,目的是遵从FSSTND。然而,也有一些distributions,以最简单廉价的方式实现FSSTND。

By no means does this mean that thestandard itself is complete. There are still unresolved issues such as the organizationof architecture?independent scripts and data files /usr/share. Up until now,the i386 has been the primary platform for Linux, so the need forstandardization of such files was non?existent.

By no means,这意味着标准本身是完整的。也有一些未解决的问题,如独立于架构的脚本和/usr/share的数据文件的组织。直到现在,i386已经是Linux的主要平台,这些文件的标准化必要性就不存在了。

The rapid progress in porting Linux toother architectures (MC680x0, Alpha, MIPS, PowerPC) suggests that this issuewill soon need to be dealt with. Another issue that is under some discussion isthe creation of an /opt directory as in SVR4. The goal for such a directorywould be to provide a location for large commercial or third party packages toinstall themselves without worrying about the requirements made by FSSTND forthe other directory hierarchies. The FSSTND provides the Linux community withan excellent reference document and has proven to be an important factor in thematuration of Linux. As Linux continues to evolve, so will the FSSTND.

移植Linux到其他的架构(MC680x0,Alpha,MIPS,PowerPC)的快速进展,暗示着这个问题需要尽快处理。另一个处于讨论中的问题是,像SVR4中一样,创建/opt目录。这样的一个目录的目的是为较大的商业或者第三方packages提供存储位置以便安装它们,而不需要担心用于其他的目录架构的FSSTND的需求。FSSTND为Linux社区提供了一个出色的参考文档,并且证明了其在Linux的成熟中是一个重要因素。随着Linux的基础发展,FSSTND也在发展着。

Now, that we have seen how things shouldbe, let’s take a look at the real world. As you will see, the implementation ofthis concept on Linux isn’t perfect and since Linux has always attractedindividualists who tend to be fairly opinionated, it has been a bone ofcontention among users for instance which directories certain files should beput into. With the arrival of different distributions, anarchy has once againdescended upon us. Some distributions put mount directories for external mediainto the / directory, others into /mnt. Red Hat based distributions feature the/etc/sysconfig sub?hierarchy for configuration files concerning input and networkdevices. Other distributions do not have this directory at all and put theappropriate files elsewhere or even use completely different mechanisms to dothe same thing. Some distributions put KDE into /opt/, others into /usr.

我们已经看到了事情应该是怎么样的,现在,让我们看看现实中的世界。正如你所见,Linux上这个概念的实现还不完美,并且,因为Linux总是吸引到fairlyopinionated的个体,在用户间这已经变成了争论的主题,比如某些文件应该放进哪个目录。伴随着不同distributions的出现,无管束状态再一次降临到我们头上。一些distributions把用于外部介质的mount目录放在了/ 目录下,其他的放在/mnt中。基于红帽子的distributions将与输入和网络设备相关的配置文件放在/etc/sysconfig 子架构中。其他的distributions根本没有这个目录,并将适当的文件放在其他地方,或者甚至使用完全不同的机制完成相同的事情。一些distributions将KDE放在/opt/目录,其他distributions将其放在了/usr目录。

But even within a given file systemhierarchy, there are inconsistencies. For example, even though this was neverthe intention of the XFree86 group, XFree86 does indeed have its own directoryhierarchy.

但是,即使在一个给定的文件系统架构中,也存在不一致性。例如,即使这绝不是XFree86 group的意图,XFree86确实有它自己的目录架构。

These problems don’t manifest themselves aslong as you compile programs yourself. You can adapt configure scripts orMakefiles to your system’s configuration or to your preference. It’s adifferent story if you install pre?compiled packages like RPMs though. Oftenthese are not adaptable from one file system hierarchy to another. What’sworse: some RPMs might even create their own hierarchy. If you, say, install a KDERPM from the SuSE Linux distribution on your Mandrake system, the binary willbe put into /opt/kde2/bin. And thus it won’t work, because Mandrake expects itto be in /usr/bin. There are of course ways to circumvent this problem but thecurrent situation is clearly untenable. Thus, all the leading Linux distributorshave joined the Linux Standard Base project, which is attempting to create acommon standard for Linux distributions. This isn’t easy, since changing thefile system hierarchy means a lot of work fordistributors so every distributor tries topush a standard which will allow them to keep as much of their own hierarchy aspossible. The LSB will also encompass the proposals made by the FilesystemHierarchy Standard project (FHS, former FSSTND).

只要是你自己编译程序,这些问题就不会暴露出来。你可以调整配置脚本或者Makefiles到你的系统配置或者你的喜好。如果你安装预先编译好的packages,像RPMs,那是一个不一样的故事。经常地,从一个文件系统架构到另一个,这些是不可调整的。更糟糕的是,一些RPMs甚至创建了它们自己的架构。假设,如果你在你的Mandrake系统上安装来自SuSE Linuxdistribution的KDE RPM,该二进制文件会被放在/opt/kde2/bin里。因此,它并不会工作,因为Mandrake期望它在/usr/bin中。当然有方法绕过这个问题,但是当前的情形明显是untenable。因此,所有领先的Linux distributions已经加入了Linux Standard Baseproject,它尝试创建一个通常的标准用于Linux distributions。这并不容易,因为对于distributors,改变文件系统结构意味着很多工作,所以每一个distributor尝试推进一个标准,而这个标准将允许它们尽可能地保留它们自己的架构。LSB也会从参与由Filesystem HierarchyStandard project(FHS, 前身是FSSTND)提出的推进。后来逐渐有广州花城的,

Linux Filesystem Hierarchy 之前言

相关文章:

你感兴趣的文章:

标签云: