mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-01-28 23:20:10 +08:00
add content
This commit is contained in:
parent
525a6cec35
commit
465667c284
@ -160,55 +160,55 @@ EXT 文件系统实现了数据分配策略以确保产生最少的文件碎片
|
||||
|
||||
[EXT3 文件系统][25] 具有克服 **fsck** 程序需要完全恢复在文件更新操作期间发生的不正确关机损坏的磁盘结构所需的大量时间的单一目标。EXT 文件系统的唯一新增是 [日志][26],它将提前记录将对文件系统执行的更改。 磁盘结构的其余部分与 EXT2 中的相同。
|
||||
|
||||
作为一个先前的版本,除了直接写入数据到磁盘的数据区域外,EXT3 的日志在写入元数据时同时也写入文件数据到磁盘上的一个指定数据区域。一旦这些数据安全地到达硬盘,它就可以几乎零丢失率地被合并或者被追加到目标文件。当这些数据被提交到磁盘上的数据区域上,这些日志就会随即更新,这样在系统发生故障之前,文件系统将保持一致状态,才能提交日志中的所有数据。在下次启动时,将检查文件系统的不一致性,然后将日志中保留的数据提交到磁盘的数据区,以完成对目标文件的更新。
|
||||
作为一个先前的版本,除了直接写入数据到磁盘的数据区域外,EXT3 的日志在写入元数据时同时会也写入文件数据到磁盘上的一个指定数据区域。一旦这些数据安全地到达硬盘,它就可以几乎零丢失率地被合并或者被追加到目标文件。当这些数据被提交到磁盘上的数据区域上,这些日志就会随即更新,这样在系统发生故障之前,文件系统将保持一致状态,才能提交日志中的所有数据。在下次启动时,将检查文件系统的不一致性,然后将日志中保留的数据提交到磁盘的数据区,以完成对目标文件的更新。
|
||||
|
||||
Journaling does reduce data-write performance, however there are three options available for the journal that allow the user to choose between performance and data integrity and safety. My personal preference is on the side of safety because my environments do not require heavy disk-write activity.
|
||||
日记功能确实降低了数据写入性能,但是有三个可用于日志的选项,允许用户在性能和数据完整性和安全性之间进行选择。 我的个人更偏向于选择安全性,因为我的环境不需要大量的磁盘写入活动。
|
||||
|
||||
The journaling function reduces the time required to check the hard drive for inconsistencies after a failure from hours (or even days) to mere minutes, at the most. I have had many issues over the years that have crashed my systems. The details could fill another article, but suffice it to say that most were self-inflicted, like kicking out a power plug. Fortunately, the EXT journaling filesystems have reduced that bootup recovery time to two or three minutes. In addition, I have never had a problem with lost data since I started using EXT3 with journaling.
|
||||
日志功能减少了在从几小时(甚至几天)到几分钟之间的失败后检查硬盘驱动器所需的时间。 多年来,我遇到了很多问题导致了我的系统崩溃。 要详细说的话恐怕还得再写一篇文章,但这足以说明大多数是我自己造成的,就比如不小心踢掉一个电源插头。 幸运的是,EXT日志文件系统将启动恢复时间缩短到两三分钟。 此外,自从我开始使用带日志记录的EXT3,我从来没有遇到丢失数据的问题。
|
||||
|
||||
The journaling feature of EXT3 can be turned off and it then functions as an EXT2 filesystem. The journal itself still exists, empty and unused. Simply remount the partition with the mount command using the type parameter to specify EXT2\. You may be able to do this from the command line, depending upon which filesystem you are working with, but you can change the type specifier in the **/etc/fstab** file and then reboot. I strongly recommend against mounting an EXT3 filesystem as EXT2 because of the additional potential for lost data and extended recovery times.
|
||||
EXT3 的日志功能可以关闭,然后作为 EXT2 文件系统。 该日志本身仍然是存在的,只是状态为空且未使用。 只需使用类型参数使用 mount 命令来 remount 到分区即可指定EXT2 \。 你可以从命令行执行此操作,但是具体还是取决于你正在使用的文件系统,但你可以更改 **/ etc / fstab** 文件中的类型说明符,然后重新启动。 我强烈建议不要将 EXT3文件系统安装为 EXT2 ,因为这会具有丢失数据和增加恢复时间的潜在可能性。
|
||||
|
||||
An existing EXT2 filesystem can be upgraded to EXT3 with the addition of a journal using the following command.
|
||||
EXT2 文件系统可以使用如下命令来通过日志升级到 EXT3 。
|
||||
|
||||
```
|
||||
tune2fs -j /dev/sda1
|
||||
```
|
||||
|
||||
Where **/dev/sda1** is the drive and partition identifier. Be sure to change the file type specifier in **/etc/fstab** and remount the partition or reboot the system to have the change take effect.
|
||||
**/dev/sda1** 表示驱动和分区的标识符。同时要注意修改 **/etc/fstab** 中的文件类型标识符并 remount 分区或者重启系统以确保修改生效。
|
||||
|
||||
### EXT4
|
||||
|
||||
The [EXT4 filesystem][27] primarily improves performance, reliability, and capacity. To improve reliability, metadata and journal checksums were added. To meet various mission-critical requirements, the filesystem timestamps were improved with the addition of intervals down to nanoseconds. The addition of two high-order bits in the timestamp field defers the [Year 2038 problem][28] until 2446—for EXT4 filesystems, at least.
|
||||
[EXT4 filesystem][27]主要提高了性能、可靠性和容量。位了提高可靠性,它新增了元数据和日志校验和。同时位了满足各种关键任务要求,文件系统新增了纳秒级别的时间戳。在时间戳字段中添加两个高位来延迟时间戳的 [2038 年的问题][28] ,在 EXT4 文件系统至少可达到 2446 年。
|
||||
|
||||
In EXT4, data allocation was changed from fixed blocks to extents. An extent is described by its starting and ending place on the hard drive. This makes it possible to describe very long, physically contiguous files in a single inode pointer entry, which can significantly reduce the number of pointers required to describe the location of all the data in larger files. Other allocation strategies have been implemented in EXT4 to further reduce fragmentation.
|
||||
在 EXT4 中,数据分配从固定块更改为盘区,盘区由硬盘驱动器上的开始和结束位置来描述。这使得可以在单个 inode 指针条目中描述非常长的物理连续的文件,这可以显着减少描述大文件中所有数据的位置所需的指针数。 EXT4 中已经实施了其他分配策略,以进一步减少碎片化。
|
||||
|
||||
EXT4 reduces fragmentation by scattering newly created files across the disk so that they are not bunched up in one location at the beginning of the disk, as many early PC filesystems did. The file-allocation algorithms attempt to spread the files as evenly as possible among the cylinder groups and, when fragmentation is necessary, to keep the discontinuous file extents as close as possible to others in the same file to minimize head seek and rotational latency as much as possible. Additional strategies are used to pre-allocate extra disk space when a new file is created or when an existing file is extended. This helps to ensure that extending the file will not automatically result in its becoming fragmented. New files are never allocated immediately after existing files, which also prevents fragmentation of the existing files.
|
||||
EXT4 通过将新创建的文件分散在磁盘上,从而使其不会全部聚集在磁盘起始位置,就像早期的PC文件系统一样,减少了碎片。文件分配算法尝试在柱面组中尽可能均匀地扩展文件,并且当需要分段时,要使不连续文件扩展区尽可能靠近同一文件中的其他文件,以尽可能减少头部搜索和旋转等待时间尽可能的当创建新文件或扩展现有文件时,使用其他策略来预分配额外的磁盘空间。这有助于确保扩展文件不会自动导致其分段。新文件不会在现有文件之后立即分配,这也可以防止现有文件的碎片化。
|
||||
|
||||
Aside from the actual location of the data on the disk, EXT4 uses functional strategies, such as delayed allocation, to allow the filesystem to collect all the data being written to the disk before allocating space to it. This can improve the likelihood that the data space will be contiguous.
|
||||
除了磁盘上数据的实际位置外,EXT4 使用诸如延迟分配的功能策略,以允许文件系统在分配空间之前收集正在写入磁盘的所有数据。这可以提高数据空间将是连续的可能性。
|
||||
|
||||
Older EXT filesystems, such as EXT2 and EXT3, can be mounted as EXT4 to make some minor performance gains. Unfortunately, this requires turning off some of the important new features of EXT4, so I recommend against this.
|
||||
较旧的EXT文件系统(如 EXT2 和 EXT3)可以作为 EXT4 进行 mount ,以使其性能获得较小的提升。不幸的是,这需要关闭 EXT4 的一些重要的新功能,所以我建议不要这样做。
|
||||
|
||||
EXT4 has been the default filesystem for Fedora since Fedora 14\. An EXT3 filesystem can be upgraded to EXT4 using the [procedure ][29]described in the Fedora documentation, however its performance will still suffer due to residual EXT3 metadata structures. The best method for upgrading to EXT4 from EXT3 is to back up all the data on the target filesystem partition, use the **mkfs** command to write an empty EXT4 filesystem to the partition, and then restore all the data from the backup.
|
||||
自 Fedora 14 以来,EXT4 一直是 Fedora 的默认文件系统。我们可以使用 Fedora 文档中描述的 [procedure ][29] 将EXT3文件系统升级到EXT4,但是由于之前仍然存留d的 EXT3 元数据结构,它的性能仍将受到影响。从 EXT3 升级到 EXT4 的最佳方法是备份目标文件系统分区上的所有数据,使用 **mkfs** 命令将空EXT4文件系统写入分区,然后从备份中恢复所有数据。
|
||||
|
||||
### Inode
|
||||
|
||||
The inode, described previously, is a key component of the metadata in EXT filesystems. Figure 2 shows the relationship between the inode and the data stored on the hard drive. This diagram is the directory and inode for a single file which, in this case, may be highly fragmented. The EXT filesystems work actively to reduce fragmentation, so it is very unlikely you will ever see a file with this many indirect data blocks or extents. In fact, as you will see below, fragmentation is extremely low in EXT filesystems, so most inodes will use only one or two direct data pointers and none of the indirect pointers.
|
||||
以前描述的 inode 是EXT文件系统中的元数据的关键组件。 图 2 显示了 inode 和存储在硬盘驱动器上的数据之间的关系。 该图是单个文件的目录和 inode,在这种情况下,可能会产生高度碎片。 EXT 文件系统可以积极地减少碎片,所以不太可能会看到有这么多间接数据块或扩展盘的文件。 实际上,如下所示,EXT文件系统中的碎片非常低,所以大多数 inode 只使用一个或两个直接数据指针,也不使用间接指针。
|
||||
|
||||
![inodesanddataallocation-01_0.png](https://opensource.com/sites/default/files/images/life-uploads/inodesanddataallocation-01_0.png)
|
||||
|
||||
Figure 2: The inode stores information about each file and enables the EXT filesystem to locate all data belonging to it.
|
||||
图 2 :inode 存储有关每个文件的信息,并使 EXT 文件系统能够查找属于它的所有数据。
|
||||
|
||||
The inode does not contain the name of the file. Access to a file is via the directory entry, which itself is the name of the file and contains a pointer to the inode. The value of that pointer is the inode number. Each inode in a filesystem has a unique ID number, but inodes in other filesystems on the same computer (and even the same hard drive) can have the same inode number. This has implications for [links][30], and this discussion is beyond the scope of this article.
|
||||
inode 不包含文件的名称。通过目录条目访问文件,目录条目本身是文件的名称,并包含指向 inode 的指针。该指针的值是 inode 号。文件系统中的每个 inode 都具有唯一的 ID 号,但同一台计算机上的其他文件系统(甚至相同的硬盘驱动器)中的 inode 可以具有相同的 inode 号。这对[links][30] 存在影响,但是这个讨论超出了本文的范围。
|
||||
|
||||
The inode contains the metadata about the file, including its type and permissions as well as its size. The inode also contains space for 15 pointers that describe the location and length of data blocks or extents in the data portion of the cylinder group. Twelve of the pointers provide direct access to the data extents and should be sufficient to handle most files. However, for files that have significant fragmentation, it becomes necessary to have some additional capabilities in the form of indirect nodes. Technically these are not really inodes, so I use the term "node" here for convenience.
|
||||
inod e包含有关该文件的元数据,包括其类型和权限以及其大小。 inode 还包含 15 个指针的空格,用于描述柱面组数据部分中数据块或扩展区的位置和长度。十二个指针提供对数据扩展区的直接访问,并且应该足以处理大多数文件。然而,对于具有重大分段的文件,有必要以间接节点的形式具有一些附加功能。从技术上讲,这些不是真正的节点,所以我在这里使用这个术语“节点”来方便。
|
||||
|
||||
An indirect node is a normal data block in the filesystem that is used only for describing data and not for storage of metadata, thus more than 15 entries can be supported. For example, a block size of 4K can support 512 4-byte indirect nodes, allowing **12 (direct) + 512 (indirect) = 524** extents for a single file. Double and triple indirect node support is also supported, but most of us are unlikely to encounter files requiring that many extents.
|
||||
间接节点是文件系统中的正常数据块,它仅用于描述数据而不用于存储元数据,因此可以支持超过 15 个条目。例如,4K 的块大小可以支持 512 个 4 字节间接节点,允许单个文件的 **12(直接)+ 512(间接)= 524** 范围。还支持双重和三重间接节点支持,但我们大多数人不太可能遇到需要许多扩展的文件。
|
||||
|
||||
### Data fragmentation
|
||||
### 数据碎片
|
||||
|
||||
For many older PC filesystems, such as FAT (and all its variants) and NTFS, fragmentation has been a significant problem resulting in degraded disk performance. Defragmentation became an industry in itself with different brands of defragmentation software that ranged from very effective to only marginally so.
|
||||
对于许多较旧的 PC 文件系统,如 FAT(及其所有变体)和 NTFS,碎片一直是导致磁盘性能下降的重大问题。 碎片整理对于其本身和一些专门的整理软件来说已经称为了一项专门的工程,其效果范围从非常有效到仅仅是微乎其微。
|
||||
|
||||
Linux's extended filesystems use data-allocation strategies that help to minimize fragmentation of files on the hard drive and reduce the effects of fragmentation when it does occur. You can use the **fsck** command on EXT filesystems to check the total filesystem fragmentation. The following example checks the home directory of my main workstation, which was only 1.5% fragmented. Be sure to use the **-n** parameter, because it prevents **fsck** from taking any action on the scanned filesystem.
|
||||
Linux 的扩展文件系统使用数据分配策略,有助于最小化硬盘驱动器上的文件碎片,并在发生碎片时减少碎片的影响。 你可以使用 EXT 文件系统上的 **fsck** 命令检查文件系统的整体碎片。 以下示例检查主工作站的主目录,只有 1.5% 的碎片。 确保使用 **- n** 参数,因为它会阻止 **fsck** 对扫描文件系统采取的任何操作。
|
||||
|
||||
```
|
||||
fsck -fn /dev/mapper/vg_01-home
|
||||
|
Loading…
Reference in New Issue
Block a user