Certification Objective 1.02:Linux Filesystem Hier

Certification Objective 1.02:Linux Filesystem Hierarchy and Structure
认证目的 1.02:Linux Filesystem 科学之分类和结构

Everything in Linux can be reduced to a file.
在 Linux 的每件事物能被转为一个文件。

Partitions are associated with filesystem device nodes such as /dev/hda1.
分区与 filesystem 装置有关波节如此的当做 /dev/hda 1.

Hardware components are associated with node files such as /dev/modem.
硬件元件波节申请有关,如此的当做 /dev/调制解调器。

Detected devices are documented as files in the /proc directory.
被发现的装置在那 /proc 目录中当做文件被证明。

The Filesystem Hierarchy Standard (FHS) is the official way to organize files in Unix and Linux directories.
Filesystem 科学之分类标准 (FHS) 是在 Unix 和 Linux 目录组织文件的官方方法。

As with the other sections, this introduction provides only the most basic overview of the FHS.
关于其他区段,这介绍提供 FHS 的只有最基本概观。

More information is available from the official FHS home page at www.pathname.com/fhs.
较多的信息在 www.pathname.com/fhs 从官方的 FHS 首页是可得的。

Linux Filesystems and Directories
Linux Filesystems 和目录

Several major directories are associated with all modern Unix/Linux operating systems.
一些主要的目录与所有的现代 Unix/Linux 操作系统有关。

These directories organize user files, drivers, kernels, logs, programs, utilities, and more into different categories.
这些目录组织使用者文件、驱动器、核仁、纪录、程序、公用程式和更多进入不同的范畴。

The standardization of the FHS makes it easier for users of other Unix-based operating systems to understand the basics of Linux.
FHS 的标准化使其他以 Unix 为基础的操作系统的使用者更容易了解 Linux 的基本。

Every FHS starts with the root directory, also known by its symbol, the single forward slash (/).
每 FHS 开始用根目录, 也被它的符号, 单一正斜线知道.(/)

All of the other directories shown in Table 1-1 are subdirectories of the root directory.
在表 1-1 被显示的所有其他目录是根目录的子目录。

Unless they are mounted separately, you can also find their files on the same partition as the root directory.
除非他们分开地被安装,你也能在与根目录相同的分区上找他们的文件。

Table 1-1:Basic Filesystem Hierarchy Standard Directories
表 1-1:基本 Filesystem 科学之分类标准目录。

 Directory目录  Description描述
 /  The root directory, the top-level directory in the FHS. All other directories are subdirectories of root, which is always mounted on some partition.
根目录, 在 FHS 中的最高阶层的目录。所有的其他目录是根的子目录,总是被展开在一些分区上。
 /bin  Essential command line utilities. Should not be mounted separately; otherwise, it could be difficult to get to these utilities when using a rescue disk.
必要的指令行公用程式。不应该分开地被安装;另外,到达这些公用程式可能是困难的当使用一个援救磁盘。
 /boot
启动
 Includes Linux startup files, including the Linux kernel. The default, 100MB, is usually sufficient for a typical modular kernel and additional kernels that you might install during the RHCE or RHCT exams.
包括 Linux 启始文件,包括 Linux 核仁。内定值,100个 MB, 对一个典型的模组核仁和另外的核仁是通常充份的你可能在 RHCE 或 RHCT 考试期间安装。
 /dev  Hardware and software device drivers for everything from floppy drives to terminals. Do not mount this directory on a separate partition.
为从软式磁盘机到终端机的每件事物的硬件和软件驱动程序。在一个分开的分区上,不要安装这一个目录。
 /etc  Most basic configuration files.
大多数的基本配置申请。
 /home  Home directories for almost every user.
家几乎每个使用者的目录。
 /lib  Program libraries for the kernel and various command line utilities. Do not mount this directory on a separate partition.
为核仁和各种不同的指令行公用程式的程序库。在一个分开的分区上,不要安装这一个目录。
 /mnt  The mount point for removable media, including floppy drives, CD-ROMs, and Zip disks.
座点为可移动的介质, 包括软式磁盘机、光盘和 ZIP 磁盘。
 /opt  Applications such as the WordPerfect or OpenOffice.org Office suites.
应用程序,像是 WordPerfect 或 OpenOffice.org Office 程序组。
 /proc  Currently running kernel-related processes, including device assignments such as IRQ ports, I/O addresses, and DMA channels.
现在正在运行中核仁讲的程序, 包括设备指派,像是 IRQ 埠, 输入/输出位址、和 DMA 波道。
 /root  The home directory of the root user.
根使用者的家目录。
 /sbin  System administration commands. Don't mount this directory separately.
系统行政命令。不要分开地安装这一个目录。
 /tmp  Temporary files. By default, Red Hat Enterprise Linux deletes all files in this directory periodically.
暂时的文件。预先设定地 , 红帽企业 Linux 在这一个目录中划除所有的文件定期地。
 /usr  Small programs accessible to all users. Includes many system administration commands and utilities.
小的程序可接近的至所有的使用者。包括许多系统行政指令和公用程式。
 /var  Variable data, including log files and printer spools.
变数数据, 包括纪录文件和打印机卷线桥。

Mounted directories are often known as volumes, which can span multiple partitions. However, while the root directory (/) is the top-level directory in the FHS, the root user's home directory (/root) is just a subdirectory.
时常安装目录即是音量,能跨越多个分区。然而,当根目录 (/) 在 FHS 中是最高阶层的目录时候,根使用者的家目录 (/根) 只是一个子目录。

 On The Job  In Linux, the word 'filesystem' has several different meanings. For example, a filesystem can refer to the FHS, an individual partition, or a format such as ext
 在 Linux 的作业上,字组 'filesystem' 有一些不同的意义。举例来说, filesystem 能提及 FHS ,一个个别的分区或一个格式,像是 ext 3 。

3. A filesystem device node such as /dev/sda1 represents the partition on which you can mount a directory.
 filesystem 装置波节如此的当做 /dev/sda 1 表现分区在哪一个之上你能安装一个目录。

Media Devices
介质装置

Several basic types of media are accessible to most PCs, including IDE hard disks, floppy drives, CD/DVD drives, and the various standards of SCSI devices. Other media are accessible through other PC ports, including serial, parallel, USB, and IEEE 1394.
介质的一些基本类型是可接近的至大多数的 PCs,包括 IDE 硬式磁盘、软式磁盘机, CD/数字化视频光磁碟机和小型电脑标准介面装置的各种不同标准。其他的介质经过其他的个人计算机埠是可接近的,包括连载,平行,万用串列总线和电器和电子工程师协会 1394 。

 You can use Linux to manage all of these types of media.
 你能使用 Linux 处理介质的所有这些类型。

Most media devices are detected automatically.
大多数的介质装置自动地被发现。

 Linux may require a bit of help for some devices described in Chapter 2.
 Linux 可能为在第 2 章被描述的一些装置需要一位元辅助。

 But in the context of the Linux FHS, media devices, like all others, are part of the /dev directory.
 但是在 Linux FHS 的语境, 介质装置, 像全部其他, 是那 /dev 目录的一部份。

Typical media devices are described in Table 1-2.
 典型的介质装置在表 1-2 被描述.

Table 1-2: Media Devices
表 1-2:介质装置

 Media Device介质装置  Device File装置文件
 Floppy drive软式磁盘机   /dev/fd0
 Second floppy (Microsoft B: drive)
 = /dev/fd1
 IDE hard drive
IDE 硬式磁盘机
IDE CD/DVD drive
IDE CD/数字化视频光磁盘
 First IDE drive = /dev/hda
Second IDE drive = /dev/hdb
Third IDE drive = /dev/hdc
Fourth IDE drive = /dev/hdd
 SCSI hard drive
小型电脑标准介面硬式磁盘机
SCSI CD/DVD drive
小型电脑标准介面 CD/数字化视频光磁盘
 First SCSI drive = /dev/sda
Second SCSI drive = /dev/sdb

Twenty-seventh SCSI drive = /dev/sdaa and so on
 Parallel port drives
平行埠驱动
 First IDE drive = /dev/pd1
First tape drive: /dev/pt1
 USB drives
万用串列总线驱动
 Varies widely
广泛地改变
 IEEE 1394 drives
电器和电子工程师协会 1394 磁盘
 IEEE 1394 (a.k.a. FireWire, iLink) is actually a SCSI standard, so these are controlled in Linux as SCSI devices
电器和电子工程师协会 1394(a.k.a.FireWire, iLink) 实际上是一个小型电脑标准介面标准, 因此这些当做小型电脑标准介面装置在 Linux 被控制

Making Reference to Devices in /dev
发展的因素关于的参考装置在 /dev

Take a look at the files in the /dev directory. Use the ls -l /dev | more command. Scroll through the long list for a while. Are you confused yet? Well, there's a method to this madnes
s. Some devices are linked to others, and that actually makes it easier to understand what is connected to what.
在那 /dev 目录中看一看文件。使用 ls-l/dev| 较多的指令。检视长的列表一阵子。你感到困扰吗?好吧,有一个方法至这疯狂。一些装置与其他相连, 而且实际上使了解什么被连接到比较容易什么。

For example, the virtual device files /dev/mouse and /dev/modem are easier to identify than the true device files.
举例来说,虚拟的装置申请 /dev/鼠标和 /比起真实的装置文件, dev/调制解调器比较容易识别。

Generally, these devices are automatically linked to the actual device files during Linux installation.
通常,这些装置自动地在 Linux 安装期间与真实的装置文件相连。

 For example, if you have a mouse and modem installed, the following commands illustrate possible links between these components and the actual device files:

 举例来说,如果你有,一个鼠标而且调制解调器安装,下列的指令举例说明这些元件和真实的装置文件之间的可能的联结:

# ls -l /dev/mouse
# ls-l/dev/鼠标
lrwxrwxrwx  1 root  root  5 Apr 18 12:17 /dev/mouse -> psaux
lrwxrwxrwx 1个根根 18 年四月 5 日 12:17/dev/鼠标 -> psaux
# ls -l /dev/modem
# ls-l/dev/调制解调器
lrwxrwxrwx  1 root  root  5 Apr 18 12:17 /dev/modem -> /dev/ttyS0
lrwxrwxrwx 1个根根 18 年四月 5 日 12:17/dev/调制解调器 ->/dev/ttyS 0

The first output shows that /dev/mouse is linked directly to the PS/2 device driver port, and that /dev/modem is linked directly to the first serial port, which corresponds to COM1 in the Microsoft world.
第一个输出表示那 /dev/鼠标直接地与 PS/2个驱动程序埠相连, 和哪一 /dev/调制解调器直接地与第一个序列埠,在微软公司世界中符合 COM1 相连。

Filesystem Formatting and Checking
Filesystem 格式而且检查

Three basic tools are available to manage the filesystem on various partitions: fdisk, mkfs, and fsck.
三个基本的工具可得在各种不同的分区上处理 filesystem:fdisk 、 mkfs 和 fsck。

They can help you configure partitions as well as create, and then check and repair, different filesystems.
 他们能帮助你配置分区和产生, 然后检验和修理,不同的 filesystems。

 As with the rest of this chapter, this section covers only the very basics; for more information, see the man page associated with each respective command tool.
 关于这一个章节的其余者,这一个区段只复盖最基本;对于较多的信息,见与每个分别的指令工具有关的帮助页。

fdisk

The Linux fdisk utility is a lot more versatile than its Microsoft counterpart.
Linux fdisk 公用程式比它的微软公司类似版本更用途广泛。

But to open it, you need to know the device file associated with the hard drive that you want to change.
 但是开启它, 你需要知道与你想要改变的硬式磁盘机有关的装置文件。

Identifying the hard disk device file is covered in Chapter 2.
 识别硬式磁盘装置文件在第 2 章被复盖。

 Assuming you want to manage the partitions on the first SCSI hard disk, enter the following command:

 假定你想要在第一个小型电脑标准介面硬式磁盘上处理分区, 进入下列的指令:

# fdisk /dev/sda

As you can see in Figure 1-3, the fdisk utility is flexible. Some key fdisk commands are described in Table 1-3.
当你能在图 1-3 见到, fdisk 公用程式是有柔性的。一些主要 fdisk 指令在表 1-3 被描述.

Table 1-3: Important fdisk Options 
表 1-3:重要的 fdisk 选择项

 fdisk Command
 Description描述
 a  Allows you to specify the bootable Linux partition (with /boot).
允许你指定可引导的Linux 分区
 l  Lists known partition types; fdisk can create partitions that conform to any of these filesystems.
知道分区的列表打字; fdisk 能产生遵照这些 filesystems 之中的任何一个的分区。
 n  Adds a new partition; works only if there is free space on the disk that hasn't already been allocated to an existing partition.
增加一个新的分区;只有当如果有自由空间在还没有已经被分派到一个现有的分区的磁盘上,工作。
 q  Quits without saving any changes.
 t  Changes the partition filesystem.
改变分区 filesystem

Figure 1-3: Linux fdisk commands; p returns the partition table
图 1-3: Linux fdisk 命令;p 返回分区表

mkfs

To format a Linux partition, apply the mkfs command.
为了要格式化一个 Linux 分区,应用 mkfs 指令。

It allows you to format a partition to a number of different filesystems.
 它让你格式化一个分区至一些不同的 filesystems 。

To format a typical partition such as /dev/hda2 to the current Red Hat standard, the third extended filesystem, run the following command:

 格式化一典型的分区如此的当做 /对目前的红帽标准,第三广大的 filesystem, 的 dev/hda 2 运行下列的指令:

# mkfs -t ext3 /dev/hda2

Inside The Exam
在考试内

Running as Root
当做根运行

Throughout the book, I'm assuming that you're running commands after having logged in as the root user.
在书各处, 我正在假定你正在有之后运行指令登录如根使用者。

While it may not be the best practice on the job, it can save you a little bit of time on the RHCT and RHCE exams.
 它可能不在作业上是最好的习惯,不过它能在 RHCT 和 RHCE 考试上替你省下一点时间。

For example, if you've logged in as a regular user, you'd start fdisk with the /sbin/fdisk command.
 举例来说,如果你已经登录如一个一般的使用者,你将会用那 /sbin/fdisk 指令启动 fdisk 。

This applies even if you've taken administrative privileges with the su command.
 即使你已经用 su 指令拿管理的特权,这应用。

 (I know, you could take administrative privileges with the root user PATH with the su - root command, but time is of the essence on these exams.)
 (我知道,你可以用根使用者路径以 su- 根的指令拿管理的特权,但是时间在这些考试上是本质。)

 On the other hand, if you log in as the root user, the default root $PATH variable, means all you need to type is fdisk.
 另一方面,如果你登录如根使用者,内定的根 $路径变数, 意谓全部你需要输入是 fdisk。

The mkfs command also serves as a 'front-end,' depending on the filesystem format.
mkfs 指令也视为仰赖 filesystem 格式的 '前端 ,' 。

 For example, if you're formatting a Red Hat standard ext3 filesystem, mkfs by itself automatically calls the mkfs.ext3 command.
 举例来说,如果你正在格式红帽标准 ext 3 filesystem , mkfs 独自自动地认为 mkfs.ext 是 3个指令。

 Therefore, if you're reformatting an ext3 filesystem, the following command is sufficient:
 因此,如果你正在再格式 ext 3 filesystem ,下列的指令是充份的:

# mkfs /dev/hda2

 On The Job  Be careful with the mkfs command.
 在作业上小心 mkfs 指令。

First, back up any data on the subject partition and computer.
 第一,在服从的分区和计算机上备存任何的数据。

This command erases all data on the specified partition.
 这指令在指定的分区上抹去所有的数据。

fsck

The fsck command is functionally similar to the Microsoft chkdsk command.
fsck 指令功能相似对微软公司 chkdsk 指令。

It analyzes the specified filesystem and performs repairs as required.
 它当做需要分析指定的 filesystem 而且执行修理。

 Assume you're having problems with files in the /var directory, which happens to be mounted on /dev/hda7.
 承担你有文件的问题在那 /变容体目录, 碰巧中被展开在 /之上dev/hda 7.

 If you want to run fsck, unmount that filesystem first.
 如果你想要运行 fsck, 不座哪一首先的 filesystem。

In some cases, you may need to go into single-user mode with the init 1 command before you can unmount a filesystem.
 在一些外壳,你可能需要进入单一从属模态与 init 1个指令,在你能不安装 filesystem 之前。

 To unmount, analyze, then remount the filesystem noted in this section, and run the following commands:
 为了要不安装,分析, 然后再骑上 filesystem 在这一个区段中注意, 而且运行下列的指令:

# umount /var

# fsck -t ext3 /dev/hda7

# mount /dev/hda7 /var

The fsck command also serves as a 'front-end,' depending on the filesystem format.
fsck 指令也视为仰赖 filesystem 格式的 '前端 ,' 。

For example, if you're formatting an ext2 or ext3 filesystem, fsck by itself automatically calls the e2fsck command (which works for both filesystems).
 举例来说,如果你正在格式 ext 2 或者 ext 3 filesystem, fsck 独自自动地呼叫 e 2个 fsck 指令 (哪一个为两者的 filesystems 工作).

Therefore, if you're checking an ext3 filesystem, once you unmount it with the umount command, the following command is sufficient:
 因此,如果你正在检查 ext 3 filesystem ,一经你用 umount 指令不安装它,下列的指令是充份的:

# fsck /dev/hda7

Multiple Partitions with One Filesystem
多个分区用一 Filesystem

The Logical Volume Manager (LVM) enables you to set up one filesystem on multiple partitions.
合乎逻辑的音量经理 (LVM) 使你能够在多个分区上建立一 filesystem 。

 For example, assume you're adding more users and are running out of room in your /home directory.
 举例来说,承担你正在增加较多的使用者而且在你的 /家目录中用光房间。

 You don't have any unpartitioned space available on your current hard disk.
 你没有任何的不分割空间从你的目前硬式磁盘可得。

With the LVM, all you need to do is add another hard disk, configure some partitions, back up /home, and use the LVM tools to combine the new partition and the one used by /home into a volume set.
藉由 LVM, 全部你需要做是增加另外的一个硬式磁盘,配置一些分区, 向后地在 /上面回家, 而且使用 LVM 工具联合新的分区和那一用被 /家进入被设定的一音量之内。

 You may need to install the LVM rpm package.
 你可能需要安装 LVM 转/每分软件包。

Once it is installed, the steps are fairly straightforward, as described in the following exercise:
 一经它被安装,步非常笔直,如下列的练习所描述:

Exercise 1-2: Creating a New LVM Partition
练习 1-2:创造新的 LVM 分割

Logical Volume Management (LVM) is new to RHEL 3 and is more important than the prerequisite skills covered in most of this chapter.
合乎逻辑的音量管理 (LVM) 对 RHEL 3 是新的而且比在这一个章节的大部分方面被复盖的预先非有不可的技术更重要。

 The latest available Red Hat Exam Prep guide includes LVM requirements on both parts of the RHCE exam.
 最近的可得红帽考试预科的指南在 RHCE 考试的两者部份上包括 LVM 需求。

For more information on LVM, see Chapters 3 and 11.
 对于关于 LVM 的较多资讯,见第 3 和 11 章。

Add a new hard disk.
增加一个新的硬式磁盘。

Create new partitions.
产生新的分区。

Assign the Linux LVM filesystem to one or more of these partitions.
 分配 Linux LVM filesystem 至一或更多个这些分区。

This can be easily done with the Linux fdisk utility.
 这能容易地与 Linux fdisk 公用程式一起做。

Back up /home.

 Assign the LVM filesystem to that partition.
 分配 LVM filesystem 到那分区。

Scan for Linux LVM filesystems with the vgscan utility, to create a database for other LVM commands.
为 Linux LVM filesystems 以 vgscan 公用程式扫瞄, 为其他的 LVM 指令产生一个数据库。

Create volumes for the set with the pvcreate /dev/partition command.
为组用 pvcreate/dev/分区指令产生音量。

Add the desired volumes to a specific volume group with the vgcreate groupname /dev/partition1 /dev/partition2 … command.
用 vgcreate groupname/dev/分区 1/dev/分区 2 把被需要的音量加入一个特定的音量组…指令。

Now you can create a logical volume.
现在你能产生一个合乎逻辑的音量。

 Use the lvcreate -L-xyM -n volname groupname command, where xy is the size of the volume, and groupname is the volume group name from the previous step.
 使用 lvcreate-xy 是音量的大小,而且 groupname 是来自早先的步的音量组名字的 L-xyM-n 的 volname groupname 指令。

Finally, you can format the logical volume with the mkfs command for the desired filesystem (usually ext2 or ext3), using the device name returned by the lvcreate command.
最后,你能为被需要的 filesystem(通常 ext 2 或 ext 3) 用 mkfs 指令格式化合乎逻辑的音量,使用被 lvcreate 指令退还的装置名字。

Mounting Partitions
架设分割

The mount command can be used to attach local and network partitions to specified directories.
座指令能被用附加局部,而且网络对指定的目录分割。

Mount points are not fixed; you can mount a CD drive or even a Samba share to any empty directory where you have appropriate permissions.
 座点没被修理;你能安装一个 CD 磁盘或者使一个桑巴舞共享相等至你有适当的许可的任何的空目录。

There are standard mount points based on the FHS.
有被基于 FHS 的标准座点。

The following commands mount a floppy with the VFAT filesystem, a CD formatted to the ISO 9660 filesystem, and a Zip drive.
 下列的指令安装一叭塌叭塌响的与 VFAT filesystem, 格式化的一个 CD 对 ISO 9660 filesystem 、和一个 ZIP 磁盘。

 The devices may be different on your system; if in doubt, look through the startup messages with dmesg | less.
 装置可能是不同的在你的系统上; 如果在怀疑方面,用 dmesg|比较少量看过启始信息。

# mount -t vfat /dev/fd0 /mnt/floppy
# mount -t iso9660 /dev/cdrom /mnt/cdrom
# mount /dev/sdc

 Exam Watch  The following section covers only the most basic of commands that you can use in Linux.
 考试表下列的区段只复盖那最你能在 Linux 使用的指令的基本。

It describes only a few of the things that you can do with each command.
 它描述只有少数的事物你能以每个指令做。

Unfortunately, a full discussion would require several hundred more pages.
 不幸地,完全的讨论会需要一些百较多的页。

 Expect to know considerably more about commands for the RHCE and RHCT exams.
 为 RHCE 和 RHCT 考试期待知道非常较多的有关指令的事。

If you feel a need for a more solid grounding in basic commands, get more information by reading Red Hat:The Complete Reference, Enterprise Linux & Fedora Edition, by Richard Petersen and Ibrahim Haddad.
 如果你感觉基本的指令的对一个比较坚硬的接地需要, 藉由读红帽得到较多的信息: 完全的参考,企业 Linux& 费多拉帽版本, 由理查 Petersen 和 Ibrahim Haddad。

作者: austin22   发布时间: 2007-03-31