-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
abby
committed
Mar 10, 2016
1 parent
ea96939
commit 40e477d
Showing
15 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
#### JFS | ||
|
||
JFS有IBM贡献给Linux内核,它因响应快(甚至是在极端条件下)而为人所知。它特别适合与网路附加储存(NAS)设备。JFS悠久的历史和长期的测试使得它成为Linux可用的最可靠的日志型文件系统之一。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
### 本地文件系统类型 | ||
|
||
Linux内核支持多种文件系统,它允许你在众多文件系统中挑选最适合你需求的。幸运的是,大部分默认的文件系统就足以满足你的需求。一些文件系统则倾向与特定的介质。例如,ISO9660文件系统仅用于CD和DVD介质。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
#### XFS | ||
|
||
XFS由SGI个公司为Linux内核贡献,它是对大容量和大文件支持最好的文件系统之一。XFS对内存的需求比其他文件系统要多些,但是如果你需要处理大文件的话,用多一点的内存换取更好的性能是值得的。XFS并不是很适合桌面电脑,它的亮点是在服务器上处理大中型文件。和ext3一样,XFS是完全的日志型文件系统。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
#### ext2 | ||
|
||
ext2是Slackware所包含的最古老的一个文件系统,它用来在磁盘上存放数据。想对于其它文件系统,ext2是很简单的。它在读写数据的速度上要比其他文件系统快些,但是它不包含日志功能。也就是说,如果出现故障,必须对文件系统进行全面的检查来发现和修复错误。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
#### ext3 | ||
|
||
ext3是ext2的升级版。它被设计来在大多数情况下替代ext2,虽然与ext2共享着许多相同的代码,但不同的是ext3增加了日志功能。由于ext3和ext2非常相似,所以可以从一个转换到另一个而不丢失数据。在遭遇灾难性的硬件故障时,有很多工具可用来从这个文件系统中回复数据。ext3是一个很好的有着日志支持的通用文件系统,但是在特定情况下,它却没有其他日志型文件系统一样的表现。ext3的一个缺陷是需要经常对文件系统进行彻底的检查。这通常是计算机启动过程中,文件文件系统被挂载后完成,因此为造成烦人的延迟。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
#### ext4 | ||
|
||
ext4是ext系列文件系统中最新的。它被设计来在ext3的基础上针对文件系统使用新的想法。虽然Slackware支持ext4,但是你应该记住这个文件系统还非常的新并且仍处于开发状态。如果你对稳定性的需求大于性能,你最好选一个其他文件系统,比如ext3。也就是说,虽然ext4相对于ext3的性能方面有着巨大的提升,但是许多人并不认为它适合稳定的使用。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
#### iso9660 | ||
|
||
iso9660是专门为光学介质比如CD和DVD设计的。由于光盘是只读介质,所以Linux内核并没有为这个文件系统提供写支持。如果要创建iso9660文件系统的话,你必须使用用户级的工具,比如`mkisofs(8)`或`growisofs(8)`。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
#### reiserfs | ||
|
||
reiserfs是另一个针对Linux内核的古老的日志型文件系统,并且Slackware对它的支持也有很多年了。它非常适合用来存放、读取和写入大量的小文件。可惜的是,当遭遇驱动器故障时没有多少工具可以用来恢复数据,而且它的故障率比ext3要高。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
#### swap | ||
|
||
和其它储存文件和目录的文件系统不一样,swap分区是用来存放虚拟内存的。swap是很有用的,因为它可以用来防止在内存耗尽是系统崩溃。当内存耗尽时内核将内存内容拷贝到swap然后释放内存来供其它程序使用。你可以把swap看作非常慢的内存。swap是典型的故障保护设施,不应该连续的依赖于使用它。如果你发现swap用的有点多的话,你还是多安装些内存吧。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
#### vfat | ||
|
||
有时你需要在Linux和Windows之间共享数据,但又不能通过网络传输。相反,你需要一个共享分区或USB驱动器。这时VFAT文件系统是最好的选择,因为大多数操作系统都支持它。但是,这个文件系统是由微软设计的,它和Linux上的文件系统不一样,它不会储存文件权限。这意味着,必须为多个用户能访问到这个文件系统上的数据而开启特殊的选项。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,23 @@ | ||
#### NFS | ||
|
||
NFS是为Linux和其他操作系统提供的网络文件系统。它的性能一般,但是支持完整的权限。要将NFS作为客户端或者服务端,你必须运行远程过程调用守护程序。这可以简单的通过赋予`/etc/rc.d/rc.rpc`文件可执行权限然后运行它搞定。一旦它被设置为可执行,那么它将在你每次启动Slackware是自动运行。 | ||
```plain | ||
darkstar:~# chmod +x /etc/rc.d/rc.rpc | ||
darkstar:~# /etc/rc.d/rc.rpc start | ||
``` | ||
挂载NFS共享和挂载本地文件系统有点不同。不是给`mount`一个本地设备,而是你必须告诉`mount`NFS服务器的域名或者IP以及要挂载的目录,这两者用冒号隔开。 | ||
```plain | ||
darkstar:~# mount -t nfs darkstar.example.com:/home /home | ||
``` | ||
|
||
运行NFS服务端又有一点不同。首先,你需要在`/etc/exports`中配置每个要导出的目录。`exports(5)`包含了用来共享的目录的信息,以及和谁共享,共享的权限是怎样的。 | ||
```plain | ||
# See exports(5) for a description. | ||
# This file contains a list of all directories exported to other computers. | ||
# It is used by rpc.nfsd and rpc.mountd. | ||
/home/backup 192.168.1.0/24(sync,rw,no_root_squash) | ||
``` | ||
`exports`中的第一列是要通过NFS导出的文件列表。第二列是可以访问导出文件的系统及其所需的权限的列表。你可以使用域名、IP或者网络块地址(本例)来指定主机。特殊的权限总是一个括号列表。你可以从`man`手册中获取它的完整列表。到目前为止,只有一个特殊选项`[no_root_squash]`需要注意。通常NFS客户端上的root用户对一个导出的共享既不能读也不能写。反而root用户被“压缩”了,并且被强制表现来nobody用户一样。而`[no_root_squash]`选项会防止这个现象。 | ||
|
||
同时你还需要运行NFS守护程序。启动和停止NFS服务可以通过`/etc/rc.d/rc.ndfd`这个脚本来完成。你也可以给这个脚本可执行权限使它想`rc.rpc`那样运行。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
### 网络文件系统 | ||
|
||
除了本地文件系统,Slackware还支持多种网络文件系统包括服务器端和客户端。这使得你可以在多个计算机之间透明的共享数据。下面我们将讨论两个最常见的:NFS和SMB。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,12 @@ | ||
#### SMB | ||
|
||
SMB是Windows网络文件共享协议。连接到一个SMB共享(通常称为samba共享)是非常简单的。然而SMB不像NFS那样被很好的支持。但是,它在Windows计算机之间提供了更高的性能和可连接性。基于此,SMB是部署在本地网络中最常用的网络文件共享协议。在Slackware中导出SMB共享是由samba守护进程和`smb.conf`完成的。然而,如何配置samba服务超出本书的讨论范围中。可以在线查找额外的文档,也可以查看`man`手册来获取更多信息。 | ||
|
||
挂载SMB共享和挂载NFS一样简单。你只需要以哦那个样的方式告诉`mount`服务器的位置以及你想访问的东西。此外,你还必须指定一个用户名和密码。 | ||
```plain | ||
darkstar:~# mount -t cifs //darkstar/home /home -o username=alan,password=secret | ||
``` | ||
|
||
你可能会好奇为什么文件系统类型是cifs而不是smbfs。在旧版的Linux内核中用的是smbfs。然而它已被废弃,取而代之的是有着更好性能更安全的通用cifs驱动。 | ||
|
||
所有的SMB共享都需要用户名和密码参数。如果你把你的samba共享写在`fstab`的话,这可能产生一个安全问题。你可以使用`[credentials]`参数来避免这点。`[credentials]`指向一个包含用户名和密码的文件。只要这个文件的安全性有保障并且只有root可读,你身份凭证被损害的可能性就会降低。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,25 @@ | ||
### 文件系统的层次 | ||
|
||
Slackware Linux将所有的文件和目录都存放在单个/目录下,这个目录叫作"根"。这和微软的Windows不一样。不同的硬盘分区、CD-ROM、USE驱动器,甚至是软盘都可以挂在到/下,但是没有“驱动器号”一样的东西。这些设备的内容几乎随处可见,但是Slackware为你设置了一些理智的默认值。例如,CD-RW驱动器通常放在`/mnt/CD-RW`。以下是Slackware中常见的目录。 | ||
|
||
表11.1 文件系统布局 | ||
|
||
|路径|描述| | ||
|:---|:---| | ||
|/|根目录,容纳所有东西的地方| | ||
|/bin|为所有用户提供的二进制程序的集合| | ||
|/boot|内核、initrd以及其他和启动相关的东西| | ||
|/etc|系统配置文件| | ||
|/dev|允许直接访问硬件的特殊文件集合| | ||
|/home|存放用户个人文件和设置的目录| | ||
|/media|DBUS/HAL自动挂载的目录| | ||
|/mnt|临时挂载可移动媒体的目录| | ||
|/opt|某些专用软件的安装目录| | ||
|/proc|存放进程信息的虚拟文件系统| | ||
|/root|root用户的家目录| | ||
|/sbin|超级用户所使用的二进制程序集合| | ||
|/srv|存放网站数据| | ||
|/sys|内核信息的虚拟文件系统| | ||
|/tmp|存放所有用户临时文件| | ||
|/usr|存放所有非必要文件、库以及共享文件的目录| | ||
|/var|存放经常变化的数据,例如日志文件| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,42 @@ | ||
### 使用mount指令 | ||
|
||
现在我们知道了Linux中可用的几种文件系统,是时候来看看怎样使用它们了。要想向一个文件系统写数据,这个文件系统必须首先被挂载。要挂载文件系统,我们可以使用`mount(8)`。我们首先要做的是决定文件系统挂载到哪儿。再次强调,Linux世界中没有驱动器号。而是所有的文件系统都挂载在目录上。在你安装的Slackware上基本文件系统总是位于`/`且其它的东西总是位于`/`的子目录中。`/mnt/hd`是一个常用来挂载分区的地方,我们把它用在第一个例子中。要挂在一个文件系统,我们必须告诉`mount`文件系统的类型,要挂载的位置以及其他特殊的选项。 | ||
|
||
```plain | ||
darkstar:~# mount -t ext3 /dev/hda3 /mnt/hd -o ro | ||
``` | ||
|
||
我们来解读一下。我们有一个ext3文件系统在IDE设备的第三个分区,我们想把它挂载到`/mnt/hd`。此外,我们把它挂载为只读,这样就不会改变它的内容了。`[-t ext3]`参数告诉`mount`我们用的文件系统是什么类型,在本例中是`ext3`。这将告诉内核该使用那个驱动。通常`mount`会自行检查文件系统类型,但是最好还是显示的声明我们的分区类型。第二参数告诉`mount`我们想挂载的的位置,本例中是`/mnt/hd`。最后,我们必须决定要使用的参数,这些参数以`[-o]`开始声明。下面是最常用选项的简短列表。 | ||
|
||
表11.2 常用的挂载选项 | ||
|
||
|选项|描述| | ||
|:--|:--| | ||
|ro| 只读| | ||
|rw| 读写(默认值)| | ||
|uid| 拥有此文件系统内容的用户| | ||
|gid| 拥有此文件系统内容的组| | ||
|noexec| 阻止执行此文件系统上的任何文件| | ||
|defaults| 大多数文件系统通用的默认值| | ||
|
||
如果这是你第一次安装Linux,你只需要关心`[ro]`和`[rw]`选项。有个例外是当你要处理不具有Linux权限机制的文件系统时,比如`vfat`或者`NTFS`,你需要使用`[uid]`或`[gid]`选项来确保非root用户能够访问这些文件系统。 | ||
```plain | ||
darkstar:~# mount -t vfat /dev/hda4 /mnt/hd -o uid=alan | ||
``` | ||
但是我们不想每次加载CD时都告诉`mount`是什么文件系统,用什么选项,这会很烦。幸好有个简单的办法,`/etc/fstab`这个文件包含了安装器为你设置的所有文件系统的信息,你也可以向里面添加东西。`fstab(5)`看起来是一个包含了设备、文件系统以及可选参数的简单表格。我们来看看。 | ||
```plain | ||
darkstar:~# cat /etc/fstab | ||
/dev/hda1 / reiserfs defaults 1 1 | ||
/dev/hda2 /home reiserfs defaults 1 2 | ||
/dev/hda3 swap swap defaults 0 0 | ||
/dev/cdrom /mnt/cdrom auto noauto,owner,ro,users 0 0 | ||
/dev/fd0 /mnt/floppy auto noauto,owner 0 0 | ||
devpts /dev/pts devpts gid=5,mode=620 0 0 | ||
proc /proc proc defaults 0 0 | ||
``` | ||
如果在`fstab`中有你的文件系统入口的话,你只需要告诉`mount`设备节点或者挂载位置就行了。 | ||
```plain | ||
darkstar:~# mount /dev/cdrom | ||
darkstar:~# mount /home | ||
``` | ||
关于`mount`需要最后告诉你的是,你只需要运行`mount`而不加任何参数就能看到已经挂载的文件系统了。 |