mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-02-06 23:50:16 +08:00
commit
403691ba66
218
published/20150316 Linux on UEFI A Quick Installation Guide.md
Normal file
218
published/20150316 Linux on UEFI A Quick Installation Guide.md
Normal file
@ -0,0 +1,218 @@
|
||||
详解 UEFI 模式下安装 Linux
|
||||
============================================================
|
||||
|
||||
> 此页面是免费浏览的,没有烦人的外部广告;然而,我的确花了时间准备,网站托管也花了钱。如果您发现此页面帮到了您,请考虑进行小额[捐款](http://www.rodsbooks.com/linux-uefi/),以帮助保持网站的运行。谢谢!
|
||||
> 原著于 2013/10/19;最后修改于 2015/3/16
|
||||
|
||||
### 引言
|
||||
|
||||
几年来,一种新的固件技术悄然出现,而大多数普通用户对此并无所知。该技术被称为 [ <ruby>可扩展固件接口<rt>Extensible Firmware Interface</rt></ruby>][29](EFI), 或更新一些的统一可扩展固件接口(Unified EFI,UEFI,本质上是 EFI 2.x),它已经开始替代古老的[<ruby>基本输入/输出系统<rt>Basic Input/Output System</rt></ruby>][30](BIOS)固件技术,有经验的计算机用户或多或少都有些熟悉 BIOS。
|
||||
|
||||
本页面是给 Linux 用户使用 EFI 技术的一个快速介绍,其中包括有关开始将 Linux 安装到此类计算机上的建议。不幸的是,EFI 是一个庞杂的话题;EFI 软件本身是复杂的,许多实现有系统特定的怪异行为甚至是缺陷。因此,我无法在一个页面上描述在 EFI 计算机上安装和使用 Linux 的一切知识。我希望你能将本页面作为一个有用的起点,不管怎么说,每个部分以及末尾[参考文献][31]部分的链接可以指引你找到更多的文档。
|
||||
|
||||
### 你的计算机是否使用 EFI 技术?
|
||||
|
||||
EFI 是一种_固件_,意味着它是内置于计算机中处理低级任务的软件。最重要的是,固件控制着计算机的引导过程,反过来说这代表着基于 EFI 的计算机与基于 BIOS 的计算机的引导过程不同。(有关此规律的例外之处稍后再说。)这种差异可能使操作系统安装介质的设计超级复杂化,但是一旦安装好并运行之后,它对计算机的日常操作几乎没有影响。请注意,大多数制造商使用术语 “BIOS” 来表示他们的 EFI。我认为这种用法很混乱,所以我避免了;在我看来,EFI 和 BIOS 是两种不同类型的固件。
|
||||
|
||||
> **注意:**苹果公司的 Mac 使用的 EFI 在许多方面是不同寻常的。尽管本页面的大部分内容同样适用于 Mac,但有些细节上的出入,特别是在设置 EFI 引导加载程序的时候。这个任务最好在 OS X 上进行,使用 Mac 的 [bless utility][49]工具,我不在此做过多描述。
|
||||
|
||||
自从 2006 年第一次推出以来,EFI 已被用于基于英特尔的 Mac 上。从 2012 年底开始,大多数安装 Windows 8 或更高版本系统的计算机就已经默认使用 UEFI 启动,实际上大多数 PC 从 2011 年中期就开始使用 UEFI,虽然默认情况下它们可能无法以 EFI 模式启动。2011 年前销出的 PC 也有一些支持 EFI,尽管它们大都默认使用 BIOS 模式启动。
|
||||
|
||||
如果你不确定你的计算机是否支持 EFI,则应查看固件设置实用程序和参考用户手册关于 _EFI_、_UEFI_ 以及 _legacy booting_ 的部分。(可以通过搜索用户手册的 PDF 文件来快速了解。)如果你没有找到类似的参考,你的计算机可能使用老式的(“legacy”) BIOS 引导;但如果你找到了这些术语的参考,几乎可以肯定它使用了 EFI 技术。你还可以尝试_只_有 EFI 模式的引导加载器的安装介质。使用 [rEFInd][50] 制作的 USB 闪存驱动器或 CD-R 镜像是用来测试不错的选择。
|
||||
|
||||
在继续之前,你应当了解大多数 x86 和 x86-64 架构的计算机上的 EFI 都包含一个叫做<ruby>兼容支持模块<rt>Compatibility Support Module</rt></ruby>(CSM)的组件,这使得 EFI 能够使用旧的 BIOS 风格的引导机制来引导操作系统。这会非常方便,因为它向后兼容;但是这样也导致一些意外情况的发生,因为计算机不论以 EFI 模式引导还是以 BIOS (也称为 CSM 或 legacy)模式引导,在控制时没有标准的使用规范和用户界面。特别地,你的 Linux 安装介质非常容易意外的以 BIOS/CSM/legacy 模式启动,这会导致 Linux 以 BIOS/CSM/legacy 模式安装。如果 Linux 是唯一的操作系统,也可以正常工作,但是如果与在 EFI 模式下的 Windows 组成双启动的话,就会非常复杂。(反过来问题也可能发生。)以下部分将帮助你以正确模式引导安装程序。如果你在阅读这篇文章之前就已经以 BIOS 模式安装了 Linux,并且希望切换引导模式,请阅读后续章节,[哎呀:将传统模式下安装的引导转为 EFI 模式下的引导][51]。
|
||||
|
||||
UEFI 的一个附加功能值得一提:<ruby>安全启动<rt>Secure Boot</rt></ruby>。此特性旨在最大限度的降低计算机受到 _boot kit_ 病毒感染的风险,这是一种感染计算机引导加载程序的恶意软件。Boot kits 很难检测和删除,阻止它们的运行刻不容缓。微软公司要求所有带有支持 Windows 8 标志的台式机和笔记本电脑启用 安全启动。这一配置使 Linux 的安装变得复杂,尽管有些发行版可以较好的处理这个问题。不要将安全启动和 EFI 或 UEFI 混淆;支持 EFI 的计算机不一定支持 安全启动,而且支持 EFI 的 x86-64 的计算机也可以禁用 安全启动。微软同意用户在 Windows 8 认证的 x86 和 x86-64 计算机上禁用安全启动功能;然而对装有 Windows 8 的 ARM 计算机而言却相反,它们必须**不允许**用户禁用 安全启动。幸运的是,基于 ARM 的 Windows 8 计算机目前很少见。我建议避免使用它们。
|
||||
|
||||
### 你的发行版是否支持 EFI 技术?
|
||||
|
||||
大多数 Linux 发行版已经支持 EFI 好多年了。然而,不同的发行版对 EFI 的支持程度不同。大多数主流发行版(Fedora,OpenSUSE,Ubuntu 等)都能很好的支持 EFI,包括对安全启动的支持。另外一些“自行打造”的发行版,比如 Gentoo,对 EFI 的支持较弱,但它们的性质使其很容易添加 EFI 支持。事实上,可以向_任意_ Linux 发行版添加 EFI 支持:你需要安装 Linux(即使在 BIOS 模式下),然后在计算机上安装 EFI 引导加载程序。有关如何执行此操作的信息,请参阅[哎呀:将传统模式下安装的引导转为 EFI 模式下的引导][52]部分。
|
||||
|
||||
你应当查看发行版的功能列表,来确定它是否支持 EFI。你还应当注意你的发行版对安全启动的支持情况,特别是如果你打算和 Windows 8 组成双启动。请注意,即使正式支持安全启动的发行版也可能要求禁用此功能,因为 Linux 对安全启动的支持通常很差劲,或者导致意外情况的发生。
|
||||
|
||||
### 准备安装 Linux
|
||||
|
||||
下面几个准备步骤有助于在 EFI 计算机上 Linux 的安装,使其更加顺利:
|
||||
|
||||
#### 1、 升级固件
|
||||
|
||||
有些 EFI 是有问题的,不过硬件制造商偶尔会发布其固件的更新。因此我建议你将固件升级到最新可用的版本。如果你从论坛的帖子知道自己计算机的 EFI 有问题,你应当在安装 Linux 之前更新它,因为如果安装 Linux 之后更新固件,会有些问题需要额外的操作才能解决。另一方面,升级固件是有一定风险的,所以如果制造商提供了 EFI 支持,最好的办法就是按它们提供的方式进行升级。
|
||||
|
||||
#### 2、 了解如何使用固件
|
||||
|
||||
通常你可以通过在引导过程之初按 Del 键或功能键进入固件设置实用程序。按下开机键后尽快查看相关的提示信息,或者尝试每个功能键。类似的,ESC 键或功能键通常可以进入固件的内置引导管理器,可以选择要进入的操作系统或外部设备。一些制造商把这些设置隐藏的很深。在某些情况下,如[此页面][32]所述,你可以在 Windows 8 内做到这些。
|
||||
|
||||
#### 3、调整以下固件设置
|
||||
|
||||
* **快速启动** — 此功能可以通过在硬件初始化时使用快捷方式来加快引导过程。这很好用,但有时候会使 USB 设备不能初始化,导致计算机无法从 USB 闪存驱动器或类似的设备启动。因此禁用快速启动_可能_有一定的帮助,甚至是必须的;你可以让它保持激活,而只在 Linux 安装程序启动遇到问题时将其停用。请注意,此功能有时可能会以其它名字出现。在某些情况下,你必须_启用_ USB 支持,而不是_禁用_快速启动功能。
|
||||
* **安全启动** — Fedora,OpenSUSE,Ubuntu 以及其它的发行版官方就支持安全启动;但是如果在启动引导加载程序或内核时遇到问题,可能需要禁用此功能。不幸的是,没办法具体描述怎么禁用,因为不同计算机的设置方法也不同。请参阅[我的安全启动页面][1]获取更多关于此话题的信息。
|
||||
|
||||
> **注意:** 一些教程说安装 Linux 时需要启用 BIOS/CSM/legacy 支持。通常情况下,这样做是错的。启用这些支持可以解决启动安装程序涉及的问题,但也会带来新的问题。以这种方式安装的教程通常可以通过“引导修复”来解决这些问题,但最好从一开始就做对。本页面提供了帮助你以 EFI 模式启动 Linux 安装程序的提示,从而避免以后的问题。
|
||||
* **CSM/legacy 选项** — 如果你想以 EFI 模式安装,请_关闭_这些选项。一些教程推荐启用这些选项,有时这是必须的 —— 比如,有些附加视频卡需要在固件中启用 BIOS 模式。尽管如此,大多数情况下启用 CSM/legacy 支持只会无意中增加以 BIOS 模式启动 Linux 的风险,但你并_不想_这样。请注意,安全启动和 CSM/legacy 选项有时会交织在一起,因此更改任一选项之后务必检查另一个。
|
||||
|
||||
#### 4、 禁用 Windows 的快速启动功能
|
||||
|
||||
[这个页面][33]描述了如何禁用此功能,不禁用的话会导致文件系统损坏。请注意此功能与固件的快速启动不同。
|
||||
|
||||
#### 5、 检查分区表
|
||||
|
||||
使用 [GPT fdisk][34]、parted 或其它任意分区工具检查磁盘分区。理想情况下,你应该创建一个包含每个分区确切起点和终点(以扇区为单位)的纸面记录。这会是很有用的参考,特别是在安装时进行手动分区的时候。如果已经安装了 Windows,确定可以识别你的 [EFI 系统分区(ESP)][35],它是一个 FAT 分区,设置了“启动标记”(在 parted 或 Gparted 中)或在 gdisk 中的类型码为 EF00。
|
||||
|
||||
### 安装 Linux
|
||||
|
||||
大部分 Linux 发行版都提供了足够的安装说明;然而我注意到了在 EFI 模式安装中的几个常见的绊脚石:
|
||||
|
||||
* **确保使用正确位深的发行版** — EFI 启动加载器和 EFI 自身的位深相同。现代计算机通常是 64 位,尽管最初几代基于 Intel 的 Mac、一些现代的平板电脑和变形本、以及一些鲜为人知的电脑使用 32 位 EFI。虽然可以将 32 位 EFI 引导加载程序添加至 32 位发行版,但我还没有遇到过正式支持 32 位 EFI 的 Linux 发行版。(我的 《[在 Linux 上管理 EFI 引导加载程序][36]》 一文概述了引导加载程序,而且理解了这些原则你就可以修改 32 位发行版的安装程序,尽管这不是一个初学者该做的。)在 64 位 EFI 的计算机上安装 32 位发行版最让人头疼,我不准备在这里描述这一过程;在具有 64 位 EFI 的计算机上,你应当使用 64 位的发行版。
|
||||
* **正确准备引导介质** — 将 .iso 镜像传输到 USB 闪存驱动器的第三方工具,比如 unetbootin,在创建正确的 EFI 模式引导项时经常失败。我建议按照发行版维护者的建议来创建 USB 闪存驱动器。如果没有类似的建议,使用 Linux 的 dd 工具,通过执行 `dd if=image.iso of=/dev/sdc` 在识别为 `/dev/sdc` 的 USB 闪存驱动器上创建一个镜像。至于 Windows,有 [WinDD][37] 和 [dd for windows][38],但我从没测试过它们。请注意,使用不兼容 EFI 的工具创建安装介质是错误的,这会导致人们进入在 BIOS 模式下安装然后再纠正它们的误区,所以不要忽视这一点!
|
||||
* **备份 ESP 分区** — 如果计算机已经存在 Windows 或者其它的操作系统,我建议在安装 Linux 之前备份你的 ESP 分区。尽管 Linux _不应该_ 损坏 ESP 分区已有的文件,但似乎这时不时发生。发生这种事情时备份会有很大用处。只需简单的文件级的备份(使用 cp,tar,或者 zip 类似的工具)就足够了。
|
||||
* **以 EFI 模式启动** — 以 BIOS/CSM/legacy 模式引导 Linux 安装程序的意外非常容易发生,特别是当固件启用 CSM/legacy 选项时。下面一些提示可以帮助你避免此问题:
|
||||
* 进入 Linux shell 环境执行 `ls /sys/firmware/efi` 验证当前是否处于 EFI 引导模式。如果你看到一系列文件和目录,表明你已经以 EFI 模式启动,而且可以忽略以下多余的提示;如果没有,表明你是以 BIOS 模式启动的,应当重新检查你的设置。
|
||||
* 使用固件内置的引导管理器(你应该已经知道在哪;请参阅[了解如何使用固件][26])使之以 EFI 模式启动。一般你会看到 CD-R 或 USB 闪存驱动器两个选项,其中一个选项包括 _EFI_ 或 _UEFI_ 字样的描述,另一个不包括。使用 EFI/UEFI 选项来启动介质。
|
||||
* 禁用安全启动 - 即使你使用的发行版官方支持安全启动,有时它们也不能生效。在这种情况下,计算机会静默的转到下一个引导加载程序,它可能是启动介质的 BIOS 模式的引导加载程序,导致你以 BIOS 模式启动。请参阅我的[安全启动的相关文章][27]以得到禁用安全启动的相关提示。
|
||||
* 如果 Linux 安装程序总是无法以 EFI 模式启动,试试用我的 [rEFInd 引导管理器][28] 制作的 USB 闪存驱动器或 CD-R。如果 rEFInd 启动成功,那它保证是以 EFI 模式运行的,而且在基于 UEFI 的 PC 上,它只显示 EFI 模式的引导项,因此若您启动到 Linux 安装程序,则应处于 EFI 模式。(但是在 Mac 上,除了 EFI 模式选项之外,rEFInd 还显示 BIOS 模式的引导项。)
|
||||
* **准备 ESP 分区** — 除了 Mac,EFI 使用 ESP 分区来保存引导加载程序。如果你的计算机已经预装了 Windows,那么 ESP 分区就已存在,可以在 Linux 上直接使用。如果不是这样,那么我建议创建一个大小为 550 MB 的 ESP 分区。(如果你已有的 ESP 分区比这小,别担心,直接用就行。)在此分区上创建一个 FAT32 文件系统。如果你使用 Gparted 或者 parted 准备 ESP 分区,记得给它一个“启动标记”。如果你使用 GPT fdisk(gdisk,cgdisk 或 sgdisk)准备 ESP 分区,记得给它一个名为 EF00 的类型码。有些安装程序会创建一个较小的 ESP 分区,并且设置为 FAT16 文件系统。尽管这样能正常工作,但如果你之后需要重装 Windows,安装程序会无法识别 FAT16 文件系统的 ESP 分区,所以你需要将其备份后转为 FAT32 文件系统。
|
||||
* **使用 ESP 分区** — 不同发行版的安装程序以不同的方式辨识 ESP 分区。比如,Debian 和 Ubuntu 的某些版本把 ESP 分区称为“EFI boot partition”,而且不会明确显示它的挂载点(尽管它会在后台挂载);但是有些发行版,像 Arch 或 Gentoo,需要你去手动挂载。尽管将 ESP 分区挂载到 /boot 进行相应配置后可以正常工作,特别是当你想使用 gummiboot 或 ELILO(译者注:gummiboot 和 ELILO 都是 EFI 引导工具)时,但是在 Linux 中最标准的 ESP 分区挂载点是 /boot/efi。某些发行版的 /boot 不能用 FAT 分区。因此,当你设置 ESP 分区挂载点时,请将其设置为 /boot/efi。除非 ESP 分区没有,否则_不要_为其新建文件系统 — 如果已经安装 Windows 或其它操作系统,它们的引导文件都在 ESP 分区里,新建文件系统会销毁这些文件。
|
||||
* **设置引导程序的位置** — 某些发行版会询问将引导程序(GRUB)装到何处。如果 ESP 分区按上述内容正确标记,不必理会此问题,但有些发行版仍会询问。请尝试使用 ESP 分区。
|
||||
* **其它分区** — 除了 ESP 分区,不再需要其它的特殊分区;你可以设置 根(/)分区,swap 分区,/home 分区,或者其它分区,就像你在 BIOS 模式下安装时一样。请注意 EFI 模式下_不需要设置_[BIOS 启动分区][39],所以如果安装程序提示你需要它,意味着你可能意外的进入了 BIOS 模式。另一方面,如果你创建了 BIOS 启动分区,会更灵活,因为你可以安装 BIOS 模式下的 GRUB,然后以任意模式(EFI 模式 或 BIOS 模式)引导。
|
||||
* **解决无显示问题** — 2013 年,许多人在 EFI 模式下经常遇到(之后出现的频率逐渐降低)无显示的问题。有时可以在命令行下通过给内核添加 `nomodeset` 参数解决这一问题。在 GRUB 界面按 `e` 键会打开一个简易文本编辑器。大多数情况下你需要搜索有关此问题的更多信息,因为此问题更多是由特定硬件引起的。
|
||||
|
||||
在某些情况下,你可能不得不以 BIOS 模式安装 Linux。但你可以手动安装 EFI 引导程序让 Linux 以 EFI 模式启动。请参阅《 [在 Linux 上管理 EFI 引导加载程序][53]》 页面获取更多有关它们以及如何安装的可用信息。
|
||||
|
||||
### 解决安装后的问题
|
||||
|
||||
如果 Linux 无法在 EFI 模式下工作,但在 BIOS 模式下成功了,那么你可以完全放弃 EFI 模式。在只有 Linux 的计算机上这非常简单;安装 BIOS 引导程序即可(如果你是在 BIOS 模式下安装的,引导程序也应随之装好)。如果是和 EFI 下的 Windows 组成双系统,最简单的方法是安装我的 [rEFInd 引导管理器][54]。在 Windows 上安装它,然后编辑 `refind.conf` 文件:取消注释 `scanfor` 一行,并确保拥有 `hdbios` 选项。这样 rEFInd 在引导时会重定向到 BIOS 模式的引导项。
|
||||
|
||||
如果重启后计算机直接进入了 Windows,很可能是 Linux 的引导程序或管理器安装不正确。(但是应当首先尝试禁用安全启动;之前提到过,它经常引发各种问题。)下面是关于此问题的几种可能的解决方案:
|
||||
|
||||
* **使用 efibootmgr** — 你可以以 _EFI 模式_引导一个 Linux 急救盘,使用 efibootmgr 实用工具尝试重新注册你的 Linux 引导程序,如[这里][40]所述。
|
||||
* **使用 Windows 上的 bcdedit** — 在 Windows 管理员命令提示符窗口中,输入 `bcdedit /set {bootmgr}path \EFI\fedora\grubx64.efi` 会用 ESP 分区的 `EFI/fedora/grubx64.efi` 文件作为默认的引导加载程序。根据需要更改此路径,指向你想设置的引导文件。如果你启用了安全启动,需要设置 `shim.efi`,`shimx64.efi` 或者 `PreLoader.efi`(不管有哪个)为引导而不是 `grubx64.efi`。
|
||||
* **安装 rEFInd** — 有时候 rEFInd 可以解决这个问题。我推荐使用 [CD-R 或者 USB 闪存驱动器][41]进行测试。如果 Linux 可以启动,就安装 Debian 软件包、RPM 程序,或者 .zip 文件包。(请注意,你需要在一个高亮的 Linux vmlinuz* 选项按两次 `F2` 或 `Insert` 修改启动选项。如果你的启动分区是单独的,这就更有必要了,因为这种情况下,rEFInd 无法找到根(/)分区,也就无法传递参数给内核。)
|
||||
* **使用修复引导程序** — Ubuntu 的[引导修复实用工具][42]可以自动修复一些问题;然而,我建议只在 Ubuntu 和 密切相关的发行版上使用,比如 Mint。有时候,有必要通过高级选项备份并替换 Windows 的引导。
|
||||
* **劫持 Windows 引导程序** — 有些不完整的 EFI 引导只能引导 Windows,就是 ESP 分区上的 `EFI/Microsoft/Boot/bootmgfw.efi` 文件。因此,你可能需要将引导程序改名(我建议将其移动到上级目录 `EFI/Microsoft/bootmgfw.efi`),然后将首选引导程序复制到这里。(大多数发行版会在 EFI 的子目录放置 GRUB 的副本,例如 Ubuntu 的 EFI/ubuntu,Fedora 的 EFI/fedora。)请注意此方法是个丑陋的解决方法,有用户反映 Windows 会替换引导程序,所以这个办法不是 100% 有效。然而,这是在不完整的 EFI 上生效的唯一办法。在尝试之前,我建议你升级固件并重新注册自己的引导程序,Linux 上用 efibootmgr,Windows 上用 bcdedit。
|
||||
|
||||
有关引导程序的其它类型的问题 - 如果 GRUB(或者你的发行版默认的其它引导程序或引导管理器)没有引导操作系统,你必须修复这个问题。因为 GRUB 2 引导 Windows 时非常挑剔,所以 Windows 经常启动失败。在某些情况下,安全启动会加剧这个问题。请参阅[我的关于 GRUB 2 的页面][55]获取一个引导 Windows 的 GRUB 2 示例。还会有很多原因导致 Linux 引导出现问题,类似于 BIOS 模式下的情况,所以我没有全部写出来。
|
||||
|
||||
尽管 GRUB 2 使用很普遍,但我对它的评价却不高 - 它很复杂,而且难以配置和使用。因此,如果你在使用 GRUB 的时候遇到了问题,我的第一反应就是用别的东西代替。[我的用于 Linux 的 EFI 引导程序页面][56]有其它的选择。其中包括我的 [rEFInd 引导管理器][57],它除了能够让许多发行版上的 GRUB 2 工作,也更容易安装和维护 - 但是它还不能完全代替 GRUB 2。
|
||||
|
||||
除此之外,EFI 引导的问题可能很奇怪,所以你需要去论坛发帖求助。尽量将问题描述完整。[Boot Info Script][58] 可帮助你提供有用的信息 - 运行此脚本,将生成的名为 RESULTS.txt 的文件粘贴到论坛的帖子上。一定要将文本粘贴到 `[code]` 和 `[/code]` 之间;不然会遭人埋怨。或者将 RESULTS.txt 文件上传到 pastebin 网站上,比如 [pastebin.com][59],然后将网站给你的 URL 地址发布到论坛。
|
||||
|
||||
### 哎呀:将传统模式下安装的系统转为 EFI 模式下引导
|
||||
|
||||
**警告:**这些指南主要用于基于 UEFI 的 PC。如果你的 Mac 已经安装了 BIOS 模式下的 Linux,但想以 EFI 模式启动 Linux,可以_在 OS X_ 中安装引导程序。rEFInd(或者旧式的 rEFIt)是 Mac 上的常用选择,但 GRUB 可以做的更多。
|
||||
|
||||
论坛上有很多人看了错误的教程,在已经存在 EFI 模式的 Windows 的情况下,安装了 BIOS 引导的 Linux,这一问题在 2015 年初很普遍。这样配置效果很不好,因为大多数 EFI 很难在两种模式之间切换,而且 GRUB 也无法胜任这项工作。你可能会遇到不完善的 EFI 无法启动外部介质的情况,也可能遇到 EFI 模式下的显示问题,或者其它问题。
|
||||
|
||||
如前所述,在[解决安装后的问题][60]部分,解决办法之一就是_在 Windows_ 上安装 rEFInd,将其配置为支持 BIOS 模式引导。然后可以引导 rEFInd 并链式引导到你的 BIOS 模式的 GRUB。在 Linux 上遇到 EFI 特定的问题时,例如无法使用显卡,我建议你使用这个办法修复。如果你没有这样的 EFI 特定的问题,在 Windows 中安装 rEFInd 和合适的 EFI 文件系统驱动可以让 Linux 直接以 EFI 模式启动。这个解决方案很完美,它和我下面描述的内容等同。
|
||||
|
||||
大多数情况下,最好将 Linux 配置为以 EFI 模式启动。有很多办法可以做到,但最好的是使用 Linux 的 EFI 引导模式(或者,可以想到,Windows,或者一个 EFI shell)注册到你首选的引导管理器。实现这一目标的方法如下:
|
||||
|
||||
1. 下载适用于 USB 闪存驱动器或 CD-R 的 [rEFInd 引导管理器][43]。
|
||||
2. 从下载的镜像文件生成安装介质。可以在任何计算机上准备,不管是 EFI 还是 BIOS 的计算机都可以(或者在其它平台上使用其它方法)。
|
||||
3. 如果你还没有这样做,[请禁用安全启动][44]。因为 rEFInd CD-R 和 USB 镜像不支持安全启动,所以这很必要,你可以在以后重新启用它。
|
||||
4. 在目标计算机上启动 rEFInd。如前所述,你可能需要调整固件设置,并使用内置引导管理器选择要引导的介质。你选择的那一项也许在其描述中包含 _UEFI_ 这样的字符串。
|
||||
5. 在 rEFInd 上测试引导项。你应该至少看到一个启动 Linux 内核的选项(名字含有 vmlinuz 这样的字符串)。有两种方法可以启动它:
|
||||
* 如果你_没有_独立的 `/boot` 分区,只需简单的选择内核并按回车键。Linux 就会启动。
|
||||
* 如果你_确定有_一个独立的 `/boot` 分区,按两次 `Insert` 或 `F2` 键。这样会打开一个行编辑器,你可以用它来编辑内核选项。增加一个 `root=` 格式以标识根(/)文件系统,如果根(/)分区在 `/dev/sda5` 上,就添加 `root=/dev/sda5`。如果不知道根文件系统在哪里,那你需要重启并尽可能想到办法。
|
||||
|
||||
在一些罕见的情况下,你可能需要添加其它内核选项来代替或补充 `root=` 选项。比如配置了 LVM(LCTT 译注:Logical Volume Manager,逻辑卷管理)的 Gentoo 就需要 `dolvm` 选项。
|
||||
6. Linux 一旦启动,安装你想要的引导程序。rEFInd 的安装很简单,可以通过 RPM、Debian 软件包、PPA,或从[rEFInd 下载页面][45]下载的二进制 .zip 文件进行安装。在 Ubuntu 和相关的发行版上,引导修改程序可以相对简单地修复你的 GRUB 设置,但你要对它有信心可以正常工作。(它通常工作良好,但有时候会把事情搞得一团糟。)另外一些选项都在我的 《[在 Linux 上管理 EFI 引导加载程序][46]》 页面上。
|
||||
7. 如果你想在安全启动激活的情况下引导,只需重启并启用它。但是,请注意,可能需要额外的安装步骤才能将引导程序设置为使用安全启动。有关详细信息,请参阅[我关于这个主题的页面][47]或你的引导程序有关安全启动的文档资料。
|
||||
|
||||
重启时,你可以看到刚才安装的引导程序。如果计算机进入了 BIOS 模式下的 GRUB,你应当进入固件禁用 BIOS/CSM/legacy 支持,或调整引导顺序。如果计算机直接进入了 Windows,那么你应当阅读前一部分,[解决安装后的问题][61]。
|
||||
|
||||
你可能想或需要调整你的配置。通常是为了看到额外的引导选项,或者隐藏某些选项。请参阅引导程序的文档资料,以了解如何进行这些更改。
|
||||
|
||||
### 参考和附加信息
|
||||
|
||||
* **信息网页**
|
||||
* 我的 《[在 Linux 上管理 EFI 引导加载程序][2]》 页面含有可用的 EFI 引导程序和引导管理器。
|
||||
* [OS X's bless tool 的手册页][3] 页面在设置 OS X 平台上的引导程序或引导管理器时可能会很有用。
|
||||
* [EFI 启动过程][4] 描述了 EFI 启动时的大致框架。
|
||||
* [Arch Linux UEFI wiki page][5] 有大量关于 UEFI 和 Linux 的详细信息。
|
||||
* 亚当·威廉姆森写的一篇不错的 《[什么是 EFI,它是怎么工作的][6]》。
|
||||
* [这个页面][7] 描述了如何从 Windows 8 调整 EFI 的固件设置。
|
||||
* 马修·J·加勒特是 Shim 引导程序的开发者,此程序支持安全启动,他维护的[博客][8]经常更新有关 EFI 的问题。
|
||||
* 如果你对 EFI 软件的开发感兴趣,我的 《[EFI 编程][9]》 页面可以为你起步助力。
|
||||
* **附加程序**
|
||||
* [rEFInd 官网][10]
|
||||
* [gummiboot 官网][11]
|
||||
* [ELILO 官网][12]
|
||||
* [GRUB 官网][13]
|
||||
* [GPT fdisk 分区软件官网][14]
|
||||
* Ubuntu 的 [引导修复实用工具][15]可帮助解决一些引启动问题
|
||||
* **交流**
|
||||
* [Sourceforge 上的 rEFInd 交流论坛][16]是 rEFInd 用户互相交流或与我联系的一种方法。
|
||||
* Pastebin 网站,比如 [http://pastebin.com][17], 是在 Web 论坛上与其他用户交换大量文本的一种便捷的方法。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.rodsbooks.com/linux-uefi/
|
||||
|
||||
作者:[Roderick W. Smith][a]
|
||||
译者:[fuowang](https://github.com/fuowang)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:rodsmith@rodsbooks.com
|
||||
[1]:http://www.rodsbooks.com/efi-bootloaders/secureboot.html#disable
|
||||
[2]:http://www.rodsbooks.com/efi-bootloaders/
|
||||
[3]:http://ss64.com/osx/bless.html
|
||||
[4]:http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/efi-boot-process.html
|
||||
[5]:https://wiki.archlinux.org/index.php/Unified_Extensible_Firmware_Interface
|
||||
[6]:https://www.happyassassin.net/2014/01/25/uefi-boot-how-does-that-actually-work-then/
|
||||
[7]:http://www.eightforums.com/tutorials/20256-uefi-firmware-settings-boot-inside-windows-8-a.html
|
||||
[8]:http://mjg59.dreamwidth.org/
|
||||
[9]:http://www.rodsbooks.com/efi-programming/
|
||||
[10]:http://www.rodsbooks.com/refind/
|
||||
[11]:http://freedesktop.org/wiki/Software/gummiboot
|
||||
[12]:http://elilo.sourceforge.net/
|
||||
[13]:http://www.gnu.org/software/grub/
|
||||
[14]:http://www.rodsbooks.com/gdisk/
|
||||
[15]:https://help.ubuntu.com/community/Boot-Repair
|
||||
[16]:https://sourceforge.net/p/refind/discussion/
|
||||
[17]:http://pastebin.com/
|
||||
[18]:http://www.rodsbooks.com/linux-uefi/#intro
|
||||
[19]:http://www.rodsbooks.com/linux-uefi/#isitefi
|
||||
[20]:http://www.rodsbooks.com/linux-uefi/#distributions
|
||||
[21]:http://www.rodsbooks.com/linux-uefi/#preparing
|
||||
[22]:http://www.rodsbooks.com/linux-uefi/#installing
|
||||
[23]:http://www.rodsbooks.com/linux-uefi/#troubleshooting
|
||||
[24]:http://www.rodsbooks.com/linux-uefi/#oops
|
||||
[25]:http://www.rodsbooks.com/linux-uefi/#references
|
||||
[26]:http://www.rodsbooks.com/linux-uefi/#using_firmware
|
||||
[27]:http://www.rodsbooks.com/efi-bootloaders/secureboot.html#disable
|
||||
[28]:http://www.rodsbooks.com/refind/getting.html
|
||||
[29]:https://en.wikipedia.org/wiki/Uefi
|
||||
[30]:https://en.wikipedia.org/wiki/BIOS
|
||||
[31]:http://www.rodsbooks.com/linux-uefi/#references
|
||||
[32]:http://www.eightforums.com/tutorials/20256-uefi-firmware-settings-boot-inside-windows-8-a.html
|
||||
[33]:http://www.eightforums.com/tutorials/6320-fast-startup-turn-off-windows-8-a.html
|
||||
[34]:http://www.rodsbooks.com/gdisk/
|
||||
[35]:http://en.wikipedia.org/wiki/EFI_System_partition
|
||||
[36]:http://www.rodsbooks.com/efi-bootloaders
|
||||
[37]:https://sourceforge.net/projects/windd/
|
||||
[38]:http://www.chrysocome.net/dd
|
||||
[39]:https://en.wikipedia.org/wiki/BIOS_Boot_partition
|
||||
[40]:http://www.rodsbooks.com/efi-bootloaders/installation.html
|
||||
[41]:http://www.rodsbooks.com/refind/getting.html
|
||||
[42]:https://help.ubuntu.com/community/Boot-Repair
|
||||
[43]:http://www.rodsbooks.com/refind/getting.html
|
||||
[44]:http://www.rodsbooks.com/efi-bootloaders/secureboot.html#disable
|
||||
[45]:http://www.rodsbooks.com/refind/getting.html
|
||||
[46]:http://www.rodsbooks.com/efi-bootloaders/
|
||||
[47]:http://www.rodsbooks.com/efi-bootloaders/secureboot.html
|
||||
[48]:mailto:rodsmith@rodsbooks.com
|
||||
[49]:http://ss64.com/osx/bless.html
|
||||
[50]:http://www.rodsbooks.com/refind/getting.html
|
||||
[51]:http://www.rodsbooks.com/linux-uefi/#oops
|
||||
[52]:http://www.rodsbooks.com/linux-uefi/#oops
|
||||
[53]:http://www.rodsbooks.com/efi-bootloaders/
|
||||
[54]:http://www.rodsbooks.com/refind/
|
||||
[55]:http://www.rodsbooks.com/efi-bootloaders/grub2.html
|
||||
[56]:http://www.rodsbooks.com/efi-bootloaders
|
||||
[57]:http://www.rodsbooks.com/refind/
|
||||
[58]:http://sourceforge.net/projects/bootinfoscript/
|
||||
[59]:http://pastebin.com/
|
||||
[60]:http://www.rodsbooks.com/linux-uefi/#troubleshooting
|
||||
[61]:http://www.rodsbooks.com/linux-uefi/#troubleshooting
|
@ -0,0 +1,384 @@
|
||||
大数据初步:在树莓派上通过 Apache Spark on YARN 搭建 Hadoop 集群
|
||||
===
|
||||
|
||||
有些时候我们想从 DQYDJ 网站的数据中分析点有用的东西出来,在过去,我们要[用 R 语言提取固定宽度的数据](https://dqydj.com/how-to-import-fixed-width-data-into-a-spreadsheet-via-r-playing-with-ipums-cps-data/),然后通过数学建模来分析[美国的最低收入补贴](http://dqydj.com/negative-income-tax-cost-calculator-united-states/),当然也包括其他优秀的方法。
|
||||
|
||||
今天我将向你展示对大数据的一点探索,不过有点变化,使用的是全世界最流行的微型电脑————[树莓派](https://www.raspberrypi.org/),如果手头没有,那就看下一篇吧(可能是已经处理好的数据),对于其他用户,请继续阅读吧,今天我们要建立一个树莓派 Hadoop集群!
|
||||
|
||||
### I. 为什么要建立一个树莓派的 Hadoop 集群?
|
||||
|
||||
![](https://dqydj.com/wp-content/uploads/2016/08/IMG_9132-245x300.png)
|
||||
|
||||
*由三个树莓派节点组成的 Hadoop 集群*
|
||||
|
||||
我们对 DQYDJ 的数据做了[大量的处理工作](https://dqydj.com/finance-calculators-investment-calculators-and-visualizations/),但这些还不能称得上是大数据。
|
||||
|
||||
和许许多多有争议的话题一样,数据的大小之别被解释成这样一个笑话:
|
||||
|
||||
> 如果能被内存所存储,那么它就不是大数据。 ————佚名
|
||||
|
||||
似乎这儿有两种解决问题的方法:
|
||||
|
||||
1. 我们可以找到一个足够大的数据集合,任何家用电脑的物理或虚拟内存都存不下。
|
||||
2. 我们可以买一些不用特别定制,我们现有数据就能淹没它的电脑:
|
||||
|
||||
—— 上手树莓派 2B
|
||||
|
||||
这个由设计师和工程师制作出来的精致小玩意儿拥有 1GB 的内存, MicroSD 卡充当它的硬盘,此外,每一台的价格都低于 50 美元,这意味着你可以花不到 250 美元的价格搭建一个 Hadoop 集群。
|
||||
|
||||
或许天下没有比这更便宜的入场券来带你进入大数据的大门。
|
||||
|
||||
### II. 制作一个树莓派集群
|
||||
|
||||
我最喜欢制作的原材料。
|
||||
|
||||
这里我将给出我原来为了制作树莓派集群购买原材料的链接,如果以后要在亚马逊购买的话你可先这些链接收藏起来,也是对本站的一点支持。(谢谢)
|
||||
|
||||
- [树莓派 2B 3 块](http://amzn.to/2bEFTVh)
|
||||
- [4 层亚克力支架](http://amzn.to/2bTo1br)
|
||||
- [6 口 USB 转接器](http://amzn.to/2bEGO8g),我选了白色 RAVPower 50W 10A 6 口 USB 转接器
|
||||
- [MicroSD 卡](http://amzn.to/2cguV9I),这个五件套 32GB 卡非常棒
|
||||
- [短的 MicroUSB 数据线](http://amzn.to/2bX2mwm),用于给树莓派供电
|
||||
- [短网线](http://amzn.to/2bDACQJ)
|
||||
- 双面胶,我有一些 3M 的,很好用
|
||||
|
||||
#### 开始制作
|
||||
|
||||
1. 首先,装好三个树莓派,每一个用螺丝钉固定在亚克力面板上。(看下图)
|
||||
2. 接下来,安装以太网交换机,用双面胶贴在其中一个在亚克力面板上。
|
||||
3. 用双面胶贴将 USB 转接器贴在一个在亚克力面板使之成为最顶层。
|
||||
4. 接着就是一层一层都拼好——这里我选择将树莓派放在交换机和USB转接器的底下(可以看看完整安装好的两张截图)
|
||||
|
||||
想办法把线路放在需要的地方——如果你和我一样购买力 USB 线和网线,我可以将它们卷起来放在亚克力板子的每一层
|
||||
|
||||
现在不要急着上电,需要将系统烧录到 SD 卡上才能继续。
|
||||
|
||||
#### 烧录 Raspbian
|
||||
|
||||
按照[这个教程](https://www.raspberrypi.org/downloads/raspbian/)将 Raspbian 烧录到三张 SD 卡上,我使用的是 Win7 下的 [Win32DiskImager][2]。
|
||||
|
||||
将其中一张烧录好的 SD 卡插在你想作为主节点的树莓派上,连接 USB 线并启动它。
|
||||
|
||||
#### 启动主节点
|
||||
|
||||
这里有[一篇非常棒的“Because We Can Geek”的教程](http://www.becausewecangeek.com/building-a-raspberry-pi-hadoop-cluster-part-1/),讲如何安装 Hadoop 2.7.1,此处就不再熬述。
|
||||
|
||||
在启动过程中有一些要注意的地方,我将带着你一起设置直到最后一步,记住我现在使用的 IP 段为 192.168.1.50 – 192.168.1.52,主节点是 .50,从节点是 .51 和 .52,你的网络可能会有所不同,如果你想设置静态 IP 的话可以在评论区看看或讨论。
|
||||
|
||||
一旦你完成了这些步骤,接下来要做的就是启用交换文件,Spark on YARN 将分割出一块非常接近内存大小的交换文件,当你内存快用完时便会使用这个交换分区。
|
||||
|
||||
(如果你以前没有做过有关交换分区的操作的话,可以看看[这篇教程](https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04),让 `swappiness` 保持较低水准,因为 MicroSD 卡的性能扛不住)
|
||||
|
||||
现在我准备介绍有关我的和“Because We Can Geek”关于启动设置一些微妙的区别。
|
||||
|
||||
对于初学者,确保你给你的树莓派起了一个正式的名字——在 `/etc/hostname` 设置,我的主节点设置为 ‘RaspberryPiHadoopMaster’ ,从节点设置为 ‘RaspberryPiHadoopSlave#’
|
||||
|
||||
主节点的 `/etc/hosts` 配置如下:
|
||||
|
||||
```
|
||||
#/etc/hosts
|
||||
127.0.0.1 localhost
|
||||
::1 localhost ip6-localhost ip6-loopback
|
||||
ff02::1 ip6-allnodes
|
||||
ff02::2 ip6-allrouters
|
||||
|
||||
192.168.1.50 RaspberryPiHadoopMaster
|
||||
192.168.1.51 RaspberryPiHadoopSlave1
|
||||
192.168.1.52 RaspberryPiHadoopSlave2
|
||||
```
|
||||
|
||||
如果你想让 Hadoop、YARN 和 Spark 运行正常的话,你也需要修改这些配置文件(不妨现在就编辑)。
|
||||
|
||||
这是 `hdfs-site.xml`:
|
||||
|
||||
```
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
|
||||
<configuration>
|
||||
<property>
|
||||
<name>fs.default.name</name>
|
||||
<value>hdfs://RaspberryPiHadoopMaster:54310</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>hadoop.tmp.dir</name>
|
||||
<value>/hdfs/tmp</value>
|
||||
</property>
|
||||
</configuration>
|
||||
```
|
||||
|
||||
这是 `yarn-site.xml` (注意内存方面的改变):
|
||||
|
||||
```
|
||||
<?xml version="1.0"?>
|
||||
<configuration>
|
||||
|
||||
<!-- Site specific YARN configuration properties -->
|
||||
<property>
|
||||
<name>yarn.nodemanager.aux-services</name>
|
||||
<value>mapreduce_shuffle</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>yarn.nodemanager.resource.cpu-vcores</name>
|
||||
<value>4</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>yarn.nodemanager.resource.memory-mb</name>
|
||||
<value>1024</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>yarn.scheduler.minimum-allocation-mb</name>
|
||||
<value>128</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>yarn.scheduler.maximum-allocation-mb</name>
|
||||
<value>1024</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>yarn.scheduler.minimum-allocation-vcores</name>
|
||||
<value>1</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>yarn.scheduler.maximum-allocation-vcores</name>
|
||||
<value>4</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>yarn.nodemanager.vmem-check-enabled</name>
|
||||
<value>false</value>
|
||||
<description>Whether virtual memory limits will be enforced for containers</description>
|
||||
</property>
|
||||
<property>
|
||||
<name>yarn.nodemanager.vmem-pmem-ratio</name>
|
||||
<value>4</value>
|
||||
<description>Ratio between virtual memory to physical memory when setting memory limits for containers</description>
|
||||
</property>
|
||||
<property>
|
||||
<name>yarn.resourcemanager.resource-tracker.address</name>
|
||||
<value>RaspberryPiHadoopMaster:8025</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>yarn.resourcemanager.scheduler.address</name>
|
||||
<value>RaspberryPiHadoopMaster:8030</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>yarn.resourcemanager.address</name>
|
||||
<value>RaspberryPiHadoopMaster:8040</value>
|
||||
</property>
|
||||
</configuration>
|
||||
```
|
||||
|
||||
`slaves`:
|
||||
|
||||
```
|
||||
RaspberryPiHadoopMaster
|
||||
RaspberryPiHadoopSlave1
|
||||
RaspberryPiHadoopSlave2
|
||||
```
|
||||
|
||||
`core-site.xml`:
|
||||
|
||||
```
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
|
||||
<configuration>
|
||||
<property>
|
||||
<name>fs.default.name</name>
|
||||
<value>hdfs://RaspberryPiHadoopMaster:54310</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>hadoop.tmp.dir</name>
|
||||
<value>/hdfs/tmp</value>
|
||||
</property>
|
||||
</configuration>
|
||||
```
|
||||
|
||||
#### 设置两个从节点:
|
||||
|
||||
接下来[按照 “Because We Can Geek”上的教程](http://www.becausewecangeek.com/building-a-raspberry-pi-hadoop-cluster-part-2/),你需要对上面的文件作出小小的改动。 在 `yarn-site.xml` 中主节点没有改变,所以从节点中不必含有这个 `slaves` 文件。
|
||||
|
||||
### III. 在我们的树莓派集群中测试 YARN
|
||||
|
||||
如果所有设备都正常工作,在主节点上你应该执行如下命令:
|
||||
|
||||
```
|
||||
start-dfs.sh
|
||||
start-yarn.sh
|
||||
```
|
||||
|
||||
当设备启动后,以 Hadoop 用户执行,如果你遵循教程,用户应该是 `hduser`。
|
||||
|
||||
接下来执行 `hdfs dfsadmin -report` 查看三个节点是否都正确启动,确认你看到一行粗体文字 ‘Live datanodes (3)’:
|
||||
|
||||
```
|
||||
Configured Capacity: 93855559680 (87.41 GB)
|
||||
Raspberry Pi Hadoop Cluster picture Straight On
|
||||
Present Capacity: 65321992192 (60.84 GB)
|
||||
DFS Remaining: 62206627840 (57.93 GB)
|
||||
DFS Used: 3115364352 (2.90 GB)
|
||||
DFS Used%: 4.77%
|
||||
Under replicated blocks: 0
|
||||
Blocks with corrupt replicas: 0
|
||||
Missing blocks: 0
|
||||
Missing blocks (with replication factor 1): 0
|
||||
————————————————-
|
||||
Live datanodes (3):
|
||||
Name: 192.168.1.51:50010 (RaspberryPiHadoopSlave1)
|
||||
Hostname: RaspberryPiHadoopSlave1
|
||||
Decommission Status : Normal
|
||||
```
|
||||
|
||||
你现在可以做一些简单的诸如 ‘Hello, World!’ 的测试,或者直接进行下一步。
|
||||
|
||||
### IV. 安装 SPARK ON YARN
|
||||
|
||||
YARN 的意思是另一种非常好用的资源调度器(Yet Another Resource Negotiator),已经作为一个易用的资源管理器集成在 Hadoop 基础安装包中。
|
||||
|
||||
[Apache Spark](https://spark.apache.org/) 是 Hadoop 生态圈中的另一款软件包,它是一个毁誉参半的执行引擎和[捆绑的 MapReduce](https://hadoop.apache.org/docs/r1.2.1/mapred_tutorial.html)。在一般情况下,相对于基于磁盘存储的 MapReduce,Spark 更适合基于内存的存储,某些运行任务能够得到 10-100 倍提升——安装完成集群后你可以试试 Spark 和 MapReduce 有什么不同。
|
||||
|
||||
我个人对 Spark 还是留下非常深刻的印象,因为它提供了两种数据工程师和科学家都比较擅长的语言—— Python 和 R。
|
||||
|
||||
安装 Apache Spark 非常简单,在你家目录下,`wget "为 Hadoop 2.7 构建的 Apache Spark”`([来自这个页面](https://spark.apache.org/downloads.html)),然后运行 `tar -xzf “tgz 文件”`,最后把解压出来的文件移动至 `/opt`,并清除刚才下载的文件,以上这些就是安装步骤。
|
||||
|
||||
我又创建了只有两行的文件 `spark-env.sh`,其中包含 Spark 的配置文件目录。
|
||||
|
||||
```
|
||||
SPARK_MASTER_IP=192.168.1.50
|
||||
SPARK_WORKER_MEMORY=512m
|
||||
```
|
||||
|
||||
(在 YARN 跑起来之前我不确定这些是否有必要。)
|
||||
|
||||
### V. 你好,世界! 为 Apache Spark 寻找有趣的数据集!
|
||||
|
||||
在 Hadoop 世界里面的 ‘Hello, World!’ 就是做单词计数。
|
||||
|
||||
我决定让我们的作品做一些内省式……为什么不统计本站最常用的单词呢?也许统计一些关于本站的大数据会更有用。
|
||||
|
||||
如果你有一个正在运行的 WordPress 博客,可以通过简单的两步来导出和净化。
|
||||
|
||||
1. 我使用 [Export to Text](https://wordpress.org/support/plugin/export-to-text) 插件导出文章的内容到纯文本文件中
|
||||
2. 我使用一些[压缩库](https://pypi.python.org/pypi/bleach)编写了一个 Python 脚本来剔除 HTML
|
||||
|
||||
```
|
||||
import bleach
|
||||
|
||||
# Change this next line to your 'import' filename, whatever you would like to strip
|
||||
# HTML tags from.
|
||||
ascii_string = open('dqydj_with_tags.txt', 'r').read()
|
||||
|
||||
|
||||
new_string = bleach.clean(ascii_string, tags=[], attributes={}, styles=[], strip=True)
|
||||
new_string = new_string.encode('utf-8').strip()
|
||||
|
||||
# Change this next line to your 'export' filename
|
||||
f = open('dqydj_stripped.txt', 'w')
|
||||
f.write(new_string)
|
||||
f.close()
|
||||
```
|
||||
|
||||
现在我们有了一个更小的、适合复制到树莓派所搭建的 HDFS 集群上的文件。
|
||||
|
||||
如果你不能树莓派主节点上完成上面的操作,找个办法将它传输上去(scp、 rsync 等等),然后用下列命令行复制到 HDFS 上。
|
||||
|
||||
```
|
||||
hdfs dfs -copyFromLocal dqydj_stripped.txt /dqydj_stripped.txt
|
||||
```
|
||||
|
||||
现在准备进行最后一步 - 向 Apache Spark 写入一些代码。
|
||||
|
||||
### VI. 点亮 Apache Spark
|
||||
|
||||
Cloudera 有个极棒的程序可以作为我们的超级单词计数程序的基础,[你可以在这里找到](https://www.cloudera.com/documentation/enterprise/5-6-x/topics/spark_develop_run.html)。我们接下来为我们的内省式单词计数程序修改它。
|
||||
|
||||
在主节点上[安装‘stop-words’](https://pypi.python.org/pypi/stop-words)这个 python 第三方包,虽然有趣(我在 DQYDJ 上使用了 23,295 次 the 这个单词),你可能不想看到这些语法单词占据着单词计数的前列,另外,在下列代码用你自己的数据集替换所有有关指向 dqydj 文件的地方。
|
||||
|
||||
```
|
||||
import sys
|
||||
|
||||
from stop_words import get_stop_words
|
||||
from pyspark import SparkContext, SparkConf
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
# create Spark context with Spark configuration
|
||||
conf = SparkConf().setAppName("Spark Count")
|
||||
sc = SparkContext(conf=conf)
|
||||
|
||||
# get threshold
|
||||
try:
|
||||
threshold = int(sys.argv[2])
|
||||
except:
|
||||
threshold = 5
|
||||
|
||||
# read in text file and split each document into words
|
||||
tokenized = sc.textFile(sys.argv[1]).flatMap(lambda line: line.split(" "))
|
||||
|
||||
# count the occurrence of each word
|
||||
wordCounts = tokenized.map(lambda word: (word.lower().strip(), 1)).reduceByKey(lambda v1,v2:v1 +v2)
|
||||
|
||||
# filter out words with fewer than threshold occurrences
|
||||
filtered = wordCounts.filter(lambda pair:pair[1] >= threshold)
|
||||
|
||||
print "*" * 80
|
||||
print "Printing top words used"
|
||||
print "-" * 80
|
||||
filtered_sorted = sorted(filtered.collect(), key=lambda x: x[1], reverse = True)
|
||||
for (word, count) in filtered_sorted: print "%s : %d" % (word.encode('utf-8').strip(), count)
|
||||
|
||||
|
||||
# Remove stop words
|
||||
print "\n\n"
|
||||
print "*" * 80
|
||||
print "Printing top non-stop words used"
|
||||
print "-" * 80
|
||||
# Change this to your language code (see the stop-words documentation)
|
||||
stop_words = set(get_stop_words('en'))
|
||||
no_stop_words = filter(lambda x: x[0] not in stop_words, filtered_sorted)
|
||||
for (word, count) in no_stop_words: print "%s : %d" % (word.encode('utf-8').strip(), count)
|
||||
```
|
||||
|
||||
保存好 wordCount.py,确保上面的路径都是正确无误的。
|
||||
|
||||
现在,准备念出咒语,让运行在 YARN 上的 Spark 跑起来,你可以看到我在 DQYDJ 使用最多的单词是哪一个。
|
||||
|
||||
```
|
||||
/opt/spark-2.0.0-bin-hadoop2.7/bin/spark-submit –master yarn –executor-memory 512m –name wordcount –executor-cores 8 wordCount.py /dqydj_stripped.txt
|
||||
```
|
||||
|
||||
### VII. 我在 DQYDJ 使用最多的单词
|
||||
|
||||
可能入列的单词有哪一些呢?“can, will, it’s, one, even, like, people, money, don’t, also“.
|
||||
|
||||
嘿,不错,“money”悄悄挤进了前十。在一个致力于金融、投资和经济的网站上谈论这似乎是件好事,对吧?
|
||||
|
||||
下面是的前 50 个最常用的词汇,请用它们刻画出有关我的文章的水平的结论。
|
||||
|
||||
![](https://dqydj.com/wp-content/uploads/2016/08/dqydj_pk_most_used_words.png)
|
||||
|
||||
我希望你能喜欢这篇关于 Hadoop、YARN 和 Apache Spark 的教程,现在你可以在 Spark 运行和编写其他的应用了。
|
||||
|
||||
你的下一步是任务是开始[阅读 pyspark 文档](https://spark.apache.org/docs/2.0.0/api/python/index.html)(以及用于其他语言的该库),去学习一些可用的功能。根据你的兴趣和你实际存储的数据,你将会深入学习到更多——有流数据、SQL,甚至机器学习的软件包!
|
||||
|
||||
你怎么看?你要建立一个树莓派 Hadoop 集群吗?想要在其中挖掘一些什么吗?你在上面看到最令你惊奇的单词是什么?为什么 'S&P' 也能上榜?
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://dqydj.com/raspberry-pi-hadoop-cluster-apache-spark-yarn/
|
||||
|
||||
作者:[PK][a]
|
||||
译者:[popy32](https://github.com/sfantree)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 组织编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://dqydj.com/about/#contact_us
|
||||
[1]: https://www.raspberrypi.org/downloads/raspbian/
|
||||
[2]: https://sourceforge.net/projects/win32diskimager/
|
||||
[3]: http://www.becausewecangeek.com/building-a-raspberry-pi-hadoop-cluster-part-1/
|
||||
[4]: https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04
|
||||
[5]: http://www.becausewecangeek.com/building-a-raspberry-pi-hadoop-cluster-part-2/
|
||||
[6]: https://spark.apache.org/
|
||||
[7]: https://hadoop.apache.org/docs/r1.2.1/mapred_tutorial.html
|
||||
[8]: https://spark.apache.org/downloads.html
|
||||
[9]: https://wordpress.org/support/plugin/export-to-text
|
||||
[10]: https://pypi.python.org/pypi/bleach
|
||||
|
@ -0,0 +1,165 @@
|
||||
Linux 容器能否弥补 IoT 的安全短板?
|
||||
========
|
||||
|
||||
![](http://hackerboards.com/files/internet_of_things_wikimedia1-thm.jpg)
|
||||
|
||||
> 在这个最后的物联网系列文章中,Canonical 和 Resin.io 向以 Linux 容器技术作为解决方案向物联网安全性和互操作性发起挑战。
|
||||
|
||||
![](http://hackerboards.com/files/samsung_artik710-thm.jpg)
|
||||
|
||||
*Artik 7*
|
||||
|
||||
尽管受到日益增长的安全威胁,但对物联网(IoT)的炒作没有显示减弱的迹象。为了刷存在感,公司们正忙于重新规划它们的物联网方面的路线图。物联网大潮迅猛异常,比移动互联网革命渗透的更加深入和广泛。IoT 像黑洞一样,吞噬一切,包括智能手机,它通常是我们通向物联网世界的窗口,有时也作为我们的汇聚点或终端。
|
||||
|
||||
新的针对物联网的处理器和嵌入式主板继续重塑其技术版图。自从 9 月份推出 [面向物联网的 Linux 和开源硬件][5] 系列文章之后,我们看到了面向物联网网关的 “Apollo Lake]” SoC 芯片 [Intel Atom E3900][6] 以及[三星 新的 Artik 模块][7],包括用于网关并由 Linux 驱动的 64 位 Artik 7 COM 及自带 RTOS 的 Cortex-M4 Artik。 ARM 为具有 ARMv8-M 和 TrustZone 安全性的 IoT 终端发布了 [Cortex-M23 和 Cortex-M33][8] 芯片。
|
||||
|
||||
讲道理,安全是这些产品的卖点。最近攻击 Dyn 服务并在一天内摧毁了美国大部分互联网的 Mirai 僵尸网络将基于 Linux 的物联网推到台前 - 当然这种方式似乎不太体面。就像 IoT 设备可以成为 DDoS 的帮凶一样,设备及其所有者同样可能直接遭受恶意攻击。
|
||||
|
||||
![](http://hackerboards.com/files/arm_cortexm33m23-thm.jpg)
|
||||
|
||||
*Cortex-M33 和 -M23*
|
||||
|
||||
Dyn 攻击更加证明了这种观点,即物联网将更加蓬勃地在受控制和受保护的工业环境发展,而不是家用环境中。这不是因为没有消费级[物联网安全技术][9],但除非产品设计之初就以安全为目标,否则如我们的[智能家居集线器系列][10]中的许多解决方案一样,后期再考虑安全就会增加成本和复杂性。
|
||||
|
||||
在物联网系列的最后这个未来展望的部分,我们将探讨两种基于 Linux 的面向 Docker 的容器技术,这些技术被提出作为物联网安全解决方案。容器还可以帮助解决我们在[物联网框架][11]中探讨的开发复杂性和互操作性障碍的问题。
|
||||
|
||||
我们与 Canonical 的 Ubuntu 客户平台工程副总裁 Oliver Ries 讨论了 Ubuntu Core 和适用于 Docker 的容器式 Snaps 包管理技术。我们还就新的基于 Docker 的物联网方案 ResinOS 采访了 Resin.io 首席执行官和联合创始人 Alexandros Marinos。
|
||||
|
||||
### Ubuntu Core Snaps
|
||||
|
||||
Canonical 面向物联网的 [Snappy Ubuntu Core][12] 版本的 Ubuntu 是围绕一个类似容器的快照包管理机制而构建的,并提供应用商店支持。 snaps 技术最近[自行发布了][13]用于其他 Linux 发行版的版本。去年 11 月 3 日,Canonical 发布了 [Ubuntu Core 16] [14],该版本改进了白标应用商店和更新控制服务。
|
||||
|
||||
|
||||
|
||||
![](http://hackerboards.com/files/canonical_ubuntucore16_diagram.jpg)
|
||||
|
||||
|
||||
*传统 Ubuntu(左)架构 与 Ubuntu Core 16*
|
||||
|
||||
快照机制提供自动更新,并有助于阻止未经授权的更新。 使用事务系统管理,快照可确保更新按预期部署或根本不部署。 在 Ubuntu Core 中,使用 AppArmor 进一步加强了安全性,并且所有应用程序文件都是只读的且保存在隔离的孤岛中。
|
||||
|
||||
![](http://hackerboards.com/files/limesdr-thm.jpg)
|
||||
|
||||
*LimeSDR*
|
||||
|
||||
Ubuntu Core 是我们最近展开的[开源物联网操作系统调查][16]的一部分,现在运行于 Gumstix 主板、Erle 机器人无人机、Dell Edge 网关、[Nextcloud Box][17]、LimeSDR、Mycroft 家庭集线器、英特尔的 Joule 和符合 Linaro 的 96Boards 规范的 SBC(单板计算机) 上。 Canonical 公司还与 Linaro 物联网和嵌入式(LITE)部门集团在其 [96Boards 物联网版(IE)][18] 上达成合作。最初,96Boards IE 专注于 Zephyr 驱动的 Cortex-M4 板卡,如 Seeed 的 [BLE Carbon] [19],不过它将扩展到可以运行 Ubuntu Core 的网关板卡上。
|
||||
|
||||
“Ubuntu Core 和 snaps 具有从边缘到网关到云的相关性,”Canonical 的 Ries 说。 “能够在任何主要发行版(包括 Ubuntu Server 和 Ubuntu for Cloud)上运行快照包,使我们能够提供一致的体验。 snaps 可以使用事务更新以免故障方式升级,可用于安全性更新、错误修复或新功能的持续更新,这在物联网环境中非常重要。”
|
||||
|
||||
![](http://hackerboards.com/files/nextcloud_box3-thm.jpg)
|
||||
|
||||
*Nextcloud盒子*
|
||||
|
||||
安全性和可靠性是关注的重点,Ries 说。 “snaps 应用可以完全独立于彼此和操作系统而运行,使得两个应用程序可以安全地在单个网关上运行,”他说。 “snaps 是只读的和经过认证的,可以保证代码的完整性。
|
||||
|
||||
Ries 还说这种技术减少开发时间。 “snap 软件包允许开发人员向支持它的任何平台提供相同的二进制包,从而降低开发和测试成本,减少部署时间和提高更新速度。 “使用 snap 软件包,开发人员完可以全控制开发生命周期,并可以立即更新。 snap 包提供了所有必需的依赖项,因此开发人员可以选择定制他们使用的组件。”
|
||||
|
||||
### ResinOS: 为 IoT 而生的 Docker
|
||||
|
||||
Resin.io 公司,与其商用的 IoT 框架同名,最近剥离了该框架的基于 Yocto Linux 的 [ResinOS 2.0][20],ResinOS 2.0 将作为一个独立的开源项目运营。 Ubuntu Core 在 snap 包中运行 Docker 容器引擎,ResinOS 在主机上运行 Docker。 极致简约的 ResinOS 抽离了使用 Yocto 代码的复杂性,使开发人员能够快速部署 Docker 容器。
|
||||
|
||||
|
||||
|
||||
![](http://hackerboards.com/files/resinio_resinos_arch.jpg)
|
||||
|
||||
|
||||
*ResinOS 2.0 架构*
|
||||
|
||||
与基于 Linux 的 CoreOS 一样,ResinOS 集成了 systemd 控制服务和网络协议栈,可通过异构网络安全地部署更新的应用程序。 但是,它是为在资源受限的设备(如 ARM 黑客板)上运行而设计的,与之相反,CoreOS 和其他基于 Docker 的操作系统(例如基于 Red Hat 的 Project Atomic)目前仅能运行在 x86 上,并且更喜欢资源丰富的服务器平台。 ResinOS 可以在 20 中 Linux 设备上运行,并不断增长,包括 Raspberry Pi,BeagleBone 和Odroid-C1 等。
|
||||
|
||||
“我们认为 Linux 容器对嵌入式系统比对于云更重要,”Resin.io 的 Marinos 说。 “在云中,容器代表了对之前的进程的优化,但在嵌入式中,它们代表了姗姗来迟的通用虚拟化“
|
||||
|
||||
![](http://hackerboards.com/files/beaglebone-hand-thm.jpg)
|
||||
|
||||
*BeagleBone Black*
|
||||
|
||||
当应用于物联网时,完整的企业级虚拟机有直接访问硬件的限制的性能缺陷,Marinos 说。像 OSGi 和 Android 的Dalvik 这样的移动设备虚拟机可以用于 IoT,但是它们依赖 Java 并有其他限制。
|
||||
|
||||
对于企业开发人员来说,使用 Docker 似乎很自然,但是你如何说服嵌入式黑客转向全新的范式呢? “Marinos 解释说,”ResinOS 不是把云技术的实践经验照单全收,而是针对嵌入式进行了优化。”此外,他说,容器比典型的物联网技术更好地包容故障。 “如果有软件缺陷,主机操作系统可以继续正常工作,甚至保持连接。要恢复,您可以重新启动容器或推送更新。更新设备而不重新启动它的能力进一步消除了故障引发问题的机率。”
|
||||
|
||||
据 Marinos 所说,其他好处源自与云技术的一致性,例如拥有更广泛的开发人员。容器提供了“跨数据中心和边缘的统一范式,以及一种方便地将技术、工作流、基础设施,甚至应用程序转移到边缘(终端)的方式。”
|
||||
|
||||
Marinos 说,容器中的固有安全性优势正在被其他技术增强。 “随着 Docker 社区推动实现镜像签名和鉴证,这些自然会转移并应用到 ResinOS,”他说。 “当 Linux 内核被强化以提高容器安全性时,或者获得更好地管理容器所消耗的资源的能力时,会产生类似的好处。
|
||||
|
||||
容器也适合开源 IoT 框架,Marinos 说。 “Linux 容器很容易与几乎各种协议、应用程序、语言和库结合使用,”Marinos 说。 “Resin.io 参加了 AllSeen 联盟,我们与使用 IoTivity 和 Thread的 伙伴一起合作。”
|
||||
|
||||
### IoT的未来:智能网关与智能终端
|
||||
|
||||
Marinos 和 Canonical 的 Ries 对未来物联网的几个发展趋势具有一致的看法。 首先,物联网的最初概念(其中基于 MCU 的端点直接与云进行通信以进行处理)正在迅速被雾化计算架构所取代。 这需要更智能的网关,也需要比仅仅在 ZigBee 和 WiFi 之间聚合和转换数据更多的功能。
|
||||
|
||||
其次,网关和智能边缘设备越来越多地运行多个应用程序。 第三,许多这些设备将提供板载分析,这些在最新的[智能家居集线器][22]上都有体现。 最后,富媒体将很快成为物联网组合的一部分。
|
||||
|
||||
|
||||
![](http://hackerboards.com/files/eurotech_reliagate2026.jpg)
|
||||
|
||||
|
||||
*最新设备网关: Eurotech 的 [ReliaGate 20-26][1]*
|
||||
|
||||
![](http://hackerboards.com/files/advantech_ubc221.jpg)
|
||||
|
||||
|
||||
*最新设备网关: Advantech 的 [UBC-221][2]*
|
||||
|
||||
“智能网关正在接管最初为云服务设计的许多处理和控制功能,”Marinos 说。 “因此,我们看到对容器化的推动力在增加,可以在 IoT 设备中使用类似云工作流程来部署与功能和安全相关的优化。去中心化是由移动数据紧缩、不断发展的法律框架和各种物理限制等因素驱动的。”
|
||||
|
||||
Ubuntu Core 等平台正在使“可用于网关的软件爆炸式增长”,Canonical 的 Ries 说。 “在单个设备上运行多个应用程序的能力吸引了众多单一功能设备的用户,以及现在可以产生持续的软件收入的设备所有者。”
|
||||
|
||||
![](http://hackerboards.com/files/myomega_mynxg-sm.jpg)
|
||||
|
||||
*两种 IoT 网关: [MyOmega MYNXG IC2 Controller][3]*
|
||||
|
||||
![](http://hackerboards.com/files/technexion_ls1021aiot_front-sm.jpg)
|
||||
|
||||
*两种 IoT 网关: TechNexion 的 [LS1021A-IoT Gateway][4]*
|
||||
|
||||
不仅是网关 - 终端也变得更聪明。 “阅读大量的物联网新闻报道,你得到的印象是所有终端都运行在微控制器上,”Marinos 说。 “但是我们对大量的 Linux 终端,如数字标牌,无人机和工业机械等直接执行任务,而不是作为操作中介(数据转发)感到惊讶。我们称之为影子 IoT。”
|
||||
|
||||
Canonical 的 Ries 同意,对简约技术的专注使他们忽视了新兴物联网领域。 “轻量化的概念在一个发展速度与物联网一样快的行业中初现端倪,”Ries 说。 “今天的高级消费硬件可以持续为终端供电数月。”
|
||||
|
||||
虽然大多数物联网设备将保持轻量和“无头”(一种配置方式,比如物联网设备缺少显示器,键盘等),它们装备有如加速度计和温度传感器这样的传感器并通过低速率的数据流通信,但是许多较新的物联网应用已经使用富媒体。 “媒体输入/输出只是另一种类型的外设,”Marinos 说。 “总是存在多个容器竞争有限资源的问题,但它与传感器或蓝牙竞争天线资源没有太大区别。”
|
||||
|
||||
Ries 看到了工业和家庭网关中“提高边缘智能”的趋势。 “我们看到人工智能、机器学习、计算机视觉和上下文意识的大幅上升,”Ries 说。 “为什么要在云中运行面部检测软件,如果相同的软件可以在边缘设备运行而又没有网络延迟和带宽及计算成本呢?“
|
||||
|
||||
当我们在这个物联网系列的[开篇故事][27]中探索时,我们发现存在与安全相关的物联网问题,例如隐私丧失和生活在监视文化中的权衡。还有一些问题如把个人决策交给可能由他人操控的 AI 裁定。这些不会被容器,快照或任何其他技术完全解决。
|
||||
|
||||
如果 AWS Alexa 可以处理生活琐事,而我们专注在要事上,也许我们会更快乐。或许有一个方法来平衡隐私和效用,现在,我们仍在探索,如此甚好。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://hackerboards.com/can-linux-containers-save-iot-from-a-security-meltdown/
|
||||
|
||||
作者:[Eric Brown][a]
|
||||
译者:[firstadream](https://github.com/firstadream)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://hackerboards.com/can-linux-containers-save-iot-from-a-security-meltdown/
|
||||
[1]:http://hackerboards.com/atom-based-gateway-taps-new-open-source-iot-cloud-platform/
|
||||
[2]:http://hackerboards.com/compact-iot-gateway-runs-yocto-linux-on-quark/
|
||||
[3]:http://hackerboards.com/wireless-crazed-customizable-iot-gateway-uses-arm-or-x86-coms/
|
||||
[4]:http://hackerboards.com/iot-gateway-runs-linux-on-qoriq-accepts-arduino-shields/
|
||||
[5]:http://hackerboards.com/linux-and-open-source-hardware-for-building-iot-devices/
|
||||
[6]:http://hackerboards.com/intel-launches-14nm-atom-e3900-and-spins-an-automotive-version/
|
||||
[7]:http://hackerboards.com/samsung-adds-first-64-bit-and-cortex-m4-based-artik-modules/
|
||||
[8]:http://hackerboards.com/new-cortex-m-chips-add-armv8-and-trustzone/
|
||||
[9]:http://hackerboards.com/exploring-security-challenges-in-linux-based-iot-devices/
|
||||
[10]:http://hackerboards.com/linux-based-smart-home-hubs-advance-into-ai/
|
||||
[11]:http://hackerboards.com/open-source-projects-for-the-internet-of-things-from-a-to-z/
|
||||
[12]:http://hackerboards.com/lightweight-snappy-ubuntu-core-os-targets-iot/
|
||||
[13]:http://hackerboards.com/canonical-pushes-snap-as-a-universal-linux-package-format/
|
||||
[14]:http://hackerboards.com/ubuntu-core-16-gets-smaller-goes-all-snaps/
|
||||
[15]:http://hackerboards.com/files/canonical_ubuntucore16_diagram.jpg
|
||||
[16]:http://hackerboards.com/open-source-oses-for-the-internet-of-things/
|
||||
[17]:http://hackerboards.com/private-cloud-server-and-iot-gateway-runs-ubuntu-snappy-on-rpi/
|
||||
[18]:http://hackerboards.com/linaro-beams-lite-at-internet-of-things-devices/
|
||||
[19]:http://hackerboards.com/96boards-goes-cortex-m4-with-iot-edition-and-carbon-sbc/
|
||||
[20]:http://hackerboards.com/can-linux-containers-save-iot-from-a-security-meltdown/%3Ca%20href=
|
||||
[21]:http://hackerboards.com/files/resinio_resinos_arch.jpg
|
||||
[22]:http://hackerboards.com/linux-based-smart-home-hubs-advance-into-ai/
|
||||
[23]:http://hackerboards.com/files/eurotech_reliagate2026.jpg
|
||||
[24]:http://hackerboards.com/files/advantech_ubc221.jpg
|
||||
[25]:http://hackerboards.com/files/myomega_mynxg.jpg
|
||||
[26]:http://hackerboards.com/files/technexion_ls1021aiot_front.jpg
|
||||
[27]:http://hackerboards.com/an-open-source-perspective-on-the-internet-of-things-part-1/
|
||||
[28]:http://hackerboards.com/can-linux-containers-save-iot-from-a-security-meltdown/
|
160
published/20170112 Partition Backup.md
Normal file
160
published/20170112 Partition Backup.md
Normal file
@ -0,0 +1,160 @@
|
||||
如何备份一个磁盘分区
|
||||
============
|
||||
|
||||
通常你可能会把数据放在一个分区上,有时候可能需要对该设备或者上面的一个分区进行备份。树莓派用户为了可引导 SD 卡当然有这个需求。其它小体积计算机的用户也会发现这非常有用。有时候设备看起来要出现故障时最好快速做个备份。
|
||||
|
||||
进行本文中的实验你需要一个叫 `dcfldd` 的工具。
|
||||
|
||||
### dcfldd 工具
|
||||
|
||||
该工具是 coreutils 软件包中 `dd` 工具的增强版。`dcfldd` 是 Nicholas Harbour 在美国国防部计算机取证实验室(DCFL)工作期间研发的。该工具的名字也基于他工作的地方 - `dcfldd`。
|
||||
|
||||
对于仍然在使用 CoreUtils 8.23 或更低版本的系统,并没有一个可以轻松查看正在创建副本的进度的选项。有时候看起来就像什么都没有发生,以至于你就想取消掉备份。
|
||||
|
||||
**注意:**如果你使用 8.24 或更新版本的 `dd` 工具,你就不需要使用 `dcfldd`,只需要用 `dd` 替换 `dcfldd` 即可。所有其它参数仍然适用。
|
||||
|
||||
在 Debian 系统上你只需要在 Package Manager 中搜索 `dcfldd`。你也可以打开一个终端然后输入下面的命令:
|
||||
|
||||
```
|
||||
sudo apt-get install dcfldd
|
||||
```
|
||||
|
||||
对于 Red Hat 系统,可以用下面的命令:
|
||||
|
||||
```
|
||||
cd /tmp
|
||||
wget dl.fedoraproject.org/pub/epel/6/i386/dcfldd-1.3.4.1-4.el6.i686.rpm
|
||||
sudo yum install dcfldd-1.3.4.1-4.el6.i686.rpm
|
||||
dcfldd --version
|
||||
```
|
||||
|
||||
**注意:** 上面的命令安装的是 32 位版本。对于 64 位版本,使用下面的命令:
|
||||
|
||||
````
|
||||
cd /tmp
|
||||
wget dl.fedoraproject.org/pub/epel/6/x86_64/dcfldd-1.3.4.1-4.el6.x86_64.rpm
|
||||
sudo yum install dcfldd-1.3.4.1-4.el6.x86_64.rpm
|
||||
dcfldd --version
|
||||
```
|
||||
|
||||
每组命令中的最后一个语句会列出 `dcfldd` 的版本并显示该命令文件已经被加载。
|
||||
|
||||
**注意:**确保你以 root 用户执行 `dd` 或者 `dcfldd` 命令。
|
||||
|
||||
安装完该工具后你就可以继续使用它备份和恢复分区。
|
||||
|
||||
### 备份分区
|
||||
|
||||
备份设备的时候可以备份整个设备也可以只是其中的一个分区。如果设备有多个分区,我们可以分别备份每个分区。
|
||||
|
||||
在进行备份之前,先让我们来看一下设备和分区的区别。假设我们有一个已经被格式化为一个大磁盘的 SD 卡。这个 SD 卡只有一个分区。如果空间被切分使得 SD 卡看起来是两个设备,那么它就有两个分区。
|
||||
|
||||
假设我们有一个树莓派中的 SD 卡。SD 卡容量为 8 GB,有两个分区。第一个分区存放 BerryBoot 启动引导器。第二个分区存放 Kali(LCTT 译注:Kali Linux 是一个 Debian 派生的 Linux 发行版)。现在已经没有可用的空间用来安装第二个操作系统。我们使用大小为 16 GB 的第二个 SD 卡,但拷贝到第二个 SD 卡之前,第一个 SD 卡必须先备份。
|
||||
|
||||
要备份第一个 SD 卡我们需要备份设备 `/dev/sdc`。进行备份的命令如下所示:
|
||||
|
||||
```
|
||||
dcfldd if=/dev/sdc of=/tmp/SD-Card-Backup.img
|
||||
```
|
||||
|
||||
备份包括输入文件(`if`)以及被设置为 `/tmp` 目录下名为 `SD-Card-Backup.img` 的输出文件(`of`)。
|
||||
|
||||
`dd` 和 `dcfldd` 默认都是每次读写文件中的一个块。通过上述命令,它可以一次默认读写 512 个字节。记住,该复制是一个精准的拷贝 - 逐位逐字节。
|
||||
|
||||
默认的 512 个字节可以通过块大小参数 - `bs=` 更改。例如,要每次读写 1 兆字节,参数为 `bs=1M`。使用以下所用的缩写可以设置不同大小:
|
||||
|
||||
* b – 512 字节
|
||||
* KB – 1000 字节
|
||||
* K – 1024 字节
|
||||
* MB – 1000x1000 字节
|
||||
* M – 1024x1024 字节
|
||||
* GB – 1000x1000x1000 字节
|
||||
* G – 1024x1024x1024 字节
|
||||
|
||||
你也可以单独指定读和写的块大小。要指定读块的大小使用 `ibs=`。要指定写块的大小使用 `obs=`。
|
||||
|
||||
我使用三种不同的块大小做了一个 120 MB 分区的备份测试。第一次使用默认的 512 字节,它用了 7 秒钟。第二次块大小为 1024 K,它用时 2 秒。第三次块大小是 2048 K,它用时 3 秒。用时会随系统以及其它硬件实现的不同而变化,但通常来说更大的块大小会比默认的稍微快一点。
|
||||
|
||||
完成备份后,你还需要知道如何把数据恢复到设备中。
|
||||
|
||||
### 恢复分区
|
||||
|
||||
现在我们已经有了一个备份点,假设数据可能被损毁了或者由于某些原因需要进行恢复。
|
||||
|
||||
命令和备份时相同,只是源和目标相反。对于上面的例子,命令会变为:
|
||||
|
||||
```
|
||||
dcfldd of=/dev/sdc if=/tmp/SD-Card-Backup.img
|
||||
```
|
||||
|
||||
这里,镜像文件被用作输入文件(`if`)而设备(sdc)被用作输出文件(`of`)。
|
||||
|
||||
**注意:** 要记住输出设备会被重写,它上面的所有数据都会丢失。通常来说在恢复数据之前最好用 GParted 删除 SD 卡上的所有分区。
|
||||
|
||||
假如你在使用多个 SD 卡,例如多个树莓派主板,你可以一次性写多块 SD 卡。为了做到这点,你需要知道系统中卡的 ID。例如,假设我们想把镜像 `BerryBoot.img` 拷贝到两个 SD 卡。SD 卡分别是 `/dev/sdc` 和 `/dev/sdd`。下面的命令在显示进度时每次读写 1 MB 的块。命令如下:
|
||||
|
||||
```
|
||||
dcfldd if=BerryBoot.img bs=1M status=progress | tee >(dcfldd of=/dev/sdc) | dcfldd of=/dev/sdd
|
||||
```
|
||||
|
||||
在这个命令中,第一个 `dcfldd` 指定输入文件并把块大小设置为 1 MB。`status` 参数被设置为显示进度。然后输入通过管道 `|`传输给命令 `tee`。`tee` 用于将输入分发到多个地方。第一个输出是到命令 `dcfldd of=/dev/sdc`。命令被放到小括号内被作为一个命令执行。我们还需要最后一个管道 `|`,否则命令 `tee` 会把信息发送到 `stdout` (屏幕)。因此,最后的输出是被发送到命令 `dcfldd of=/dev/sdd`。如果你有第三个 SD 卡,甚至更多,只需要添加另外的重定向和命令,类似 `>(dcfldd of=/dev/sde`。
|
||||
|
||||
**注意:**记住最后一个命令必须在管道 `|` 后面。
|
||||
|
||||
必须验证写的数据确保数据是正确的。
|
||||
|
||||
### 验证数据
|
||||
|
||||
一旦创建了一个镜像或者恢复了一个备份,你可以验证这些写入的数据。要验证数据,你会使用名为 `diff` 的另一个不同程序。
|
||||
|
||||
使用 `diff` ,你需要指定镜像文件的位置以及系统中拷贝自或写入的物理媒介。你可以在创建备份或者恢复了一个镜像之后使用 `diff` 命令。
|
||||
|
||||
该命令有两个参数。第一个是物理媒介,第二个是镜像文件名称。
|
||||
|
||||
对于例子 `dcfldd of=/dev/sdc if=/tmp/SD-Card-Backup.img`,对应的 `diff` 命令是:
|
||||
|
||||
```
|
||||
diff /dev/sdc /tmp/SD-Card-Backup.img
|
||||
```
|
||||
|
||||
如果镜像和物理设备有任何的不同,你会被告知。如果没有显示任何信息,那么数据就验证为完全相同。
|
||||
|
||||
确保数据完全一致是验证备份和恢复完整性的关键。进行备份时需要注意的一个主要问题是镜像大小。
|
||||
|
||||
### 分割镜像
|
||||
|
||||
假设你想要备份一个 16GB 的 SD 卡。镜像文件大小会大概相同。如果你只能把它备份到 FAT32 分区会怎样呢?FAT32 最大文件大小限制是 4 GB。
|
||||
|
||||
必须做的是文件必须被切分为 4 GB 的分片。通过管道 `|` 将数据传输给 `split` 命令可以切分正在被写的镜像文件。
|
||||
|
||||
创建备份的方法相同,但命令会包括管道和切分命令。示例备份命令为 `dcfldd if=/dev/sdc of=/tmp/SD-Card-Backup.img` ,其切分文件的新命令如下:
|
||||
|
||||
```
|
||||
dcfldd if=/dev/sdc | split -b 4000MB - /tmp/SD-Card-Backup.img
|
||||
```
|
||||
|
||||
**注意:** 大小后缀和对 `dd` 及 `dcfldd` 命令的意义相同。 `split` 命令中的破折号用于将通过管道从 `dcfldd` 命令传输过来的数据填充到输入文件。
|
||||
|
||||
文件会被保存为 `SD-Card-Backup.imgaa` 和 `SD-Card-Backup.imgab`,如此类推。如果你担心文件大小太接近 4 GB 的限制,可以试着用 3500MB。
|
||||
|
||||
将文件恢复到设备也很简单。你使用 `cat` 命令将它们连接起来然后像下面这样用 `dcfldd` 写输出:
|
||||
|
||||
```
|
||||
cat /tmp/SD-Card-Backup.img* | dcfldd of=/dev/sdc
|
||||
```
|
||||
|
||||
你可以在命令中 `dcfldd` 部分包含任何需要的参数。
|
||||
|
||||
我希望你了解并能执行任何需要的数据备份和恢复,正如 SD 卡和类似设备所需的那样。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.linuxforum.com/threads/partition-backup.3638/
|
||||
|
||||
作者:[Jarret][a]
|
||||
译者:[ictlyh](https://github.com/ictlyh)
|
||||
校对:[jasminepeng](https://github.com/jasminepeng)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://www.linuxforum.com/members/jarret.268/
|
97
published/20170210 Fedora 25 Wayland vs Xorg.md
Normal file
97
published/20170210 Fedora 25 Wayland vs Xorg.md
Normal file
@ -0,0 +1,97 @@
|
||||
Fedora 25: Wayland 大战 Xorg
|
||||
============
|
||||
|
||||
就像异形大战铁血战士的结果一样,后者略胜一筹。不管怎样,你可能知道,我最近测试了 [Fedora 25][1],体验还可以。总的来说,这个发行版表现的相当不错。它不是最快速的,但随着一系列的改进,变得足够稳定也足够好用。最重要的是,除了一些性能以及响应性的损失,Wayland 并没有造成我的系统瘫痪。但这还仅仅是个开始。
|
||||
|
||||
Wayland 作为一种消费者技术还处在它的襁褓期,或者至少是当人们在处理桌面事物时应就这么认为。因此,我必须继续测试,绝不弃坑。在过去的积极地使用 Fedora 25 的几个星期里,我确实碰到了几个其它的问题,有些不用太担心,有些确实很恼人,有些很奇怪,有些却无意义。让我们来讲述一下吧!
|
||||
|
||||
![Teaser](http://www.dedoimedo.com/images/computers-years/2016-2/fedora-wayland-xorg-teaser.jpg)
|
||||
|
||||
注: 图片来自 [Wikimedia][2] 并做了些修改, [CC BY-SA 3.0][3] 许可
|
||||
|
||||
### Wayland 并不支持所有软件
|
||||
|
||||
没错,这是一个事实。如果你去网站上阅读相关的信息,你会发现各种各样的软件都还没为 Wayland 做好准备。当然,我们都知道 Fedora 是一个激进的高端发行版,它是为了探索新功能而出现的测试床。这没毛病。有一段时间,所有东西都很正常,没有瞎忙活,没有错误。但接下来,我突然需要使用 GParted。我当时很着急,正在排除一个大故障,然而我却让自己置身于一些无意义的额外工作。 GParted 没办法在 Wayland 下直接启动。在探索了更多一些细节之后,我知道了该分区软件目前还没有被 Wayland 支持。
|
||||
|
||||
![GParted 无法运行于 Wayland](http://www.dedoimedo.com/images/computers-years/2016-2/fedora-wayland-xorg-gparted.jpg)
|
||||
|
||||
问题就在于我并不太清楚其它哪些应用不能在 Wayland 下运行,并且我不能在一个正确估计的时间敏锐地发现这一点。通过在线搜索,我还是不能快速找到一个简要的当前不兼容列表。可能只是我在搜索方面不太在行,但显而易见这些东西是和“Wayland + 兼容性” 这样的问题一样零零散散的。
|
||||
|
||||
我找到了一个[自诩][4] Wayland 很棒的文章、一个目前已被这个新玩意儿支持的 [Gnome][5] 应用程序列表、一些 ArchWiki 上难懂的资料,一篇在[英伟达][6]开发论坛上的晦涩得让我后悔点进去的主题,以及一些其他含糊的讨论。
|
||||
|
||||
### 再次提到性能
|
||||
|
||||
在 Fedora 25 上,我把登录会话从 Gnome(Wayland)切换到 Gnome Xorg,观察会对系统产生什么影响。我之前已经提到过在同一个笔记本([联想 G50][8])上的性能跑分和与 [Fedora 24][7] 的比较,但这次会给我们提供更加准确的结果。
|
||||
|
||||
Wayland(截图 1)空闲时的内存占用为 1.4GB, CPU 的平均负载约为 4-5%。Xorg(截图 2)占用了同样大小的内存,处理器消耗了全部性能的 3-4%,单纯从数字上来看少了一小点。但是 Xorg 会话的体验却好得多。虽然只是毫秒级的差距,但你能感受得到。传统的会话方式看起来更加的灵动、快速、清新一点。但 Wayland 落后得并不明显。如果你对你的电脑响应速度很敏感,你可能会对这点延迟不会太满意。当然,这也许只是作为新手缺乏优化的缘故,Wayland 会随时间进步。但这一点也是我们所不能忽视的。
|
||||
|
||||
![Wayland resources](http://www.dedoimedo.com/images/computers-years/2016-2/fedora-wayland-xorg-resources-wayland.jpg)
|
||||
|
||||
![Xorg resources](http://www.dedoimedo.com/images/computers-years/2016-2/fedora-wayland-xorg-resources-xorg.jpg)
|
||||
|
||||
### 批评
|
||||
|
||||
我对此并不高兴。虽然并不是很愤怒,但我不喜欢为了能完全享受我的桌面体验,我却需要登录到传统的 X 会话。因为 X 给了我全部,但 Wayland 则没有。这意味着我不能一天都用着 Wayland。我喜欢探索科技,但我不是一个盲目的狂热追随者。我只是想用我的桌面,有时我可能需要它快速响应。注销然后重新登录在急需使用的时候会成为恼人的麻烦。我们遇到这个问题的原因就是 Wayland 没有让 Linux 桌面用户的生活变得更简单,而恰恰相反。
|
||||
|
||||
引用:
|
||||
|
||||
> Wayland 是为了成为 X 的更加简单的替代品,更加容易开发和维护。建议 GNOME 和 KDE 都使用它。
|
||||
|
||||
你能看到,这就是问题的一方面原因。东西不应该被设计成容易开发或维护。它可以是满足了所有其它消费需求之后提供的有益副产品。但如果没有,那么不管它对于程序员敲代码来说多么困难或简单都将不重要。那是他们的工作。科技的所有目的都是为了达到一种无缝并且流畅的用户体验。
|
||||
|
||||
不幸的是,现在很大数量的产品都被重新设计或者开发,只是为了使软件人员更加轻松,而不是用户。在很大程度上,Gnome 3、PulseAudio、[Systemd][9] 和 Wayland 都没有遵循提高用户体验的宗旨。在这个意义上来说,它们更像是一种打扰,而没有为 Linux 桌面生态的稳定性和易用性作出贡献。
|
||||
|
||||
这也是为什么 Linux 桌面是一个相对不成熟产品的一个主要原因————它被设计成开发人员的自我支持产品,更像一个活生生的生物,而不是依附于用户各种怪念头和想法的奴隶。这也是伟大事物是如何形成的,你满足于主要需求,接下来只是担心细节方面。优秀的用户体验不依赖于(也永远不依赖于)编程语言、编译器的选择,或任何其他无意义的东西。如果依赖了,那么不管谁来设计这个抽象层做的不够好的产品,我们都会得到一个失败的作品,需要把它的存在抹去。
|
||||
|
||||
那么在我的展望中,我不在乎是否要吐血十升去编译一个 Xorg 或其它什么的版本。我是一个用户,我所在乎的只是我的桌面能否像它昨天或者 5 年前一样健壮地工作。没事的情况下,我不会对宏、类、变量、声明、结构体,或其他任何极客的计算机科技感兴趣。那是不着边际的。一个产品宣传自己是被创造出来为人们的开发提供方便的,那是个悖论。如果接下来再也不用去开发它了,这样反而会使事情更简单。
|
||||
|
||||
现在,事实是 Wayland 大体上可用,但它仍然不像 Xorg 那么好,并且它也不应该在任何的桌面上作为就绪的产品被提供。一但它能够无人知晓般无缝地取代那些过时技术,只有在那种时候,它才获得了它所需要的成功,那之后,它可以用 C、D 或者 K 之类的无论什么语言编写,拥有开发者需要的任何东西。而在那之前,它都是一个蚕食资源和人们思想的寄生虫而已。
|
||||
|
||||
不要误会,我们需要进步,需要改变。但它必须为了进化的目而服务。现在 Xorg 能很好地满足用户需求了吗?它能为第三方库提供图形支持吗?它能支持 HD、UHD、DPI 或其他的什么吗?你能用它玩最新的游戏吗?行还是不行?如果不行,那么它就需要被改进。这些就是进化的驱动力,而不是写代码或者编译代码的困难程度。软件开发者是数字工业的矿工,他们需要努力工作而取悦于用户。就像短语“更加易于开发”应该被取缔一样,那些崇尚于此的人也应该用老式收音机的电池处以电刑,然后用没有空调的飞船流放到火星上去。如果你不能写出高明的代码,那是你的问题。用户不能因为开发者认为自己是公主而遭受折磨。
|
||||
|
||||
### 结语
|
||||
|
||||
说到这里。大体上说,Wayland 还可以,并不差。但这说的就像是某人决定修改你工资单上分配比例,导致你从昨天能赚 100% 到今天只能赚 83% 一样。讲道理这是不能接受的,即使 Wayland 工作的相当好。正是那些不能运作的东西导致如此大的不同。忽略所有批评它的一面,Wayland 被认为降低了可用性、性能以及软件的知名度,这正是 Fedora 亟待解决的问题。
|
||||
|
||||
其他的发行版会跟进,然后我们会看到历史重演,就像 Gnome 3 和 Systemd 所发生的一样。没有完全准备好的东西被放到开放环境中,然后我们花费一两年时间修复那些本无需修复的东西,最终我们将拥有的是我们已经拥有的相同功能,只是用不同的编程语言来实现。我并不感兴趣这些。计算机科学曾在 1999 年非常受欢迎,当时 Excel 用户每小时能赚 50 美元。而现在,编程就像是躲在平底船下划桨,人们并不会在乎你在甲板下流下的汗水与磨出的水泡。
|
||||
|
||||
性能可能不太是一个问题了,因为你可以放弃 1-2% 的变化,尤其是它会受随机的来自任何一个因素的影响,如果你已经用 Linux 超过一、两年你就会知道的。但是无法启动应用是个大问题。不过至少, Fedora 也友好地提供了传统的平台。但是,它可能会在 Wayland 100% 成熟前就消失了。我们再来看看,不,不会有灾难。我原本的 Fedora 25 宣称支持这种看法。我们有的就是烦恼,不必要的烦恼。啊,这是 Linux 故事中的第 9000 集。
|
||||
|
||||
那么,在今天结束之际,我们已经讨论了所有事情。从中我们学到:**臣伏于 Xorg!天呐!**真棒,现在我将淡入背景音乐,而笑声会将你的欢乐带给寒冷的夜晚。再见!
|
||||
|
||||
干杯。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
作者简介:
|
||||
|
||||
我是 Igor Ljubuncic。现在大约 38 岁,已婚但还没有孩子。我现在在一个大胆创新的云科技公司做首席工程师。直到大约 2015 年初,我还在一个全世界最大的 IT 公司之一中做系统架构工程师,和一个工程计算团队开发新的基于 Linux 的解决方案,优化内核以及攻克 Linux 的问题。在那之前,我是一个为高性能计算环境设计创新解决方案的团队的技术领导。还有一些其他花哨的头衔,包括系统专家、系统程序员等等。所有这些都曾是我的爱好,但从 2008 年开始成为了我的有偿的工作。还有什么比这更令人满意的呢?
|
||||
|
||||
从 2004 年到 2008 年间,我曾通过作为医学影像行业的物理学家来糊口。我的工作专长集中在解决问题和算法开发。为此,我广泛地使用了 Matlab,主要用于信号和图像处理。另外,我得到了几个主要的工程方法学的认证,包括 MEDIC 六西格玛绿带、试验设计以及统计工程学。
|
||||
|
||||
我也写过书,包括高度魔幻类和 Linux 上的技术工作方面的,彼此交织。
|
||||
|
||||
|
||||
-------------
|
||||
|
||||
|
||||
via: http://www.dedoimedo.com/computers/fedora-25-wayland-vs-xorg.html
|
||||
|
||||
作者:[Igor Ljubuncic][a]
|
||||
译者:[cycoe](https://github.com/cycoe)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.dedoimedo.com/faq.html
|
||||
|
||||
[1]:http://www.dedoimedo.com/computers/fedora-25-gnome.html
|
||||
[2]:https://commons.wikimedia.org/wiki/File:DragonCon-AlienVsPredator.jpg
|
||||
[3]:https://creativecommons.org/licenses/by-sa/3.0/deed.en
|
||||
[4]:https://wayland.freedesktop.org/faq.html
|
||||
[5]:https://wiki.gnome.org/Initiatives/Wayland/Applications
|
||||
[6]:https://devtalk.nvidia.com/default/topic/925605/linux/nvidia-364-12-release-vulkan-glvnd-drm-kms-and-eglstreams/
|
||||
[7]:http://www.dedoimedo.com/computers/fedora-24-gnome.html
|
||||
[8]:http://www.dedoimedo.com/computers/lenovo-g50-distros-second-round.html
|
||||
[9]:http://www.ocsmag.com/2016/10/19/systemd-progress-through-complexity/
|
@ -1,10 +1,9 @@
|
||||
Integrate Ubuntu 16.04 to AD as a Domain Member with Samba and Winbind – Part 8
|
||||
Samba 系列(八):使用 Samba 和 Winbind 将 Ubuntu 16.04 添加到 AD 域
|
||||
============================================================
|
||||
使用 Samba 和 Winbind 将 Ubuntu 16.04 添加到 AD 域 ——(八)
|
||||
|
||||
这篇文章讲述了如何将 Ubuntu 主机加入到 Samba4 AD 域,并实现使用域帐号登录 Ubuntu 系统。
|
||||
|
||||
#### 要求:
|
||||
### 要求:
|
||||
|
||||
1. [在 Ubuntu 系统上使用 Samba4 软件来创建活动目录架构][1]
|
||||
|
||||
@ -12,7 +11,7 @@ Integrate Ubuntu 16.04 to AD as a Domain Member with Samba and Winbind – Part
|
||||
|
||||
1、在将 Ubuntu 主机加入到 AD DC 之前,你得先确保 Ubuntu 系统中的一些服务配置正常。
|
||||
|
||||
主机名是你的机器的一个重要标识。因此,在加入域前,使用 hostnamectl 命令或者通过手动编辑 /etc/hostname 文件来为 Ubuntu 主机设置一个合适的主机名。
|
||||
主机名是你的机器的一个重要标识。因此,在加入域前,使用 `hostnamectl` 命令或者通过手动编辑 `/etc/hostname` 文件来为 Ubuntu 主机设置一个合适的主机名。
|
||||
|
||||
```
|
||||
# hostnamectl set-hostname your_machine_short_name
|
||||
@ -23,32 +22,32 @@ Integrate Ubuntu 16.04 to AD as a Domain Member with Samba and Winbind – Part
|
||||
![Set System Hostname](http://www.tecmint.com/wp-content/uploads/2017/03/Set-Ubuntu-System-Hostname.png)
|
||||
][2]
|
||||
|
||||
设置系统主机名
|
||||
*设置系统主机名*
|
||||
|
||||
2、在这一步中,打开并编辑网卡配置文件,为你的主机设置一个合适的 IP 地址。注意把 DNS 地址设置为你的域控制器的地址。
|
||||
|
||||
编辑 /etc/network/interfaces 文件,添加 dns-nameservers 参数,并设置为 AD 服务器的 IP 地址,添加 dns-search 参数,其值为域控制器的主机名,如下图所示。
|
||||
编辑 `/etc/network/interfaces` 文件,添加 `dns-nameservers` 参数,并设置为 AD 服务器的 IP 地址;添加 `dns-search` 参数,其值为域控制器的主机名,如下图所示。
|
||||
|
||||
并且,把上面设置的 DNS IP 地址和域名添加到 /etc/resolv.conf 配置文件中,如下图所示:
|
||||
并且,把上面设置的 DNS IP 地址和域名添加到 `/etc/resolv.conf` 配置文件中,如下图所示:
|
||||
|
||||
[
|
||||
![Configure Network Settings for AD](http://www.tecmint.com/wp-content/uploads/2017/03/Configure-Network-Settings-for-AD.png)
|
||||
][3]
|
||||
|
||||
为 AD 配置网络设置
|
||||
*为 AD 配置网络设置*
|
||||
|
||||
在上面的截图中, 192.168.1.254 和 192.168.1.253 是 Samba4 AD DC 服务器的 IP 地址, Tecmint.lan 是 AD 域名,已加入到这个域中的所有机器都可以查询到该域名。
|
||||
在上面的截图中, `192.168.1.254` 和 `192.168.1.253` 是 Samba4 AD DC 服务器的 IP 地址, `Tecmint.lan` 是 AD 域名,已加入到这个域中的所有机器都可以查询到该域名。
|
||||
|
||||
3、重启网卡服务或者重启计算机以使网卡配置生效。使用 ping 命令加上域名来检测 DNS 解析是否正常。
|
||||
|
||||
AD DC 应该返回的 FQDN 。如果你的网络中配置了 DHCP 服务器来为局域网中的计算机自动分配 IP 地址,请确保你已经把 AD DC 服务器的 IP 地址添加到 DHCP 服务器的 DNS 配置中。
|
||||
AD DC 应该返回的是 FQDN 。如果你的网络中配置了 DHCP 服务器来为局域网中的计算机自动分配 IP 地址,请确保你已经把 AD DC 服务器的 IP 地址添加到 DHCP 服务器的 DNS 配置中。
|
||||
|
||||
```
|
||||
# systemctl restart networking.service
|
||||
# ping -c2 your_domain_name
|
||||
```
|
||||
|
||||
4、最后一步是配置服务器时间同步。安装 ntpdate 包,使用下面的命令来查询并同步 AD DC 服务器的时间。
|
||||
4、最后一步是配置服务器时间同步。安装 `ntpdate` 包,使用下面的命令来查询并同步 AD DC 服务器的时间。
|
||||
|
||||
```
|
||||
$ sudo apt-get install ntpdate
|
||||
@ -59,7 +58,7 @@ $ sudo ntpdate your_domain_name
|
||||
![Time Synchronization with AD](http://www.tecmint.com/wp-content/uploads/2017/03/Time-Synchronization-with-AD.png)
|
||||
][4]
|
||||
|
||||
AD 服务器时间同步
|
||||
*AD 服务器时间同步*
|
||||
|
||||
5、下一步,在 Ubuntu 机器上执行下面的命令来安装加入域环境所必需软件。
|
||||
|
||||
@ -70,7 +69,7 @@ $ sudo apt-get install samba krb5-config krb5-user winbind libpam-winbind libnss
|
||||
![Install Samba4 in Ubuntu Client](http://www.tecmint.com/wp-content/uploads/2017/03/Install-Samba4-in-Ubuntu-Client.png)
|
||||
][5]
|
||||
|
||||
在 Ubuntu 机器上安装 Samba4 软件
|
||||
*在 Ubuntu 机器上安装 Samba4 软件*
|
||||
|
||||
在 Kerberos 软件包安装的过程中,你会被询问输入默认的域名。输入大写的域名,并按 Enter 键继续安装。
|
||||
|
||||
@ -78,7 +77,7 @@ $ sudo apt-get install samba krb5-config krb5-user winbind libpam-winbind libnss
|
||||
![Add AD Domain Name](http://www.tecmint.com/wp-content/uploads/2017/03/Add-AD-Domain-Name.png)
|
||||
][6]
|
||||
|
||||
添加 AD 域名
|
||||
*添加 AD 域名*
|
||||
|
||||
6、当所有的软件包安装完成之后,使用域管理员帐号来测试 Kerberos 认证,然后执行下面的命令来列出票据信息。
|
||||
|
||||
@ -90,7 +89,7 @@ $ sudo apt-get install samba krb5-config krb5-user winbind libpam-winbind libnss
|
||||
![Check Kerberos Authentication with AD](http://www.tecmint.com/wp-content/uploads/2017/03/Check-Kerberos-Authentication-with-AD.png)
|
||||
][7]
|
||||
|
||||
使用 AD 来检查 Kerberos 认证是否正常
|
||||
*使用 AD 来检查 Kerberos 认证是否正常*
|
||||
|
||||
### 第二步:将 Ubuntu 主机添加到 Samba4 AD DC
|
||||
|
||||
@ -129,11 +128,11 @@ store dos attributes = Yes
|
||||
![Configure Samba for AD](http://www.tecmint.com/wp-content/uploads/2017/03/Configure-Samba.png)
|
||||
][8]
|
||||
|
||||
Samba 服务的 AD 环境配置
|
||||
*Samba 服务的 AD 环境配置*
|
||||
|
||||
根据你本地的实际情况来替换 workgroup , realm , netbios name 和 dns forwarder 的参数值。
|
||||
根据你本地的实际情况来替换 `workgroup` , `realm` , `netbios name` 和 `dns forwarder` 的参数值。
|
||||
|
||||
由于 winbind use default domain 这个参数会让 winbind 服务把任何登录系统的帐号都当作 AD 帐号。因此,如果存在本地帐号名跟域帐号同名的情况下,请不要设置该参数。
|
||||
由于 `winbind use default domain` 这个参数会让 winbind 服务把任何登录系统的帐号都当作 AD 帐号。因此,如果存在本地帐号名跟域帐号同名的情况下,请不要设置该参数。
|
||||
|
||||
8、现在,你应该重启 Samba 后台服务,停止并卸载一些不必要的服务,然后启用 samba 服务的 system-wide 功能,使用下面的命令来完成。
|
||||
|
||||
@ -153,7 +152,7 @@ $ sudo net ads join -U ad_admin_user
|
||||
![Join Ubuntu to Samba4 AD DC](http://www.tecmint.com/wp-content/uploads/2017/03/Join-Ubuntu-to-Samba4-AD-DC.png)
|
||||
][9]
|
||||
|
||||
把 Ubuntu 主机加入到 Samba4 AD DC
|
||||
*把 Ubuntu 主机加入到 Samba4 AD DC*
|
||||
|
||||
10、在 [安装了 RSAT 工具的 Windows 机器上][10] 打开 AD UC ,展开到包含的计算机。你可以看到已加入域的 Ubuntu 计算机。
|
||||
|
||||
@ -161,7 +160,7 @@ $ sudo net ads join -U ad_admin_user
|
||||
![Confirm Ubuntu Client in Windows AD DC](http://www.tecmint.com/wp-content/uploads/2017/03/Confirm-Ubuntu-Client-in-RSAT-.png)
|
||||
][11]
|
||||
|
||||
确认 Ubuntu 计算机已加入到 Windows AD DC
|
||||
*确认 Ubuntu 计算机已加入到 Windows AD DC*
|
||||
|
||||
### 第三步:配置 AD 帐号认证
|
||||
|
||||
@ -173,7 +172,7 @@ $ sudo net ads join -U ad_admin_user
|
||||
$ sudo nano /etc/nsswitch.conf
|
||||
```
|
||||
|
||||
然后在 passwd 和 group 行添加 winbind 值,如下图所示:
|
||||
然后在 `passwd` 和 `group` 行添加 winbind 值,如下图所示:
|
||||
|
||||
```
|
||||
passwd: compat winbind
|
||||
@ -183,9 +182,9 @@ group: compat winbind
|
||||
![Configure AD Accounts Authentication](http://www.tecmint.com/wp-content/uploads/2017/03/Configure-AD-Accounts-Authentication.png)
|
||||
][12]
|
||||
|
||||
配置 AD 帐号认证
|
||||
*配置 AD 帐号认证*
|
||||
|
||||
12、为了测试 Ubuntu 机器是否已加入到域中,你可以使用 wbinfo 命令来列出域帐号和组。
|
||||
12、为了测试 Ubuntu 机器是否已加入到域中,你可以使用 `wbinfo` 命令来列出域帐号和组。
|
||||
|
||||
```
|
||||
$ wbinfo -u
|
||||
@ -195,9 +194,9 @@ $ wbinfo -g
|
||||
![List AD Domain Accounts and Groups](http://www.tecmint.com/wp-content/uploads/2017/03/List-AD-Domain-Accounts-and-Groups.png)
|
||||
][13]
|
||||
|
||||
列出域帐号和组
|
||||
*列出域帐号和组*
|
||||
|
||||
13、同时,使用 getent 命令加上管道符及 grep 参数来过滤指定域用户或组,以测试 Winbind nsswitch 模块是否运行正常。
|
||||
13、同时,使用 `getent` 命令加上管道符及 `grep` 参数来过滤指定域用户或组,以测试 Winbind nsswitch 模块是否运行正常。
|
||||
|
||||
```
|
||||
$ sudo getent passwd| grep your_domain_user
|
||||
@ -207,9 +206,9 @@ $ sudo getent group|grep 'domain admins'
|
||||
![Check AD Domain Users and Groups](http://www.tecmint.com/wp-content/uploads/2017/03/Check-AD-Domain-Users-and-Groups.png)
|
||||
][14]
|
||||
|
||||
检查 AD 域用户和组
|
||||
*检查 AD 域用户和组*
|
||||
|
||||
14、为了让域帐号在 Ubuntu 机器上完成认证登录,你需要使用 root 帐号运行 pam-auth-update 命令,然后勾选 winbind 服务所需的选项,以让每个域帐号首次登录时自动创建 home 目录。
|
||||
14、为了让域帐号在 Ubuntu 机器上完成认证登录,你需要使用 root 帐号运行 `pam-auth-update` 命令,然后勾选 winbind 服务所需的选项,以让每个域帐号首次登录时自动创建 home 目录。
|
||||
|
||||
查看所有的选项,按 ‘[空格]’键选中,单击 OK 以应用更改。
|
||||
|
||||
@ -220,9 +219,9 @@ $ sudo pam-auth-update
|
||||
![Authenticate Ubuntu with Domain Accounts](http://www.tecmint.com/wp-content/uploads/2017/03/Authenticate-Ubuntu-with-Domain-Accounts.png)
|
||||
][15]
|
||||
|
||||
使用域帐号登录 Ubuntu 主机
|
||||
*使用域帐号登录 Ubuntu 主机*
|
||||
|
||||
15、在 Debian 系统中,如果想让系统自动为登录的域帐号创建家目录,你需要手动编辑 /etc/pam.d/common-account 配置文件,并添加下面的内容。
|
||||
15、在 Debian 系统中,如果想让系统自动为登录的域帐号创建家目录,你需要手动编辑 `/etc/pam.d/common-account` 配置文件,并添加下面的内容。
|
||||
|
||||
```
|
||||
session required pam_mkhomedir.so skel=/etc/skel/ umask=0022
|
||||
@ -231,9 +230,9 @@ session required pam_mkhomedir.so skel=/etc/skel/ umask=0022
|
||||
![Authenticate Debian with Domain Accounts](http://www.tecmint.com/wp-content/uploads/2017/03/Authenticate-Debian-with-Domain-Accounts.png)
|
||||
][16]
|
||||
|
||||
使用域帐号登录 Debian 系统
|
||||
*使用域帐号登录 Debian 系统*
|
||||
|
||||
16、为了让 AD 用户能够在 Linux 的命令行下修改密码,你需要打开 /etc/pam.d/common-password 配置文件,在 password 那一行删除 use_authtok 参数,如下图所示:
|
||||
16、为了让 AD 用户能够在 Linux 的命令行下修改密码,你需要打开 /etc/pam.d/common-password 配置文件,在 `password` 那一行删除 `use_authtok` 参数,如下图所示:
|
||||
|
||||
```
|
||||
password [success=1 default=ignore] pam_winbind.so try_first_pass
|
||||
@ -242,9 +241,9 @@ password [success=1 default=ignore] pam_winbind.so try_first_pass
|
||||
![Users Allowed to Change Password](http://www.tecmint.com/wp-content/uploads/2017/03/AD-Domain-Users-Change-Password.png)
|
||||
][17]
|
||||
|
||||
允许域帐号在 Linux 命令行下修改密码
|
||||
*允许域帐号在 Linux 命令行下修改密码*
|
||||
|
||||
17、要使用 Samba4 AD 帐号来登录 Ubuntu 主机,在 su - 后面加上域用户名即可。你还可以通过运行 id 命令来查看 AD 帐号的其它信息。
|
||||
17、要使用 Samba4 AD 帐号来登录 Ubuntu 主机,在 `su -` 后面加上域用户名即可。你还可以通过运行 `id` 命令来查看 AD 帐号的其它信息。
|
||||
|
||||
```
|
||||
$ su - your_ad_user
|
||||
@ -253,9 +252,9 @@ $ su - your_ad_user
|
||||
![Find AD User Information](http://www.tecmint.com/wp-content/uploads/2017/03/Find-AD-User-Information.png)
|
||||
][18]
|
||||
|
||||
查看 AD 用户信息
|
||||
*查看 AD 用户信息*
|
||||
|
||||
使用 [pwd 命令][19]来查看域帐号的当前目录,如果你想修改域帐号的密码,你可以使用 passwd 命令来完成。
|
||||
使用 [pwd 命令][19]来查看域帐号的当前目录,如果你想修改域帐号的密码,你可以使用 `passwd` 命令来完成。
|
||||
|
||||
18、如果想让域帐号在 ubuntu 机器上拥有 root 权限,你可以使用下面的命令来把 AD 帐号添加到 sudo 系统组中:
|
||||
|
||||
@ -263,15 +262,15 @@ $ su - your_ad_user
|
||||
$ sudo usermod -aG sudo your_domain_user
|
||||
```
|
||||
|
||||
登录域帐号登录到 Ubuntu 主机,然后运行 apt-get-update 命令来更新系统,以验证域账号是否拥有 root 权限。
|
||||
登录域帐号登录到 Ubuntu 主机,然后运行 `apt-get-update` 命令来更新系统,以验证域账号是否拥有 root 权限。
|
||||
|
||||
[
|
||||
![Add Sudo User Root Group](http://www.tecmint.com/wp-content/uploads/2017/03/Add-Sudo-User-Root-Group.png)
|
||||
][20]
|
||||
|
||||
给域帐号添加 root 权限
|
||||
*给域帐号添加 root 权限*
|
||||
|
||||
19、要为整个域用户组添加 root 权限,使用 vi 命令打开并编辑 /etc/sudoers 配置文件,如下图所示,添加如下内容:
|
||||
19、要为整个域用户组添加 root 权限,使用 `vi` 命令打开并编辑 `/etc/sudoers` 配置文件,如下图所示,添加如下内容:
|
||||
|
||||
```
|
||||
%YOUR_DOMAIN\\your_domain\ group ALL=(ALL:ALL) ALL
|
||||
@ -280,13 +279,13 @@ $ sudo usermod -aG sudo your_domain_user
|
||||
![Add Root Privileges to Domain Group](http://www.tecmint.com/wp-content/uploads/2017/03/Add-Root-Privileges-to-Domain-Group.jpg)
|
||||
][21]
|
||||
|
||||
为域帐号组添加 root 权限
|
||||
*为域帐号组添加 root 权限*
|
||||
|
||||
使用反斜杠来转义域用户组的名称中包含的空格,或者用来转义第一个反斜杠。在上面的例子中, TECMINT 域的域用户组的名字是 “domain admins" 。
|
||||
|
||||
前边的 `(%)` 表明我们指定是的用户组而不是用户名。
|
||||
前边的 `%` 表明我们指定是的用户组而不是用户名。
|
||||
|
||||
20、如果你使用的是图形界面的 Ubuntu 系统,并且你想使用域帐号来登录系统,你需要修改 LightDM 显示管理器,编辑 /usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf 配置文件,添加下面的内容,然后重启系统才能生效。
|
||||
20、如果你使用的是图形界面的 Ubuntu 系统,并且你想使用域帐号来登录系统,你需要修改 LightDM 显示管理器,编辑 `/usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf` 配置文件,添加下面的内容,然后重启系统才能生效。
|
||||
|
||||
```
|
||||
greeter-show-manual-login=true
|
||||
@ -307,7 +306,7 @@ via: http://www.tecmint.com/join-ubuntu-to-active-directory-domain-member-samba-
|
||||
|
||||
作者:[Matei Cezar][a]
|
||||
译者:[rusking](https://github.com/rusking)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
@ -3,32 +3,25 @@
|
||||
|
||||
![cockpit](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/cockpit-containers.jpg?itok=D3MMNlkg "cockpit")
|
||||
|
||||
如果你正在寻找一种简单的方法来管理包含容器的 Linux 服务器,那么你应该看看 Cockpit。
|
||||
[Creative Commons Zero][6]
|
||||
> 如果你正在寻找一种管理运行容器的 Linux 服务器的简单方法,那么你应该看看 Cockpit。
|
||||
|
||||
如果你管理着一台 Linux 服务器,那么你可能正在寻找一个可靠的管理工具。为了这个你可能已经看了 [Webmin][14] 和 [cPanel][15] 这类软件。但是,如果你正在寻找一种简单的方法来管理还包括 Docker 的 Linux 服务器,那么有一个工具可以用于这个需求:[Cockpit][16]。
|
||||
如果你管理着一台 Linux 服务器,那么你可能正在寻找一个可靠的管理工具。为了这个你可能已经看了 [Webmin][14] 和 [cPanel][15] 这类软件。但是,如果你正在寻找一种简单的方法来管理还包括了 Docker 的 Linux 服务器,那么有一个工具可以用于这个需求:[Cockpit][16]。
|
||||
|
||||
为什么使用 Cockpit?因为它可以处理管理任务,例如:
|
||||
为什么使用 Cockpit?因为它可以处理这些管理任务:
|
||||
|
||||
* 连接并管理多台机器
|
||||
|
||||
* 通过 Docker 管理容器
|
||||
|
||||
* 与 Kubernetes 或 Openshift 集群进行交互
|
||||
|
||||
* 修改网络设置
|
||||
|
||||
* 管理用户帐号
|
||||
|
||||
* 访问基于 Web 的 shell
|
||||
|
||||
* 通过基于 Web 的 shell 访问
|
||||
* 通过图表查看系统性能信息
|
||||
|
||||
* 查看系统服务和日志文件
|
||||
|
||||
Cockpit 可以安装在 [Debian][17]、[Red Hat][18]、[CentOS][19]、[Arch Linux][20] 和 [Ubuntu][21] 之上。在这里,我将使用一台已经安装了 Docker 的 Ubuntu 16.04 服务器来安装系统。
|
||||
|
||||
在上面的功能列表中,其中最突出的是容器管理。为什么?因为它使安装和管理容器变得非常简单。事实上,你可能很难找到更好的容器管理解决方案。
|
||||
|
||||
因此,让我们来安装这个方案并看看它的使用是多么简单。
|
||||
|
||||
### 安装
|
||||
@ -39,7 +32,7 @@ Cockpit 可以安装在 [Debian][17]、[Red Hat][18]、[CentOS][19]、[Arch Linu
|
||||
sudo add-apt-repository ppa:cockpit-project/cockpit
|
||||
```
|
||||
|
||||
出现提示时,按下键盘上的 Enter 键,等待提示返回。一旦返回到 bash 提示符,使用下面的命令来更新 apt:
|
||||
出现提示时,按下键盘上的回车键,等待提示返回。一旦返回到 bash 提示符,使用下面的命令来更新 apt:
|
||||
|
||||
```
|
||||
sudo apt-get get update
|
||||
@ -62,17 +55,16 @@ sudo systemctl enable cockpit
|
||||
|
||||
### 登录到 Cockpit
|
||||
|
||||
要访问 Cockpit 的 web 界面,打开浏览器(与 Cockpit 服务器在同一个网络内),输入 http://IP_OF_SERVER:9090,你就会看到登录页面(图 1)。
|
||||
要访问 Cockpit 的 web 界面,打开浏览器(与 Cockpit 服务器在同一个网络内),输入 `http://IP_OF_SERVER:9090`,你就会看到登录页面(图 1)。
|
||||
|
||||
![login](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/cockpit_a.jpg?itok=RViOst2V "login")
|
||||
|
||||
*图 1:Cockpit 登录页面。[授权使用][1]*
|
||||
*图 1:Cockpit 登录页面。*
|
||||
|
||||
在 Ubuntu 中使用 Cockpit 有个警告。Cockpit 中的很多任务需要管理员权限。如果你使用标准用户登录,则无法使用 Docker 等一些工具。 要解决这个问题,你可以在 Ubuntu 上启用 root 用户。但这并不总是一个好主意。通过启用 root 帐户,你将绕过多年来一直存在的安全系统。但是,为了本文,我将使用以下两个命令启用 root 用户:
|
||||
在 Ubuntu 中使用 Cockpit 有个警告。Cockpit 中的很多任务需要管理员权限。如果你使用普通用户登录,则无法使用 Docker 等一些工具。 要解决这个问题,你可以在 Ubuntu 上启用 root 用户。但这并不总是一个好主意。通过启用 root 帐户,你将绕过已经建立多年的安全系统。但是,在本文的用途中,我将使用以下两个命令启用 root 用户:
|
||||
|
||||
```
|
||||
sudo passwd root
|
||||
|
||||
sudo passwd -u root
|
||||
```
|
||||
|
||||
@ -84,15 +76,15 @@ sudo passwd -u root
|
||||
sudo passwd -l root
|
||||
```
|
||||
|
||||
在其他发行版(如 CentOS 和 Red Hat)中,你可以使用用户名 _root_ 和 root 密码登录 Cockpit,而无需像上面那样需要额外的步骤。
|
||||
在其他发行版(如 CentOS 和 Red Hat)中,你可以使用用户名 `root` 及其密码登录 Cockpit,而无需像上面那样需要额外的步骤。
|
||||
|
||||
如果你对启用 root 用户感到担心,则可以在服务终端拉取镜像(使用命令 _docker pull IMAGE_NAME _, 这里的 _IMAGE_NAME_ 是你要拉取的镜像)。这会将镜像添加到你的 docker 服务器中,然后可以通过普通用户进行管理。唯一需要注意的是,普通用户必须使用以下命令将自己添加到 Docker 组:
|
||||
如果你对启用 root 用户感到担心,则可以在服务器的终端窗口拉取镜像(使用命令 `docker pull IMAGE_NAME`, 这里的 `IMAGE_NAME` 是你要拉取的镜像)。这会将镜像添加到你的 docker 服务器中,然后可以通过普通用户进行管理。唯一需要注意的是,普通用户必须使用以下命令将自己添加到 Docker 组:
|
||||
|
||||
```
|
||||
sudo usermod -aG docker USER
|
||||
```
|
||||
|
||||
其中,USER 是实际添加到组的用户名。在你完成后,重新登出并登入,接着使用下面的命令重启 Docker:
|
||||
其中,`USER` 是实际添加到组的用户名。在你完成后,重新登出并登入,接着使用下面的命令重启 Docker:
|
||||
|
||||
```
|
||||
sudo service docker restart
|
||||
@ -104,24 +96,23 @@ sudo service docker restart
|
||||
|
||||
一旦你登录后,你可以看到 Cockpit 的主界面(图 2)。
|
||||
|
||||
|
||||
![main window](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/cockpit_b.jpg?itok=tZCHcq-Y "main window")
|
||||
|
||||
*图 2:Cockpit 主界面。[授权使用][2]*
|
||||
*图 2:Cockpit 主界面。*
|
||||
|
||||
你可以通过每个栏目来检查服务器的状态,与用户合作等,但是我们想要直接进入容器。单击 “Containers” 那栏以显示当前运行的以及可用的镜像(图3)。
|
||||
你可以通过每个栏目来检查服务器的状态等,但是我们想要直接进入容器。单击 “Containers” 那栏以显示当前运行的以及可用的镜像(图3)。
|
||||
|
||||
![Cockpit](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/cockpit_c.jpg?itok=OOYJt2yv "Cockpit")
|
||||
|
||||
*图 3:使用 Cockpit 管理容器难以置信地简单。[授权使用][3]*
|
||||
*图 3:使用 Cockpit 管理容器难以置信地简单。*
|
||||
|
||||
要启动一个镜像,只要找到镜像并点击关联的启动按钮。在弹出的窗口中(图 4),你可以在点击运行之前查看所有镜像的信息(并根据需要调整)。
|
||||
|
||||
![Running Docker image](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/cockpit_d.jpg?itok=8uldEq_r "Running Docker image")
|
||||
|
||||
*图 4: 使用 Cockpit 运行 Docker 镜像。[授权使用][4]*
|
||||
*图 4: 使用 Cockpit 运行 Docker 镜像。*
|
||||
|
||||
镜像运行后,你可以点击它查看状态,并可以停止、重启、删除示例。你也可以点击修改资源限制并接着调整内存限制还有(或者)CPU 优先级。
|
||||
镜像运行后,你可以点击它查看状态,并可以停止、重启、删除实例。你也可以点击修改资源限制并接着调整内存限制还有(或者)CPU 优先级。
|
||||
|
||||
### 添加新的镜像
|
||||
|
||||
@ -129,13 +120,13 @@ sudo service docker restart
|
||||
|
||||
![Adding image](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/cockpit_f.jpg?itok=_S5g8Da2 "Adding image")
|
||||
|
||||
*图 5:使用 Cockpit 添加最新的官方构建 CentOS 镜像到 Docker 中。[授权使用][5]*
|
||||
*图 5:使用 Cockpit 添加最新的官方构建 CentOS 镜像到 Docker 中。*
|
||||
|
||||
镜像下载完后,那它就在 Docker 中可用了,并可以通过 Cockpit 运行。
|
||||
|
||||
### 如获取它那样简单
|
||||
|
||||
管理 Docker 并不容易。是的,在 Ubuntu 上运行 Cockpit 会有一个警告,但如果这是你唯一的选择,那么还有办法让它工作。在 Cockpit 的帮助下,你不仅可以轻松管理 Docker 镜像,也可以在任何可以访问 Linux 服务器的 web 浏览器上这样做。请享受这个新发现的容易使用 Docker 的方法。
|
||||
管理 Docker 并不容易。是的,在 Ubuntu 上运行 Cockpit 会有一个警告,但如果这是你唯一的选择,那么也有办法让它工作。在 Cockpit 的帮助下,你不仅可以轻松管理 Docker 镜像,也可以在任何可以访问 Linux 服务器的 web 浏览器上这样做。请享受这个新发现的让 Docker 易用的方法。
|
||||
|
||||
_在 Linux Foundation 以及 edX 中通过免费的 ["Introduction to Linux"][13] 课程学习 Linux。_
|
||||
|
@ -3,13 +3,13 @@
|
||||
|
||||
> 你是否在为小型企业或家庭办公室寻找电话系统?
|
||||
|
||||
|
||||
![How to install Asterisk on the Raspberry Pi](https://opensource.com/sites/default/files/styles/image-full-size/public/images/life/life-raspberrypi_0.png?itok=wxVxQ0Z4 "How to install Asterisk on the Raspberry Pi")
|
||||
|
||||
>图片版权: Dwight Sipler 的 [Flickr][8]
|
||||
|
||||
你是否在为小型企业或家庭办公室寻找电话系统?我一直对可扩展 VoIP(Voice over IP)解决方案感兴趣,后来我在树莓派上找到 [Asterisk][9] 的一个实现。
|
||||
|
||||
我的好奇心被激起了,我决心尝试一下,所以我从 [Asterisk][11] 官网[下载][10]了它,然后使用我的树莓派 3 构建服务器。
|
||||
我的好奇心被激起了,我决心尝试一下,所以我从 [Asterisk][11] 官网[下载][10]了它(RasPBX),然后使用我的树莓派 3 构建服务器。
|
||||
|
||||
### 准备开始
|
||||
|
||||
@ -17,36 +17,35 @@
|
||||
|
||||
更多关于树莓派的内容:
|
||||
|
||||
* [我们最新的树莓派教程][1]
|
||||
* [什么是树莓派?][2]
|
||||
* [开始使用树莓派][3]
|
||||
* [给我们发送你的树莓派项目和教程][4]
|
||||
|
||||
接下来,我在 Linux 上打开一个终端,并输入 **ssh root@192.168.1.8**,这是我的服务器的 IP 地址。我被提示以 root 用户身份登录到 **raspbx** 上。默认密码是 “raspberry”。 (出于安全考虑,如果你打算再多试试,请务必更改默认密码。)
|
||||
接下来,我在 Linux 上打开一个终端,并输入 `ssh root@192.168.1.8`,这是我的服务器的 IP 地址。我被提示以 `root` 用户身份登录到 RasPBX 上。默认密码是 `raspberry`。 (出于安全考虑,如果你打算再多试试,请务必更改默认密码。)
|
||||
|
||||
当我登录到了 raspbx 上的 shell 后,接下来我需要准备配置了。根据网站上提供的[文档][12],我在 shell 下输入 **regen-hostkeys** 来创建新的主机密钥。然后输入 **configure-timezone** 来配置服务器的时区。我通过在提示符下输入 **dpkg-reconfigure locales** 来配置区域设置。我也安装了 [Fail2Ban][13] 来提供服务器的安全性。
|
||||
当我登录到了 RasPBX 上的 shell 后,接下来我需要准备配置了。根据网站上提供的[文档][12],我在 shell 下输入 `regen-hostkeys` 来创建新的主机密钥。然后输入 `configure-timezone` 来配置服务器的时区。我通过在提示符下输入 `dpkg-reconfigure locales` 来配置区域设置。我也安装了 [Fail2Ban][13] 来保障服务器的安全性。
|
||||
|
||||
现在我准备测试我的配置。
|
||||
|
||||
### 测试
|
||||
|
||||
我从 **raspbx** shell 中登出,然后打开浏览器并输入我的服务器的 IP 地址。将服务器 IP 地址加载到浏览器中,我看到了一个可爱的登录页面。
|
||||
我从 RasPBX 的 shell 中登出,然后打开浏览器并输入我的服务器的 IP 地址。将服务器 IP 地址加载到浏览器中,我看到了一个可爱的登录页面。
|
||||
|
||||
[FreePBX][14] 提供了一个非常好的基于 Web 的开源图形用户界面,我用它来控制和配置 Asterisk(在 [GitHub][15] 上找到)。(FreePBX 是 GPL 许可的)。我用它来完成其余的配置。FreePBX 的默认登录账号为 **用户名:admin; 密码:admin**。
|
||||
[FreePBX][14] 提供了一个非常好的基于 Web 的开源图形用户界面,我用它来控制和配置 Asterisk(可在 [GitHub][15] 上找到)。(FreePBX 是 GPL 许可的)。我用它来完成其余的配置。FreePBX 的默认登录账号为用户名:`admin`; 密码:`admin`。
|
||||
|
||||
![FreePBX_Login_Screen](https://opensource.com/sites/default/files/freepbx_login_screen.png "FreePBX_Login_Screen")
|
||||
|
||||
登录之后,我进入位于显示屏左上方的<ruby>应用菜单<rt>Application Menu</rt></ruby>。点击菜单链接并选择了第二个选项,即 <ruby>“应用”<rt>Applications</rt></ruby>,接着选择了第四个选项,<ruby>“分机”<rt>Extensions</rt></ruby>。从那里我选择创建一个 **New Chan_Sip** 分机。
|
||||
登录之后,我进入位于显示屏左上方的<ruby>应用菜单<rt>Application Menu</rt></ruby>。点击菜单链接并选择了第二个选项,即 <ruby>“应用”<rt>Applications</rt></ruby>,接着选择了第四个选项,<ruby>“分机”<rt>Extensions</rt></ruby>。从那里我选择创建一个 New Chan_Sip 分机。
|
||||
|
||||
![](https://opensource.com/sites/default/files/add_a_new_chan_sip_extension.png)
|
||||
|
||||
我使用密码配置了一个 **sip** 分机用户。密码是自动生成的,也可以选择创建自己的密码。
|
||||
我使用密码配置了一个 sip 分机用户。密码是自动生成的,也可以选择创建自己的密码。
|
||||
|
||||
现在我有了一个完整的分机,我急于尝试我的新的 VoIP 服务器。我下载并安装了[ Yate 客户端][16],这是在构建服务器的过程中发现的。安装 [Yate][17] 之后,我想测试与服务器的连接。我发现我可以使用 Yate 连接到服务器并输入 \*43 进行回声测试。当我听到客户端指示时,我感到很激动。
|
||||
现在我有了一个完整的分机,我急于尝试我的新的 VoIP 服务器。我下载并安装了 [Yate 客户端][16],这是在构建服务器的过程中发现的。安装 [Yate][17] 之后,我想测试与服务器的连接。我发现我可以使用 Yate 连接到服务器并输入 `*43` 进行回声测试。当我听到客户端指示时,我感到很激动。
|
||||
|
||||
![](https://opensource.com/sites/default/files/echotest.png)
|
||||
|
||||
我决定创建另外一个 **sip** 分机,这样我就可以测试系统的语音信箱功能。 在完成后,我使用 Yate 客户端来呼叫这个分机,并留下了简短的语音留言。然后再次使用 Yate 呼叫该分机并输入 \*97 来检索语音留言。然后我想看看我是否可以使用我的新服务器来呼叫外线。返回到菜单,选择 <ruby>“连接”<rt>Connectivity</rt></ruby> 选项,并添加了 Google Voice 号码。
|
||||
我决定创建另外一个 sip 分机,这样我就可以测试系统的语音信箱功能。 在完成后,我使用 Yate 客户端来呼叫这个分机,并留下了简短的语音留言。然后再次使用 Yate 呼叫该分机并输入 `*97` 来检索语音留言。然后我想看看我是否可以使用我的新服务器来呼叫外线。返回到菜单,选择 <ruby>“连接”<rt>Connectivity</rt></ruby> 选项,并添加了 Google Voice 号码。
|
||||
|
||||
![Google_Voice_Connectivity](https://opensource.com/sites/default/files/google_voice_connectivity.png "Google_Voice_Connectivity")
|
||||
|
||||
@ -54,15 +53,15 @@
|
||||
|
||||
![Google_Voice_outbound_route](https://opensource.com/sites/default/files/google_voice_outbound_route.png "Google_Voice_outbound_route")
|
||||
|
||||
### 完成一个电话
|
||||
### 完成一个呼叫
|
||||
|
||||
回到 Yate 客户端,我呼叫了一个外线并成功完成了这个电话。
|
||||
回到 Yate 客户端,我呼叫了一个外线并成功完成了这个呼叫。
|
||||
|
||||
我相信这个特定的 VoIP 解决方案可以轻松地为一个小型办公室工作。根据 RasPBX 网站的[常见问题][18]部分,典型的树莓派系统可以在树莓派 1 上支持多达 10 个并发呼叫。
|
||||
|
||||
Asterisk 有很多细微差别的功能,FreePBX 则可以很容易地利用它们。
|
||||
|
||||
_关于树莓派上的 Asterisk 的更多信息,请参考他们的[博客][5]。你可以在他们的网站上找到有关[ FreePBX 源代码][6]的其他信息。
|
||||
_关于树莓派上的 Asterisk 的更多信息,请参考他们的[博客][5]。你可以在他们的网站上找到有关[ FreePBX 源代码][6]的其他信息。_
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
151
published/20170423 THE STORY OF GETTING SSH PORT 22.md
Normal file
151
published/20170423 THE STORY OF GETTING SSH PORT 22.md
Normal file
@ -0,0 +1,151 @@
|
||||
SSH 协议端口号 22 背后的故事
|
||||
======================
|
||||
|
||||
为什么 [SSH][4](安全终端)的端口号是 22 呢,这不是一个巧合,这其中有个我([Tatu Ylonen](https://www.ssh.com/people/tatu-ylonen),SSH 协议的设计者)未曾诉说的故事。
|
||||
|
||||
### 将 SSH 协议端口号设为 22 的故事
|
||||
|
||||
1995 年春我编写了 SSH 协议的最初版本,那时候 [telnet][5] 和 [FTP][6] 正被广泛使用。
|
||||
|
||||
当时我设计 SSH 协议想着是为了替代 `telnet`(端口 23)和 `ftp`(端口21)两个协议的,而端口 22 是空闲的。我想当然地就选择了夹在 `telnet` 和 `ftp` 的端口中间的数字。我觉得端口号虽然是个小事但似乎又存在着某种信念。但我到底要怎么拿到那个端口号呢?我未曾拥有过任何一个端口号,但我却认识几个拥有端口号的人!
|
||||
|
||||
在那时取得端口号的事情其实说来挺简单的。毕竟当时的因特网(Internet)并不是很大,是因特网爆炸的早期。端口号分配的活儿是 IANA(Internet Assigned Numbers Authority,互联网数字分配机构)干的。在那时这机构可相当于是因特网先驱 [Jon Postel][7] 和 [Joyce K. Reynolds][8] 一般的存在。Jon 参与编写了多项主要的协议标准,例如 IP(RFC 791)、ICMP(RFC 792)和 TCP(RFC 793)等一些你应该早有耳闻的协议。
|
||||
|
||||
我可以说是敬畏 Jon 先生的,他参与编写了几乎所有主要的因特网标准文档(Internet RFC)!
|
||||
|
||||
1995 年 7 月,就在我发布 `ssh-1.0` 前,我发送了一封邮件给 IANA:
|
||||
|
||||
```
|
||||
From ylo Mon Jul 10 11:45:48 +0300 1995
|
||||
From: Tatu Ylonen <ylo@cs.hut.fi>
|
||||
To: Internet Assigned Numbers Authority <iana@isi.edu>
|
||||
Subject: 请求取得一个端口号
|
||||
Organization: 芬兰赫尔辛基理工大学
|
||||
|
||||
亲爱的机构成员:
|
||||
|
||||
我写了个可以在不安全的网络环境中安全地从一台机器登录到另一台机器的程序。它主要是对现有的
|
||||
telnet 协议以及 rlogin 协议的功能性提升和安全性改进。说的具体些,就是可以防御 IP、DNS
|
||||
或路由等欺骗行为。我打算将我的软件免费地发布在因特网上,以得到广泛地使用。
|
||||
|
||||
我希望为该软件注册一个特权端口号,要是这个端口号在 1 到 255 之间就更好了,这样它就可以用
|
||||
在名字服务器的 WKS 字段中了。
|
||||
|
||||
我在附件中附上了协议标准的草案。这个软件已经在本地运行了几个月了,我已准备在获得端口号后
|
||||
就发布。如果端口号分配一事安排的及时,我希望这周就将要发布的软件准备好。我目前在 beta 版
|
||||
测试时使用的端口号是 22,如果要是能够分配到这个端口,我就不用做什么更改了(目前这个端口在
|
||||
列表中还是空闲的)。
|
||||
|
||||
软件中服务的名称叫 `ssh`(系 Secure Shell 的缩写)。
|
||||
|
||||
您最真诚的,
|
||||
|
||||
Tatu Ylonen <ylo@cs.hut.fi>
|
||||
|
||||
... 附件:ssh-1.0 协议标准
|
||||
```
|
||||
|
||||
(LCTT 译注:DNS 协议中的 WKS 记录类型意即“众所周知的业务描述”,是类似于 A、MX 这样的 DNS 记录类型,用于描述某个 IP 所提供的服务,目前鲜见使用。参见: https://docs.oracle.com/cd/E19683-01/806-4077/dnsintro-154/index.html 。)
|
||||
|
||||
第二天,我就收到了 Joyce 发来的邮件:
|
||||
|
||||
```
|
||||
Date: Mon, 10 Jul 1995 15:35:33 -0700
|
||||
From: jkrey@ISI.EDU
|
||||
To: ylo@cs.hut.fi
|
||||
Subject: 回复:请求取得一个端口号
|
||||
Cc: iana@ISI.EDU
|
||||
|
||||
Tatu,
|
||||
|
||||
我们将端口号 22 分配给 ssh 服务了,你目前是该服务的主要联系人。
|
||||
|
||||
Joyce
|
||||
```
|
||||
|
||||
这就搞定了!SSH 的端口正式使用 22!!!
|
||||
|
||||
1995 年 7 月 12 日上午 2 点 21 分,我给我在赫尔辛基理工大学的测试者们宣布了 SSH 的最后 beta 版本。当日下午 5 点 23 分,我给测试者们宣布了 ssh-1.0.0 版本。1995 年 7 月 12 日,下午 5 点 51 分,我将一份 SSH(安全终端)的宣告发给了 `cypherpunks@toad.com` 的邮件列表,此外我还将其发给了一些新闻组、邮件列表和一些在因特网上讨论相关话题的人们。
|
||||
|
||||
### 如何更改 SSH 服务的端口号
|
||||
|
||||
SSH 服务器是默认运行在 22 号端口上的。然而,由于某些原因需要,它也可以运行在别的端口上。比如为了方便测试使用,又比如在同一个宿主机上运行多个不同的配置。当然,极少情况下,不使用 root 权限运行它也可以,比如某些必须运行在非特权的端口的情况(端口号大于等于 1024)。
|
||||
|
||||
端口号可以在配置文件 [/etc/ssh/sshd_config][9] 中将 `Port 22` 更改。也可以使用 `-p <port>` 选项运行 [sshd][10]。SSH 客户端和 [sftp][11] 程序也可以使用 `-p <port>` 选项。
|
||||
|
||||
### 配置 SSH 协议穿越防火墙
|
||||
|
||||
SSH 是少数通常被许可穿越防火墙的协议之一。通常的做法是不限制出站的 SSH 连接,尤其常见于一些较小的或者比较技术型的组织中,而入站的 SSH 连接通常会限制到一台或者是少数几台服务器上。
|
||||
|
||||
#### 出站的 SSH 连接
|
||||
|
||||
在防火墙中配置出站的 SSH 连接十分简单。如果完全限制了外发连接,那么只需要创建一个允许 TCP 端口 22 可以外发的规则即可。如果你想限制目标地址,你可以限制该规则仅允许访问你的组织放在云端的外部服务器或保护该云端的[跳板服务器][12]即可。
|
||||
|
||||
#### 反向通道是有风险的
|
||||
|
||||
其实不限制出站的 SSH 连接虽然是可以的,但是是存在风险的,SSH 协议是支持 [通道访问][13] 的。最初的想法是在外部服务器搭建一个 SSH 服务监听来自各处的连接,将进入的连接转发到组织,并让这个连接可以访问某个内部服务器。
|
||||
|
||||
在某些场景下这当然非常的方便。开发者和系统管理员经常使用它打开一个通道以便于他们可以远程访问,比如在家里或者在旅行中使用笔记本电脑等场景。
|
||||
|
||||
然而通常来讲这些做法是违背安全策略的,跳过了防火墙管理员和安全团队保护的控制无疑是违背安全策略的,比如这些: [PCI][14]、[HIPAA][15]、[NIST SP 800-53][16] 等。它可以被黑客和外国情报机构用来在组织内留下后门。
|
||||
|
||||
[CryptoAuditor][17] 是一款可以控制通道穿过防火墙或者一组云端服务器入口的产品。该款产品可以配合 [通用 SSH 密钥管理器(Universal SSH Key Manager)][18] 来获得对 [主机密钥(host keys)][19]的访问,以在启用防火墙并阻挡未授权转发的场景中解密 SSH 会话。
|
||||
|
||||
#### 入站的 SSH 访问
|
||||
|
||||
对于入站访问而言,这里有几点需要说一下:
|
||||
|
||||
* 配置防火墙,并转发所有去往 22 端口的连接只能流向到一个特定的内部网络 IP 地址或者一个 [DMZ][1] 主机。在该 IP 上运行 [CryptoAuditor][2] 或者跳板机来控制和审查所有访问该组织的连接。
|
||||
* 在防火墙上使用不同的端口访问不同的服务器。
|
||||
* 只允许使用 [IPsec][3] 协议这样的 VPN(虚拟专用网)登录后连接 SSH 服务。
|
||||
|
||||
### 通过 iptables 服务限制 SSH 访问
|
||||
|
||||
[iptables][20] 是一款内建在 Linux 内核的宿主防火墙。通常配置用于保护服务器以防止被访问那些未明确开启的端口。
|
||||
|
||||
如果服务器上启用了 `iptables`,使用下面的命令将可以允许进入的 SSH 访问,当然命令需要以 root 身份运行。
|
||||
|
||||
```
|
||||
iptables -A INPUT -p tcp --dport 22 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT
|
||||
iptables -A OUTPUT -p tcp --sport 22 -m conntrack --ctstate ESTABLISHED -j ACCEPT
|
||||
```
|
||||
|
||||
如果你想将上述命令创建的规则持久地保存,在某些系统版本中,可使用如下命令:
|
||||
|
||||
```
|
||||
service iptables save
|
||||
```
|
||||
|
||||
![防火墙开启 SSH 端口可以让我挖隧道去银行](https://www.ssh.com/s/ssh-port-firewall-access-banks-950x333-s+ZpRviP.png)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.ssh.com/ssh/port
|
||||
|
||||
作者:[Tatu Ylonen][a]
|
||||
译者:[kenxx](https://github.com/kenxx)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://www.ssh.com/ssh/port
|
||||
[1]:https://en.wikipedia.org/wiki/DMZ_(computing)
|
||||
[2]:https://www.ssh.com/products/cryptoauditor/
|
||||
[3]:https://www.ssh.com/network/ipsec/
|
||||
[4]:https://www.ssh.com/ssh/
|
||||
[5]:https://www.ssh.com/ssh/telnet
|
||||
[6]:https://www.ssh.com/ssh/ftp/
|
||||
[7]:https://en.wikipedia.org/wiki/Jon_Postel
|
||||
[8]:https://en.wikipedia.org/wiki/Joyce_K._Reynolds
|
||||
[9]:https://www.ssh.com/ssh/sshd_config/
|
||||
[10]:https://www.ssh.com/ssh/sshd/
|
||||
[11]:https://www.ssh.com/ssh/sftp/
|
||||
[12]:https://www.ssh.com/iam/jump-server
|
||||
[13]:https://www.ssh.com/ssh/tunneling/
|
||||
[14]:https://www.ssh.com/compliance/pci/
|
||||
[15]:https://www.ssh.com/compliance/hipaa/security-rule
|
||||
[16]:https://www.ssh.com/compliance/nist-800-53/
|
||||
[17]:https://www.ssh.com/products/cryptoauditor/
|
||||
[18]:https://www.ssh.com/products/universal-ssh-key-manager/
|
||||
[19]:https://www.ssh.com/ssh/host-key
|
||||
[20]:https://en.wikipedia.org/wiki/Iptables
|
@ -1,478 +0,0 @@
|
||||
How to install pandom: a true random number generator for Linux
|
||||
============================================================
|
||||
|
||||
### On this page
|
||||
|
||||
1. [Introduction][40]
|
||||
2. [1 Installation of pandom][41]
|
||||
1. [1.1 Gain root access][1]
|
||||
2. [1.2 Install build dependencies][2]
|
||||
3. [Arch based systems][3]
|
||||
4. [Debian based systems][4]
|
||||
5. [Red Hat based systems][5]
|
||||
6. [SUSE based systems][6]
|
||||
7. [1.3 Download and extract sources][7]
|
||||
8. [1.4 Test before installing (recommended)][8]
|
||||
9. [1.5 Determine init system][9]
|
||||
10. [1.6 Install pandom][10]
|
||||
11. [init.d based init system (e.g: upstart, sysvinit)][11]
|
||||
12. [systemd as init system][12]
|
||||
3. [2 Analysis of checkme file][42]
|
||||
1. [2.1 Gain root access][13]
|
||||
2. [2.2 Install build dependencies][14]
|
||||
3. [Arch based systems][15]
|
||||
4. [Debian based systems][16]
|
||||
5. [Red Hat based systems][17]
|
||||
6. [SUSE based systems][18]
|
||||
7. [2.3 Download and extract sources][19]
|
||||
8. [2.4 Install entropyarray][20]
|
||||
9. [2.5 Analyze checkme file][21]
|
||||
10. [2.6 Uninstall entropyarray (optional)][22]
|
||||
4. [3 Installation using debian repository][43]
|
||||
1. [3.1 Gain root access][23]
|
||||
2. [3.2 Install keyring][24]
|
||||
3. [3.3 Install sources list][25]
|
||||
4. [Wheezy][26]
|
||||
5. [Jessie][27]
|
||||
6. [Stretch][28]
|
||||
7. [3.4 Update sources list][29]
|
||||
8. [3.5 Test pandom][30]
|
||||
9. [3.6 Install pandom][31]
|
||||
5. [4 Managing pandom][44]
|
||||
1. [4.1 Performance test][32]
|
||||
2. [4.2 Entropy and serial correlation test][33]
|
||||
3. [4.3 System service][34]
|
||||
4. [init.d based init system (e.g: upstart, sysvinit)][35]
|
||||
5. [systemd as init system][36]
|
||||
6. [5 Increasing unpredictability or performance][45]
|
||||
1. [5.1 Edit source files][37]
|
||||
2. [5.2 Test the unpredictability][38]
|
||||
3. [5.3 Install personalized pandom][39]
|
||||
|
||||
This tutorial is for amd64 / x86_64 linux kernel versions greater and equal to 2.6.9\. It explains how to install [pandom][46]: a timing jitter true random number generator maintained by ncomputers.org
|
||||
|
||||
### Introduction
|
||||
|
||||
The built-in Linux kernel true random number generator provides low throughput under modern circumstances, as for example: personal computers with solid state drives (SSD) and virtual private servers (VPS).
|
||||
|
||||
This problem is becoming popular in linux implementations, because of the continuously increasing need for true random numbers, mainly by diverse cryptographic purposes.
|
||||
|
||||
Pandom outputs around 8 KiB/s entropy of 64 [ubits][47] / 64 bits, is compatible with physical and virtual environments and assumes, that no other process running as root user writes to /dev/random.
|
||||
|
||||
### 1 Installation of pandom
|
||||
|
||||
### 1.1 Gain root access
|
||||
|
||||
Pandom must be installed as root, run this command if needed.
|
||||
|
||||
su -
|
||||
|
||||
### 1.2 Install build dependencies
|
||||
|
||||
In order to download and install pandom, you need: GNU **as**sembler, GNU **make**, GNU **tar** and GNU **wget** (the last two usually installed already). You may uninstall them later at will.
|
||||
|
||||
### Arch based systems
|
||||
|
||||
pacman -S binutils make
|
||||
|
||||
### Debian based systems
|
||||
|
||||
apt-get install binutils make
|
||||
|
||||
### Red Hat based systems
|
||||
|
||||
dnf install binutils make
|
||||
|
||||
yum install binutils make
|
||||
|
||||
### SUSE based systems
|
||||
|
||||
zypper install binutils make
|
||||
|
||||
### 1.3 Download and extract sources
|
||||
|
||||
These commands download and extract the sources of pandom from ncomputers.org using **wget** and **tar**.
|
||||
|
||||
wget [http://ncomputers.org/pandom.tar.gz][48]
|
||||
tar xf pandom.tar.gz
|
||||
cd pandom/amd64-linux
|
||||
|
||||
### 1.4 Test before installing (recommended)
|
||||
|
||||
This recommended test takes around 8 minutes. It checks for kernel support and generates a file named **checkme** (analyzed on the next section).
|
||||
|
||||
make check
|
||||
|
||||
### 1.5 Determine init system
|
||||
|
||||
Before installing pandom, you need to know, which init software does your system use. If the following command outputs the word **running**, it means that your system is using **systemd**, otherwise it is likely, that your system is using an **init.d** implementation (e.g: upstart, sysvinit). There might be some exceptions, more information in these [unix.stackexchange.com][49] answers.
|
||||
|
||||
systemctl is-system-running
|
||||
|
||||
```
|
||||
running
|
||||
```
|
||||
|
||||
### 1.6 Install pandom
|
||||
|
||||
Once you know which system does your linux implementation use, then you may install pandom accordingly.
|
||||
|
||||
### init.d based init system (e.g: upstart, sysvinit)
|
||||
|
||||
Install pandom running this command, if your system is using an **init.d** implementation (e.g: upstart, sysvinit).
|
||||
|
||||
make install-init.d
|
||||
|
||||
### systemd as init system
|
||||
|
||||
Install pandom running this command, if your system is using **systemd**.
|
||||
|
||||
make install-systemd
|
||||
|
||||
### 2 Analysis of checkme file
|
||||
|
||||
Before using pandom for cryptographic purposes, it is highly recommended to analyze **checkme** file generated during the installation process in the previous section of this tutorial. This task is useful for knowing if the numbers are truly random or not. This section explains how to analyze **checkme** file using ncomputers.org/**entropyarray**: a shell script, that tests entropy and serial correlation of its input.
|
||||
|
||||
**Note**: this analysis might be run in another computer, such as a laptop or desktop computer. For example: if you are installing pandom in a constrained-resources virtual private server (VPS), you might opt to copy **checkme** file to your personal computer, in order to analyze it there.
|
||||
|
||||
### 2.1 Gain root access
|
||||
|
||||
Entropyarray must be installed as root, run this command if needed.
|
||||
|
||||
su -
|
||||
|
||||
### 2.2 Install build dependencies
|
||||
|
||||
In order to download and install entropyarray, you need: GNU **g++** compiler, GNU **make**, GNU **tar** and GNU **wget** (the last two usually installed already). You may uninstall them later at will.
|
||||
|
||||
### Arch based systems
|
||||
|
||||
pacman -S gcc make
|
||||
|
||||
### Debian based systems
|
||||
|
||||
apt-get install g++ make
|
||||
|
||||
### Red Hat based systems
|
||||
|
||||
dnf install gcc-c++ make
|
||||
|
||||
yum install gcc-c++ make
|
||||
|
||||
### SUSE based systems
|
||||
|
||||
zypper install gcc-c++ make
|
||||
|
||||
### 2.3 Download and extract sources
|
||||
|
||||
These commands download and extract the sources of entropyarray from ncomputers.org using **wget** and **tar**.
|
||||
|
||||
wget [http://ncomputers.org/rearray.tar.gz][50]
|
||||
wget [http://ncomputers.org/entropy.tar.gz][51]
|
||||
wget [http://ncomputers.org/entropyarray.tar.gz][52]
|
||||
|
||||
tar xf entropy.tar.gz
|
||||
tar xf rearray.tar.gz
|
||||
tar xf entropyarray.tar.gz
|
||||
|
||||
### 2.4 Install entropyarray
|
||||
|
||||
**Note**: errors regarding -std=c++11 mean that the GNU **g++** compiler version doesn't support ISO C++ 2011 standard. You may try to compile ncomputers.org/**entropy** and ncomputers.org/**rearray** in another system that supports it (e.g: GNU g++ in a newer version of your favorite linux distribution) and then install the compiled binaries using **make install** in the system you would like to run **entropyarray**, or skip this step, despite it is highly recommended that you analyze **checkme** file before using pandom for any cryptographic purpose.
|
||||
|
||||
cd rearray; make install; cd ..
|
||||
cd entropy; make install; cd ..
|
||||
cd entropyarray; make install; cd ..
|
||||
|
||||
### 2.5 Analyze checkme file
|
||||
|
||||
**Note**: 64 [ubits][53] / 64 bits pandom implementations should result this test with entropy above **15.977** and **max** frequency below **70**. If your results differ too much, you may try to increase the unpredictability of your pandom implementation as described in the fifth section of this tutorial. In case you skipped the last step, you may use other tools such as [pseudorandom number sequence test][54].
|
||||
|
||||
entropyarray checkme
|
||||
|
||||
```
|
||||
entropyarray in /tmp/tmp.mbCopmzqsg
|
||||
15.977339
|
||||
min:12
|
||||
med:32
|
||||
max:56
|
||||
15.977368
|
||||
min:11
|
||||
med:32
|
||||
max:58
|
||||
15.977489
|
||||
min:11
|
||||
med:32
|
||||
max:59
|
||||
15.977077
|
||||
min:12
|
||||
med:32
|
||||
max:60
|
||||
15.977439
|
||||
min:8
|
||||
med:32
|
||||
max:59
|
||||
15.977374
|
||||
min:13
|
||||
med:32
|
||||
max:60
|
||||
15.977312
|
||||
min:12
|
||||
med:32
|
||||
max:67
|
||||
```
|
||||
|
||||
### 2.6 Uninstall entropyarray (optional)
|
||||
|
||||
If you plan to not use entropyarray any more, then you might want to uninstall it at will.
|
||||
|
||||
cd entropyarray; make uninstall; cd ..
|
||||
cd entropy; make uninstall; cd ..
|
||||
cd rearray; make uninstall; cd ..
|
||||
|
||||
### 3 Installation using debian repository
|
||||
|
||||
If you would like to keep pandom updated on your debian based system, you may opt to install / reinstall it using ncomputers.org debian repository.
|
||||
|
||||
### 3.1 Gain root access
|
||||
|
||||
The below debian packages must be installed as root, run this command if needed.
|
||||
|
||||
su -
|
||||
|
||||
### 3.2 Install keyring
|
||||
|
||||
This debian package includes the public key of the ncomputers.org debian repository.
|
||||
|
||||
wget [http://ncomputers.org/debian/keyring.deb][55]
|
||||
dpkg -i keyring.deb
|
||||
rm keyring.deb
|
||||
|
||||
### 3.3 Install sources list
|
||||
|
||||
These debian packages include the sources list of the ncomputers.org debian repository according to the latest debian distributions (year 2017).
|
||||
|
||||
**Note**: It is also possible to write the commented lines below in **/etc/apt/sources.list**, instead of installing the respective debian package for your debian distribution, but if these sources change in the future, then you would need to update them manually.
|
||||
|
||||
### Wheezy
|
||||
|
||||
#deb [http://ncomputers.org/debian][56] wheezy main
|
||||
wget [http://ncomputers.org/debian/wheezy.deb][57]
|
||||
dpkg -i wheezy.deb
|
||||
rm wheezy.deb
|
||||
|
||||
### Jessie
|
||||
|
||||
#deb [http://ncomputers.org/debian][58] jessie main
|
||||
wget [http://ncomputers.org/debian/jessie.deb][59]
|
||||
dpkg -i jessie.deb
|
||||
rm jessie.deb
|
||||
|
||||
### Stretch
|
||||
|
||||
#deb [http://ncomputers.org/debian][60] stretch main
|
||||
wget [http://ncomputers.org/debian/stretch.deb][61]
|
||||
dpkg -i stretch.deb
|
||||
rm stretch.deb
|
||||
|
||||
### 3.4 Update sources list
|
||||
|
||||
Once the keyring and sources list are installed.
|
||||
|
||||
apt-get update
|
||||
|
||||
### 3.5 Test pandom
|
||||
|
||||
Once tested, you may uninstall the below package at will.
|
||||
|
||||
**Note**: if you have already tested pandom in your linux implementation, you may skip this step.
|
||||
|
||||
apt-get install pandom-test
|
||||
pandom-test
|
||||
|
||||
```
|
||||
generating checkme file, please wait around 8 minutes ...
|
||||
entropyarray in /tmp/tmp.5SkiYsYG3h
|
||||
15.977366
|
||||
min:12
|
||||
med:32
|
||||
max:57
|
||||
15.977367
|
||||
min:13
|
||||
med:32
|
||||
max:57
|
||||
15.977328
|
||||
min:12
|
||||
med:32
|
||||
max:61
|
||||
15.977431
|
||||
min:12
|
||||
med:32
|
||||
max:59
|
||||
15.977437
|
||||
min:11
|
||||
med:32
|
||||
max:57
|
||||
15.977298
|
||||
min:11
|
||||
med:32
|
||||
max:59
|
||||
15.977196
|
||||
min:10
|
||||
med:32
|
||||
max:57
|
||||
```
|
||||
|
||||
### 3.6 Install pandom
|
||||
|
||||
apt-get install pandom
|
||||
|
||||
### 4 Managing pandom
|
||||
|
||||
After pandom was installed, you might want to manage it.
|
||||
|
||||
### 4.1 Performance test
|
||||
|
||||
Pandom offers around 8 kilobytes per second, but its performance may vary depending on the environment.
|
||||
|
||||
dd if=/dev/random of=/dev/null bs=8 count=512
|
||||
|
||||
```
|
||||
512+0 records in
|
||||
512+0 records out
|
||||
4096 bytes (4.1 kB, 4.0 KiB) copied, 0.451253 s, 9.1 kB/s
|
||||
```
|
||||
|
||||
### 4.2 Entropy and serial correlation test
|
||||
|
||||
Besides of ncomputers.org/**entropyarray**, there are more tests, for example [NIST testsuite by Ilja Gerhardt][62].
|
||||
|
||||
entropyarray /dev/random 1M
|
||||
|
||||
### 4.3 System service
|
||||
|
||||
Pandom runs as a system service.
|
||||
|
||||
### init.d based init system (e.g: upstart, sysvinit)
|
||||
|
||||
/etc/init.d/random status
|
||||
/etc/init.d/random start
|
||||
/etc/init.d/random stop
|
||||
/etc/init.d/random restart
|
||||
|
||||
### systemd as init system
|
||||
|
||||
systemctl status random
|
||||
systemctl start random
|
||||
systemctl stop random
|
||||
systemctl restart random
|
||||
|
||||
### 5 Increasing unpredictability or performance
|
||||
|
||||
If you would like to try to increase the unpredictabiity or the performance of your pandom implementation, you may try to add or delete CPU time measurements.
|
||||
|
||||
### 5.1 Edit source files
|
||||
|
||||
In the source files **test.s** and **tRNG.s** add or remove measurement blocks at will.
|
||||
|
||||
```
|
||||
#measurement block
|
||||
mov $35,%rax
|
||||
syscall
|
||||
rdtsc
|
||||
[...]
|
||||
|
||||
#measurement block
|
||||
mov $35,%rax
|
||||
syscall
|
||||
rdtsc
|
||||
[...]
|
||||
```
|
||||
|
||||
### 5.2 Test the unpredictability
|
||||
|
||||
We recommend to always test any personalized pandom implementation before using it for cryptographic purposes.
|
||||
|
||||
make check
|
||||
|
||||
### 5.3 Install personalized pandom
|
||||
|
||||
If you are happy with the results, then you may install your personalized pandom implementation.
|
||||
|
||||
make install
|
||||
|
||||
Additional information and updates: [http://ncomputers.org/pandom][63]
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/
|
||||
|
||||
作者:[Oliver][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/
|
||||
[1]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-gain-root-access
|
||||
[2]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-install-build-dependencies
|
||||
[3]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#arch-based-systems
|
||||
[4]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#debian-based-systems
|
||||
[5]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#red-hat-based-systems
|
||||
[6]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#suse-based-systems
|
||||
[7]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-download-and-extract-sources
|
||||
[8]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-test-before-installing-recommended
|
||||
[9]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-determine-init-system
|
||||
[10]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-install-pandom
|
||||
[11]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#initd-based-init-system-eg-upstart-sysvinit
|
||||
[12]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#systemd-as-init-system
|
||||
[13]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-gain-root-access-2
|
||||
[14]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-install-build-dependencies-2
|
||||
[15]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#arch-based-systems-2
|
||||
[16]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#debian-based-systems-2
|
||||
[17]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#red-hat-based-systems-2
|
||||
[18]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#suse-based-systems-2
|
||||
[19]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-download-and-extract-sources-2
|
||||
[20]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-install-entropyarray
|
||||
[21]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-analyze-checkme-file
|
||||
[22]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-uninstall-entropyarray-optional
|
||||
[23]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-gain-root-access-3
|
||||
[24]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-install-keyring
|
||||
[25]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-install-sources-list
|
||||
[26]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#wheezy
|
||||
[27]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#jessie
|
||||
[28]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#stretch
|
||||
[29]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-update-sources-list
|
||||
[30]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-test-pandom
|
||||
[31]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-install-pandom-2
|
||||
[32]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-performance-test
|
||||
[33]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-entropy-and-serial-correlation-test
|
||||
[34]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-system-service
|
||||
[35]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#initd-based-init-system-eg-upstart-sysvinit-2
|
||||
[36]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#systemd-as-init-system-2
|
||||
[37]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-edit-source-files
|
||||
[38]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-test-the-unpredictability
|
||||
[39]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-install-personalized-pandom
|
||||
[40]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#introduction
|
||||
[41]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-installation-of-pandom
|
||||
[42]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-analysis-of-checkme-file
|
||||
[43]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-installation-using-debian-repository
|
||||
[44]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-managing-pandom
|
||||
[45]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-increasing-unpredictability-or-performance
|
||||
[46]:http://ncomputers.org/pandom
|
||||
[47]:http://ncomputers.org/ubit
|
||||
[48]:http://ncomputers.org/pandom.tar.gz
|
||||
[49]:http://unix.stackexchange.com/a/18210/94448
|
||||
[50]:http://ncomputers.org/rearray.tar.gz
|
||||
[51]:http://ncomputers.org/entropy.tar.gz
|
||||
[52]:http://ncomputers.org/entropyarray.tar.gz
|
||||
[53]:http://ncomputers.org/ubit
|
||||
[54]:http://www.fourmilab.ch/random/
|
||||
[55]:http://ncomputers.org/debian/keyring.deb
|
||||
[56]:http://ncomputers.org/debian
|
||||
[57]:http://ncomputers.org/debian/wheezy.deb
|
||||
[58]:http://ncomputers.org/debian
|
||||
[59]:http://ncomputers.org/debian/jessie.deb
|
||||
[60]:http://ncomputers.org/debian
|
||||
[61]:http://ncomputers.org/debian/stretch.deb
|
||||
[62]:https://gerhardt.ch/random.php
|
||||
[63]:http://ncomputers.org/pandom
|
@ -1,277 +0,0 @@
|
||||
How to Install iRedMail on CentOS 7 for Samba4 AD Integration – Part 10
|
||||
============================================================
|
||||
|
||||
This series of tutorials will guide you on how to integrate iRedMail installed on a CentOS 7 machine with a [Samba4 Active Directory Domain Controller][3] in order for domain accounts to send or receive mail via Thunderbird desktop client or via Roundcube web interface.
|
||||
|
||||
The CentOS 7 server where iRedMail will be installed will allow SMTP or mail routing services via ports 25 and 587 and will also serve as a mail delivery agent through Dovecot, providing POP3 and IMAP services, both secured with self-signed certificates issued on the installation process.
|
||||
|
||||
The recipient mailboxes will be stored on the same CentOS server along with the webmail user agent provided by Roundcube. Samba4 Active Directory will be used by iRedMail to query and authenticate recipient accounts against the realm, to create mail lists with the help of Active Directory groups and to control the mail accounts via Samba4 AD DC.
|
||||
|
||||
#### Requirements:
|
||||
|
||||
1. [Create an Active Directory Infrastructure with Samba4 on Ubuntu][1]
|
||||
|
||||
### Step 1: Install iRedMail in CentOS 7
|
||||
|
||||
1. Before starting with iRedMail installation first make sure you have a fresh CentOS 7 operating system installed on your machine using the instructions provided by this guide:
|
||||
|
||||
1. [Fresh Installation of CentOS 7 Minimal][2]
|
||||
|
||||
2. Also, assure that the system is up-to-date with the latest security and packages updates by issuing the below command.
|
||||
|
||||
```
|
||||
# yum update
|
||||
```
|
||||
|
||||
3. The system will also need a FQDN hostname set by issuing the below command. Replace `mail.tecmint.lan` variable with your own custom FQDN.
|
||||
|
||||
```
|
||||
# hostnamectl set-hostname mail.tecmint.lan
|
||||
```
|
||||
|
||||
Verify system hostname with the below commands.
|
||||
|
||||
```
|
||||
# hostname -s # Short name
|
||||
# hostname -f # FQDN
|
||||
# hostname -d # Domain
|
||||
# cat /etc/hostname # Verify it with cat command
|
||||
```
|
||||
[
|
||||
![Verify CentOS 7 Hostname](http://www.tecmint.com/wp-content/uploads/2017/03/Verify-CentOS-7-Hostname.png)
|
||||
][4]
|
||||
|
||||
Verify CentOS 7 Hostname
|
||||
|
||||
4. Map the machine FQDN and short name against the machine loopback IP address by manually editing `/etc/hosts` file. Add the values as illustrated below and replace `mail.tecmint.lan` and mail values accordingly.
|
||||
|
||||
```
|
||||
127.0.0.1 mail.tecmint.lan mail localhost localhost.localdomain
|
||||
```
|
||||
|
||||
5. iRedMail technicians recommends that SELinux should be completely disabled. Disable SELinux by editing /etc/selinux/config file and set SELINUX parameter from `permissive` to `disabled` as illustrated below.
|
||||
|
||||
```
|
||||
SELINUX=disabled
|
||||
```
|
||||
|
||||
Reboot the machine to apply new SELinux policies or run setenforce with 0 parameter to force SELinux to instantly disable.
|
||||
|
||||
```
|
||||
# reboot
|
||||
OR
|
||||
# setenforce 0
|
||||
```
|
||||
|
||||
6. Next, install the following packages that will come in-handy later for system administration:
|
||||
|
||||
```
|
||||
# yum install bzip2 net-tools bash-completion wget
|
||||
```
|
||||
|
||||
7. In order to install iRedMail, first go to the download page [http://www.iredmail.org/download.html][5] and grab the latest archive version of the software by issuing the below command.
|
||||
|
||||
```
|
||||
# wget https://bitbucket.org/zhb/iredmail/downloads/iRedMail-0.9.6.tar.bz2
|
||||
```
|
||||
|
||||
8. After the download finishes, extract the compressed archive and enter the extracted iRedMail directory by issuing the following commands.
|
||||
|
||||
```
|
||||
# tar xjf iRedMail-0.9.6.tar.bz2
|
||||
# cd iRedMail-0.9.6/
|
||||
# ls
|
||||
```
|
||||
|
||||
9. Start the installation process by executing iRedMail shell script with the following command. From now on a series of questions will be asked by the installer.
|
||||
|
||||
```
|
||||
# bash iRedMail.sh
|
||||
```
|
||||
|
||||
10. On the first welcome prompt hit on `Yes` to proceed further with the installation.
|
||||
|
||||
[
|
||||
![iRedMail Setup Wizard](http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-Setup-Wizard.png)
|
||||
][6]
|
||||
|
||||
iRedMail Setup Wizard
|
||||
|
||||
11. Next, choose the location where all the mail will be stored. The default directory that iRedMail uses to store mailboxes is `/var/vmail/` system path.
|
||||
|
||||
If this directory is located under a partition with enough storage to host mail for all your domain accounts then hit on Next to continue.
|
||||
|
||||
Otherwise change the default location with a different directory in case if you’ve configured a larger partition dedicated to mail storage.
|
||||
|
||||
[
|
||||
![iRedMail Mail Storage Path](http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-Mail-Storage-Path.png)
|
||||
][7]
|
||||
|
||||
iRedMail Mail Storage Path
|
||||
|
||||
12. On the next step choose the frontend web server through which you will interact with iRedMail. iRedMail administration panel will be completely disabled later, so we will use the frontend web server only to access accounts mail via Roundcube web panel.
|
||||
|
||||
If you don’t have thousands of mail accounts per hour accessing the webmail interface you should go with Apache web server do to its flexibility and easy management.
|
||||
|
||||
[
|
||||
![iRedMail Preferred Web Server](http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-Preferred-Web-Server.png)
|
||||
][8]
|
||||
|
||||
iRedMail Preferred Web Server
|
||||
|
||||
13. On this step choose OpenLDAP backend database for compatibility reasons with Samba4 domain controller and hit Next to continue, although we won’t use this OpenLDAP database later once we’ll integrate iRedMail to Samba domain controller.
|
||||
|
||||
[
|
||||
![iRedMail LDAP Backend](http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-LDAP-Backend.png)
|
||||
][9]
|
||||
|
||||
iRedMail LDAP Backend
|
||||
|
||||
14. Next, specify your Samba4 domain name for LDAP suffix as illustrated on the image below and hit Next to continue.
|
||||
|
||||
[
|
||||
![iRedMail LDAP Suffix](http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-LDAP-Suffix.png)
|
||||
][10]
|
||||
|
||||
iRedMail LDAP Suffix
|
||||
|
||||
15. On the next prompt enter your domain name only and hit Next to move on. Replace `tecmint.lan` value accordingly.
|
||||
|
||||
[
|
||||
![iRedMail Mail Domain](http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-Mail-Domain.png)
|
||||
][11]
|
||||
|
||||
iRedMail Mail Domain
|
||||
|
||||
16. Now, setup a password for `postmaster@yourdomain.tld` administrator and hit Next to continue.
|
||||
|
||||
[
|
||||
![iRedMail Mail Domain Administrator](http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-Mail-Domain-Administrator.png)
|
||||
][12]
|
||||
|
||||
iRedMail Mail Domain Administrator
|
||||
|
||||
17. Next, choose from the list the optional components you want to integrate with your mail server. I strongly recommend to install Roundcube in order to provide a web interface for domain accounts to access mail, although Roundcube can be installed and configured on a different machine for this task in order to free mail server resources in case of high loads.
|
||||
|
||||
For local domains with restricted internet access and especially while we’re using domain integration the other components are not very useful, except Awstats in case you need mail analysis.
|
||||
|
||||
[
|
||||
![iRedMail Optional Components](http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-Optional-Components.png)
|
||||
][13]
|
||||
|
||||
iRedMail Optional Components
|
||||
|
||||
18. On the next review screen type `Y` in order to apply configuration and start the installation process.
|
||||
|
||||
[
|
||||
![iRedMail Configuration Changes](http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-Configuration-Changes.png)
|
||||
][14]
|
||||
|
||||
iRedMail Configuration Changes
|
||||
|
||||
19. Finally, accept iRedMail scripts to automatically configure your machine firewall and MySQL configuration file by typing yes for all questions.
|
||||
|
||||
[
|
||||
![iRedMail System Configuration](http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-System-Configuration.png)
|
||||
][15]
|
||||
|
||||
iRedMail System Configuration
|
||||
|
||||
20. After the installation finishes the installer will provide some sensitive information, such as iRedAdmin credentials, web panel URL addresses and the file location with all parameters used at the installation process.
|
||||
|
||||
[
|
||||
![iRedMail Installation Summary](http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-Installation-Summary.png)
|
||||
][16]
|
||||
|
||||
iRedMail Installation Summary
|
||||
|
||||
Read the displayed information above carefully and reboot the machine in order to enable all mail services by issuing the following command.
|
||||
|
||||
```
|
||||
# init 6
|
||||
```
|
||||
|
||||
21. After the system reboots, login with an account with root privileges or as root and list all network sockets and their associated programs your mail server listens on by issuing the following command.
|
||||
|
||||
From the socket list you will see that your mail server covers almost all services required by a mail server to properly function: SMTP/S, POP3/S, IMAP/S and antivirus along with spam protection.
|
||||
|
||||
```
|
||||
# netstat -tulpn
|
||||
```
|
||||
[
|
||||
![iRedMail Network Sockets](http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-Network-Sockets.png)
|
||||
][17]
|
||||
|
||||
iRedMail Network Sockets
|
||||
|
||||
22. In order to view the location of all configuration files iRedMail has modified and the credentials used by iRedMail during the installation process for database administration, mail admin account and other accounts, display the contents of iRedMail.tips file.
|
||||
|
||||
The file is located in the directory where you’ve initially extracted the installation archive. Be aware that you should move and protect this file because it contains sensitive information about your mail server.
|
||||
|
||||
```
|
||||
# less iRedMail-0.9.6/iRedMail.tips
|
||||
```
|
||||
|
||||
23. The file mentioned above which contain details about your mail server will also be automatically mailed to the mail server administrator account, represented by the postmaster account.
|
||||
|
||||
The webmail can be accessed securely via HTTPS protocol by typing your machine IP address in a browser. Accept the error generated in browser by the iRedMail self-signed web certificate and log in with the password chosen for postmaster@your_domain.tld account during the initial installation. Read and store this e-mail to a safe mailbox.
|
||||
|
||||
```
|
||||
https://192.168.1.254
|
||||
```
|
||||
[
|
||||
![iRedMail Account Login](http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-Account-Login.png)
|
||||
][18]
|
||||
|
||||
iRedMail Account Login
|
||||
|
||||
[
|
||||
![iRedMail Web Mail](http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-Web-Mail.png)
|
||||
][19]
|
||||
|
||||
iRedMail Web Mail
|
||||
|
||||
That’s all! By now, you’ll have a full mail server configured on your premises which operates on its own, but not yet integrated with Samba4 Active Directory Domain Controller services.
|
||||
|
||||
On the next part we will see how to tamper iRedMail services (postfix, dovecot and roundcube configuration files) in order to query domain accounts, send, receive and read mail.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
作者简介:
|
||||
|
||||
I'am a computer addicted guy, a fan of open source and linux based system software, have about 4 years experience with Linux distributions desktop, servers and bash scripting.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.tecmint.com/install-iredmail-on-centos-7-for-samba4-ad-integration/
|
||||
|
||||
作者:[Matei Cezar][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.tecmint.com/author/cezarmatei/
|
||||
|
||||
[1]:http://www.tecmint.com/install-samba4-active-directory-ubuntu/
|
||||
[2]:http://www.tecmint.com/centos-7-3-installation-guide/
|
||||
[3]:http://www.tecmint.com/install-samba4-active-directory-ubuntu/
|
||||
[4]:http://www.tecmint.com/wp-content/uploads/2017/03/Verify-CentOS-7-Hostname.png
|
||||
[5]:http://www.iredmail.org/download.html
|
||||
[6]:http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-Setup-Wizard.png
|
||||
[7]:http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-Mail-Storage-Path.png
|
||||
[8]:http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-Preferred-Web-Server.png
|
||||
[9]:http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-LDAP-Backend.png
|
||||
[10]:http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-LDAP-Suffix.png
|
||||
[11]:http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-Mail-Domain.png
|
||||
[12]:http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-Mail-Domain-Administrator.png
|
||||
[13]:http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-Optional-Components.png
|
||||
[14]:http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-Configuration-Changes.png
|
||||
[15]:http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-System-Configuration.png
|
||||
[16]:http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-Installation-Summary.png
|
||||
[17]:http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-Network-Sockets.png
|
||||
[18]:http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-Account-Login.png
|
||||
[19]:http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-Web-Mail.png
|
||||
[20]:http://www.tecmint.com/author/cezarmatei/
|
||||
[21]:http://www.tecmint.com/10-useful-free-linux-ebooks-for-newbies-and-administrators/
|
||||
[22]:http://www.tecmint.com/free-linux-shell-scripting-books/
|
@ -1,5 +1,8 @@
|
||||
translating by [kenxx](https://github.com/kenxx)
|
||||
|
||||
# [Discovering my inner curmudgeon: A Linux laptop review][1]
|
||||
|
||||
|
||||
Quick refresher: I'm a life-long Mac user, but I was [disappointed by Apple's latest MacBook Pro release][2]. I researched [a set of alternative computers][3] to consider. And, as a surprise even to myself, I decided to leave the Mac platform.
|
||||
|
||||
I chose the HP Spectre x360 13" laptop that was released after CES 2017, the new version with a 4K display. I bought the machine [from BestBuy][4] (not an affiliate link) because that was the only retailer selling this configuration. My goal was to run Ubuntu Linux instead of Windows.
|
||||
@ -67,7 +70,7 @@ Follow @haxor if you'd like to read posts from me in the future. You can also em
|
||||
via: http://www.onebigfluke.com/2017/04/discovering-my-inner-curmudgeon-linux.html
|
||||
|
||||
作者:[Brett Slatkin ][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
译者:[kenxx](https://github.com/kenxx)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
@ -0,0 +1,256 @@
|
||||
rdiff-backup – A Remote Incremental Backup Tool for Linux
|
||||
============================================================
|
||||
|
||||
rdiff-backup is a powerful and easy-to-use Python script for local/remote incremental backup, which works on any POSIX operating system such as Linux, Mac OS X or [Cygwin][1]. It brings together the remarkable features of a mirror and an incremental backup.
|
||||
|
||||
Significantly, it preserves subdirectories, dev files, hard links, and critical file attributes such as permissions, uid/gid ownership, modification times, extended attributes, acls, and resource forks. It can work in a bandwidth-efficient mode over a pipe, in a similar way as the popular [rsync backup tool][2].
|
||||
|
||||
rdiff-backup backs up a single directory to another over a network using SSH, implying that the data transfer is encrypted thus secure. The target directory (on the remote system) ends up an exact copy of the source directory, however extra reverse diffs are stored in a special subdirectory in the target directory, making it possible to recover files lost some time ago.
|
||||
|
||||
#### Dependencies
|
||||
|
||||
To use rdiff-backup in Linux, you’ll need the following packages installed on your system:
|
||||
|
||||
* Python v2.2 or later
|
||||
* librsync v0.9.7 or later
|
||||
* pylibacl and pyxattr Python modules are optional but necessary for POSIX access control list(ACL) and extended attribute support respectively.
|
||||
* rdiff-backup-statistics requires Python v2.4 or later.
|
||||
|
||||
### How to Install rdiff-backup in Linux
|
||||
|
||||
Important: If you are operating over a network, you’ll have to install rdiff-backup both systems, preferably both installations of rdiff-backup will have to be the exact same version.
|
||||
|
||||
The script is already present in the official repositories of the mainstream Linux distributions, simply run the command below to install rdiff-backup as well as its dependencies:
|
||||
|
||||
#### On Debian/Ubuntu
|
||||
|
||||
```
|
||||
$ sudo apt-get update
|
||||
$ sudo apt-get install librsync-dev rdiff-backup
|
||||
```
|
||||
|
||||
#### On CentOS/RHEL 7
|
||||
|
||||
```
|
||||
# wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-9.noarch.rpm
|
||||
# rpm -ivh epel-release-7-9.noarch.rpm
|
||||
# yum install librsync rdiff-backup
|
||||
```
|
||||
|
||||
#### On CentOS/RHEL 6
|
||||
|
||||
```
|
||||
# wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
|
||||
# rpm -ivh epel-release-6-8.noarch.rpm
|
||||
# yum install librsync rdiff-backup
|
||||
```
|
||||
|
||||
#### On Fedora
|
||||
|
||||
```
|
||||
# yum install librsync rdiff-backup
|
||||
# dnf install librsync rdiff-backup [Fedora 22+]
|
||||
```
|
||||
|
||||
### How to Use rdiff-backup in Linux
|
||||
|
||||
As I mentioned before, rdiff-backup uses SSH to connect to remote machines on your network, and the default authentication in SSH is the username/password method, which normally requires human interaction.
|
||||
|
||||
However, to automate tasks such as automatic backups with scripts and beyond, you will need to configure [SSH Passwordless Login Using SSH keys][3], because SSH keys increases the trust between two Linux servers for [easy file synchronization or transfer][4].
|
||||
|
||||
Once you have setup [SSH Passwordless Login][5], you can start using the script with the following examples.
|
||||
|
||||
#### Backup Files to Different Partition
|
||||
|
||||
The example below will backup the `/etc` directory in a Backup directory on another partition:
|
||||
|
||||
```
|
||||
$ sudo rdiff-backup /etc /media/aaronkilik/Data/Backup/mint_etc.backup
|
||||
```
|
||||
[
|
||||
![Backup Files to Different Partition](http://www.tecmint.com/wp-content/uploads/2017/03/Backup-Files-to-Different-Partition.png)
|
||||
][6]
|
||||
|
||||
Backup Files to Different Partition
|
||||
|
||||
To exclude a particular directory as well as it’s subdirectories, you can use the `--exclude` option as follows:
|
||||
|
||||
```
|
||||
$ sudo rdiff-backup --exclude /etc/cockpit --exclude /etc/bluetooth /media/aaronkilik/Data/Backup/mint_etc.backup
|
||||
```
|
||||
|
||||
We can include all device files, fifo files, socket files, and symbolic links with the `--include-special-files` option as below:
|
||||
|
||||
```
|
||||
$ sudo rdiff-backup --include-special-files --exclude /etc/cockpit /media/aaronkilik/Data/Backup/mint_etc.backup
|
||||
```
|
||||
|
||||
There are two other important flags we can set for file selection; `--max-file-size` size which excludes files that are larger than the given size in bytes and `--min-file-size` size which excludes files that are smaller than the given size in bytes:
|
||||
|
||||
```
|
||||
$ sudo rdiff-backup --max-file-size 5M --include-special-files --exclude /etc/cockpit /media/aaronkilik/Data/Backup/mint_etc.backup
|
||||
```
|
||||
|
||||
#### Backup Remote Files on Local Linux Server
|
||||
|
||||
For the purpose of this section, we’ll use:
|
||||
|
||||
```
|
||||
Remote Server (tecmint) : 192.168.56.102
|
||||
Local Backup Server (backup) : 192.168.56.10
|
||||
```
|
||||
|
||||
As we stated before, you must install the same version of rdiff-backup on both machines, now try to check the version on both machines as follows:
|
||||
|
||||
```
|
||||
$ rdiff-backup -V
|
||||
```
|
||||
[
|
||||
![Check rdiff Version on Servers](http://www.tecmint.com/wp-content/uploads/2017/03/check-rdif-versions-on-servers.png)
|
||||
][7]
|
||||
|
||||
Check rdiff Version on Servers
|
||||
|
||||
On the backup server, create a directory which will store the backup files like so:
|
||||
|
||||
```
|
||||
# mkdir -p /backups
|
||||
```
|
||||
|
||||
Now from the backup server, run the following commands to make a backup of directories `/var/log/`and `/root` from remote Linux server 192.168.56.102 in `/backups`:
|
||||
|
||||
```
|
||||
# rdiff-backup root@192.168.56.102::/var/log/ /backups/192.168.56.102_logs.backup
|
||||
# rdiff-backup root@192.168.56.102::/root/ /backups/192.168.56.102_rootfiles.backup
|
||||
```
|
||||
|
||||
The screenshot below shows the root file on remote server 192.168.56.102 and the backed up files on the back server 192.168.56.10:
|
||||
|
||||
[
|
||||
![Backup Remote Directory on Local Server](http://www.tecmint.com/wp-content/uploads/2017/03/Backup-Remote-Linux-Directory-on-Local-Server.png)
|
||||
][8]
|
||||
|
||||
Backup Remote Directory on Local Server
|
||||
|
||||
Take note of the rdiff-backup-data directory created in the `backup` directory as seen in the screenshot, it contains vital data concerning the backup process and incremental files.
|
||||
|
||||
[
|
||||
![rdiff-backup - Backup Process Files](http://www.tecmint.com/wp-content/uploads/2017/03/rdiff-backup-data-directory-contents.png)
|
||||
][9]
|
||||
|
||||
rdiff-backup – Backup Process Files
|
||||
|
||||
Now, on the server 192.168.56.102, additional files have been added to the root directory as shown below:
|
||||
|
||||
[
|
||||
![Verify Backup Directory](http://www.tecmint.com/wp-content/uploads/2017/03/additional-files-in-root-directory.png)
|
||||
][10]
|
||||
|
||||
Verify Backup Directory
|
||||
|
||||
Let’s run the backup command once more time to get the changed data, we can use the `-v[0-9]`(where the number specifies the verbosity level, default is 3 which is silent) option to set the verbosity feature:
|
||||
|
||||
```
|
||||
# rdiff-backup -v4 root@192.168.56.102::/root/ /backups/192.168.56.102_rootfiles.backup
|
||||
```
|
||||
[
|
||||
![Incremental Backup with Summary](http://www.tecmint.com/wp-content/uploads/2017/03/incremental-backup-of-root-files.png)
|
||||
][11]
|
||||
|
||||
Incremental Backup with Summary
|
||||
|
||||
And to list the number and date of partial incremental backups contained in the /backups/192.168.56.102_rootfiles.backup directory, we can run:
|
||||
|
||||
```
|
||||
# rdiff-backup -l /backups/192.168.56.102_rootfiles.backup/
|
||||
```
|
||||
|
||||
#### Automating rdiff-back Backup Using Cron
|
||||
|
||||
We can print summary statistics after a successful backup with the `--print-statistics`. However, if we don’t set this option, the info will still be available from the session statistics file. Read more concerning this option in the STATISTICS section of the man page.
|
||||
|
||||
And the –remote-schema flag enables us to specify an alternative method of connecting to a remote computer.
|
||||
|
||||
Now, let’s start by creating a `backup.sh` script on the backup server 192.168.56.10 as follows:
|
||||
|
||||
```
|
||||
# cd ~/bin
|
||||
# vi backup.sh
|
||||
```
|
||||
|
||||
Add the following lines to the script file.
|
||||
|
||||
```
|
||||
#!/bin/bash
|
||||
#This is a rdiff-backup utility backup script
|
||||
#Backup command
|
||||
rdiff-backup --print-statistics --remote-schema 'ssh -C %s "sudo /usr/bin/rdiff-backup --server --restrict-read-only /"' root@192.168.56.102::/var/logs /backups/192.168.56.102_logs.back
|
||||
#Checking rdiff-backup command success/error
|
||||
status=$?
|
||||
if [ $status != 0 ]; then
|
||||
#append error message in ~/backup.log file
|
||||
echo "rdiff-backup exit Code: $status - Command Unsuccessful" >>~/backup.log;
|
||||
exit 1;
|
||||
fi
|
||||
#Remove incremental backup files older than one month
|
||||
rdiff-backup --force --remove-older-than 1M /backups/192.168.56.102_logs.back
|
||||
```
|
||||
|
||||
Save the file and exit, then run the following command to add the script to the crontab on the backup server 192.168.56.10:
|
||||
|
||||
```
|
||||
# crontab -e
|
||||
```
|
||||
|
||||
Add this line to run your backup script daily at midnight:
|
||||
|
||||
```
|
||||
0 0 * * * /root/bin/backup.sh > /dev/null 2>&1
|
||||
```
|
||||
|
||||
Save the crontab and close it, now we’ve successful automated the backup process. Ensure that it is working as expected.
|
||||
|
||||
Read through the rdiff-backup man page for additional info, exhaustive usage options and examples:
|
||||
|
||||
```
|
||||
# man rdiff-backup
|
||||
```
|
||||
|
||||
rdiff-backup Homepage: [http://www.nongnu.org/rdiff-backup/][12]
|
||||
|
||||
That’s it for now! In this tutorial, we showed you how to install and basically use rdiff-backup, an easy-to-use Python script for local/remote incremental backup in Linux. Do share your thoughts with us via the feedback section below.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
作者简介:
|
||||
|
||||
Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.
|
||||
|
||||
|
||||
|
||||
------------
|
||||
|
||||
via: http://www.tecmint.com/rdiff-backup-remote-incremental-backup-for-linux/
|
||||
|
||||
作者:[Aaron Kili ][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.tecmint.com/author/aaronkili/
|
||||
[1]:http://www.tecmint.com/install-cygwin-to-run-linux-commands-on-windows-system/
|
||||
[2]:http://www.tecmint.com/rsync-local-remote-file-synchronization-commands/
|
||||
[3]:http://www.tecmint.com/ssh-passwordless-login-using-ssh-keygen-in-5-easy-steps/
|
||||
[4]:http://www.tecmint.com/sync-new-changed-modified-files-rsync-linux/
|
||||
[5]:http://www.tecmint.com/ssh-passwordless-login-using-ssh-keygen-in-5-easy-steps/
|
||||
[6]:http://www.tecmint.com/wp-content/uploads/2017/03/Backup-Files-to-Different-Partition.png
|
||||
[7]:http://www.tecmint.com/wp-content/uploads/2017/03/check-rdif-versions-on-servers.png
|
||||
[8]:http://www.tecmint.com/wp-content/uploads/2017/03/Backup-Remote-Linux-Directory-on-Local-Server.png
|
||||
[9]:http://www.tecmint.com/wp-content/uploads/2017/03/rdiff-backup-data-directory-contents.png
|
||||
[10]:http://www.tecmint.com/wp-content/uploads/2017/03/additional-files-in-root-directory.png
|
||||
[11]:http://www.tecmint.com/wp-content/uploads/2017/03/incremental-backup-of-root-files.png
|
||||
[12]:http://www.nongnu.org/rdiff-backup/
|
||||
[13]:http://www.tecmint.com/author/aaronkili/
|
||||
[14]:http://www.tecmint.com/10-useful-free-linux-ebooks-for-newbies-and-administrators/
|
||||
[15]:http://www.tecmint.com/free-linux-shell-scripting-books/
|
@ -1,157 +0,0 @@
|
||||
SSH PORT
|
||||
============================================================
|
||||
|
||||
The [SSH][4] (Secure Shell) port is 22\. It is not a co-incidence. This is a story I (Tatu Ylonen) haven't told before.
|
||||
|
||||
### THE STORY OF GETTING SSH PORT 22
|
||||
|
||||
I wrote the initial version of SSH in Spring 1995\. It was a time when [telnet][5] and [FTP][6] were widely used.
|
||||
|
||||
Anyway, I designed SSH to replace both `telnet` (port 23) and `ftp` (port 21). Port 22 was free. It was conveniently between the ports for `telnet` and `ftp`. I figured having that port number might be one of those small things that would give some aura of credibility. But how could I get that port number? I had never allocated one, but I knew somebody who had allocated a port.
|
||||
|
||||
The basic process for port allocation was fairly simple at that time. Internet was smaller and we were in very early stages of the Internet boom. Port numbers were allocated by IANA (Internet Assigned Numbers Authority). At the time, that meant an esteemed Internet pioneer called [Jon Postel][7] and [Joyce K. Reynolds][8]. Among other things, Jon had been the editor of such minor protocol standards as IP (RFC 791), ICMP (RFC 792), and TCP (RFC 793). Some of you may have heard of them.
|
||||
|
||||
To me Jon felt outright scary, having authored all the main Internet RFCs!
|
||||
|
||||
Anyway, just before announcing `ssh-1.0` in July 1995, I sent this e-mail to IANA:
|
||||
|
||||
```
|
||||
From ylo Mon Jul 10 11:45:48 +0300 1995
|
||||
From: Tatu Ylonen <ylo@cs.hut.fi>
|
||||
To: Internet Assigned Numbers Authority <iana@isi.edu>
|
||||
Subject: request for port number
|
||||
Organization: Helsinki University of Technology, Finland
|
||||
|
||||
Dear Sir,
|
||||
|
||||
I have written a program to securely log from one machine into another
|
||||
over an insecure network. It provides major improvements in security
|
||||
and functionality over existing telnet and rlogin protocols and
|
||||
implementations. In particular, it prevents IP, DNS and routing
|
||||
spoofing. My plan is to distribute the software freely on the
|
||||
Internet and to get it into as wide use as possible.
|
||||
|
||||
I would like to get a registered privileged port number for the
|
||||
software. The number should preferably be in the range 1-255 so that
|
||||
it can be used in the WKS field in name servers.
|
||||
|
||||
I'll enclose the draft RFC for the protocol below. The software has
|
||||
been in local use for several months, and is ready for publication
|
||||
except for the port number. If the port number assignment can be
|
||||
arranged in time, I'd like to publish the software already this week.
|
||||
I am currently using port number 22 in the beta test. It would be
|
||||
great if this number could be used (it is currently shown as
|
||||
Unassigned in the lists).
|
||||
|
||||
The service name for the software is "ssh" (for Secure Shell).
|
||||
|
||||
Yours sincerely,
|
||||
|
||||
Tatu Ylonen <ylo@cs.hut.fi>
|
||||
|
||||
... followed by protocol specification for ssh-1.0
|
||||
```
|
||||
|
||||
The next day, I had an e-mail from Joyce waiting in my mailbox:
|
||||
|
||||
```
|
||||
Date: Mon, 10 Jul 1995 15:35:33 -0700
|
||||
From: jkrey@ISI.EDU
|
||||
To: ylo@cs.hut.fi
|
||||
Subject: Re: request for port number
|
||||
Cc: iana@ISI.EDU
|
||||
|
||||
Tatu,
|
||||
|
||||
We have assigned port number 22 to ssh, with you as the point of
|
||||
contact.
|
||||
|
||||
Joyce
|
||||
```
|
||||
|
||||
There we were! SSH port was 22!!!
|
||||
|
||||
On July 12, 1995, at 2:32am, I announced a final beta version to my beta testers at Helsinki University of Technology. At 5:23pm I announced ssh-1.0.0 packages to my beta testers. At 5:51pm on July 12, 1995, I sent an announcement about SSH (Secure Shell) to the `cypherpunks@toad.com` mailing list. I also posted it in a few newsgroups, mailing lists, and directly to selected people who had discussed related topics on the Internet.
|
||||
|
||||
### CHANGING THE SSH PORT IN THE SERVER
|
||||
|
||||
By default, the SSH server still runs in port 22\. However, there are occasions when it is run in a different port. Testing use is one reason. Running multiple configurations on the same host is another. Rarely, it may also be run without root privileges, in which case it must be run in a non-privileged port (i.e., port number >= 1024).
|
||||
|
||||
The port number can be configured by changing the `Port 22` directive in [/etc/ssh/sshd_config][9]. It can also be specified using the `-p <port>` option to [sshd][10]. The SSH client and [sftp][11] programs also support the `-p <port>` option.
|
||||
|
||||
### CONFIGURING SSH THROUGH FIREWALLS
|
||||
|
||||
SSH is one of the few protocols that are frequently permitted through firewalls. Unrestricted outbound SSH is very common, especially in smaller and more technical organizations. Inbound SSH is usually restricted to one or very few servers.
|
||||
|
||||
### OUTBOUND SSH
|
||||
|
||||
Configuring outbound SSH in a firewall is very easy. If there are restrictions on outgoing traffic at all, just create a rule that allows TCP port 22 to go out. That is all. If you want to restrict the destination addresses, you can also limit the rule to only permit access to your organization's external servers in the cloud, or to a [jump server][12] that guards cloud access.
|
||||
|
||||
### BACK-TUNNELING IS A RISK
|
||||
|
||||
Unrestricted outbound SSH can, however, be risky. The SSH protocol supports [tunneling][13]. The basic idea is that it is possible to have the SSH server on an external server listen to connections from anywhere, forward those back into the organization, and then make a connection to some Internal server.
|
||||
|
||||
This can be very convenient in some environments. Developers and system administrators frequently use it to open a tunnel that they can use to gain remote access from their home or from their laptop when they are travelling.
|
||||
|
||||
However, it generally violates policy, takes control away from firewall administrators and the security team, and it violates policy. It can, for example, violate [PCI][14], [HIPAA][15], or [NIST SP 800-53][16]. It can be used by hackers and foreign intelligence agencies to leave backdoors into organizations.
|
||||
|
||||
[CryptoAuditor][17] is a product that can control tunneling at a firewall or at the entry point to a group of cloud servers. It works together with [Universal SSH Key Manager][18] to gain access to [host keys][19] and is able to use them to decrypt the SSH sessions at a firewall and block unauthorized forwarding.
|
||||
|
||||
### INBOUND SSH ACCESS
|
||||
|
||||
For inbound access, there are a few practical alternatives:
|
||||
|
||||
* Configure firewall to forward all connections to port 22 to a particular IP address on the internal network or [DMZ][1]. Run [CryptoAuditor][2] or a jump server at that IP address to control and audit further access into the organization.
|
||||
* Use different ports on the firewall to access different servers.
|
||||
* Only allow SSH access after you have logged in using a VPN (Virtual Private Network), typically using the [IPsec][3] protocol.
|
||||
|
||||
### ENABLING SSH ACCESS VIA IPTABLES
|
||||
|
||||
[Iptables][20] is a host firewall built into the Linux kernel. It is typically configured to protect the server by preventing access to any ports that have not been expressly opened.
|
||||
|
||||
If `iptables` is enabled on the server, the following commands can be used to permit incoming SSH access. They must be run as root.
|
||||
|
||||
```
|
||||
iptables -A INPUT -p tcp --dport 22 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT
|
||||
iptables -A OUTPUT -p tcp --sport 22 -m conntrack --ctstate ESTABLISHED -j ACCEPT
|
||||
```
|
||||
|
||||
If you want to save the rules permanently, on some systems that can be done with the command:
|
||||
|
||||
```
|
||||
service iptables save
|
||||
```
|
||||
|
||||
![SSH port at firewall can permit tunneling to banks](https://www.ssh.com/s/ssh-port-firewall-access-banks-950x333-s+ZpRviP.png)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.ssh.com/ssh/port
|
||||
|
||||
作者:[Tatu Ylonen ][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://www.ssh.com/ssh/port
|
||||
[1]:https://en.wikipedia.org/wiki/DMZ_(computing)
|
||||
[2]:https://www.ssh.com/products/cryptoauditor/
|
||||
[3]:https://www.ssh.com/network/ipsec/
|
||||
[4]:https://www.ssh.com/ssh/
|
||||
[5]:https://www.ssh.com/ssh/telnet
|
||||
[6]:https://www.ssh.com/ssh/ftp/
|
||||
[7]:https://en.wikipedia.org/wiki/Jon_Postel
|
||||
[8]:https://en.wikipedia.org/wiki/Joyce_K._Reynolds
|
||||
[9]:https://www.ssh.com/ssh/sshd_config/
|
||||
[10]:https://www.ssh.com/ssh/sshd/
|
||||
[11]:https://www.ssh.com/ssh/sftp/
|
||||
[12]:https://www.ssh.com/iam/jump-server
|
||||
[13]:https://www.ssh.com/ssh/tunneling/
|
||||
[14]:https://www.ssh.com/compliance/pci/
|
||||
[15]:https://www.ssh.com/compliance/hipaa/security-rule
|
||||
[16]:https://www.ssh.com/compliance/nist-800-53/
|
||||
[17]:https://www.ssh.com/products/cryptoauditor/
|
||||
[18]:https://www.ssh.com/products/universal-ssh-key-manager/
|
||||
[19]:https://www.ssh.com/ssh/host-key
|
||||
[20]:https://en.wikipedia.org/wiki/Iptables
|
132
sources/tech/20170501 Containers running Containers.md
Normal file
132
sources/tech/20170501 Containers running Containers.md
Normal file
@ -0,0 +1,132 @@
|
||||
Containers running Containers
|
||||
============================================================
|
||||
|
||||
Some genuinely exciting news piqued my interest at this year’s DockerCon, that being the new Operating System (OS), LinuxKit, which was announced and is immediately on offer from the undisputed heavyweight container company, Docker.
|
||||
|
||||
The container giant has announced a flexible, extensible Operating System where system services run inside containers for portability. You might be surprised to hear that even includes the Docker runtime daemon itself.
|
||||
|
||||
In this article we’ll have a quick look at what’s promised in LinuxKit, how to try it out for yourself and at ever-shrinking, optimised containers.
|
||||
|
||||
**Less Is More**
|
||||
|
||||
There’s no denying that users have been looking for a stripped-down version of Linux to run their microservices upon. With containerisation you’re trying your hardest to minimise each application so that it becomes a standalone process which sits inside a container of its own. However constantly shifting containers around because you’re patching the host that the containers reside on causes issues. In fact without an orchestrator like Kubernetes or Docker Swarm that container-shuffling is almost always going to cause downtime.
|
||||
|
||||
Needless to say that’s just one reason to keep your OS as miniscule as possible; one of many.
|
||||
|
||||
A favourite quote I’ve repeated on a number of occasions, comes from the talented Dutch programmer, Wietse Zweitze, who brought us the e-mail stalwart Postfix and TCP Wrappers amongst other renowned software.
|
||||
|
||||
The Postfix website ([Postfix TLS_README][10]) states that even if you’re as careful with your coding as Wietse that for “every 1000 lines [you] introduce one additional bug into Postfix.” From my professional DevSecOps perspective by the mention of “bug” I might be forgiven for loosely translating that definition into security issues too.
|
||||
|
||||
From a security perspective it’s precisely for this reason that less-is-more in the world of code. Simply put there’s a number of benefits to using less lines of code; namely security, administration time and performance. For starters there’s less security bugs, less time updating packages and faster boot times.
|
||||
|
||||
**Look deeper inside**
|
||||
|
||||
Think about what runs your application from inside a container.
|
||||
|
||||
A good starting point is Alpine Linux ([https://alpinelinux.org/downloads][1]) which is a low-fat, boiled-down, reduced OS commonly preferred over the more bloated host favourites, such as Ubuntu or CentOS. Alpine also provides a miniroot filesystem (for use within containers) which comes in at a staggering 1.8MB at the last check. Indeed the ISO download for a fully-working Linux Operating System comes in at a remarkable 80MB in size.
|
||||
|
||||
If you decide to utilise a Docker base image from Alpine Linux then you can find one on the Docker Hub ([https://hub.docker.com/_/alpine][2]) where Alpine Linux describes itself as: “A minimal Docker image based on Alpine Linux with a complete package index and only 5 MB in size!”.
|
||||
|
||||
It’s been said, and I won’t attempt to verify this meme, that the ubiquitous Window Start Button is around the same filesize! I’ll refrain from commenting further.
|
||||
|
||||
In all seriousness hopefully that gives you an idea of the power of innovative Unix-type OSs like Alpine Linux.
|
||||
|
||||
**Lock everything up**
|
||||
|
||||
What’s more, it goes on to explain that Alpine Linux is (not surprisingly) based on BusyBox ([BusyBox][3]), the famous set of Linux commands neatly packaged which many people won’t be aware sits inside their broadband router, smart television and of course many IoT devices in their homes as they read this.
|
||||
|
||||
Comments on the the About page ([Alpine Linux][4]) of the Alpine Linux site states:
|
||||
|
||||
“Alpine Linux was designed with security in mind. The kernel is patched with an unofficial port of grsecurity/PaX, and all userland binaries are compiled as Position Independent Executables (PIE) with stack smashing protection. These proactive security features prevent exploitation of entire classes of zero-day and other vulnerabilities.”
|
||||
|
||||
In other words the boiled-down binaries bundled inside the Alpine Linux builds which offers the system its functionality have already been sieved through clever industry-standard security tools in order to help mitigate buffer overflow attacks.
|
||||
|
||||
**Odd socks**
|
||||
|
||||
Why do the innards of containers matter when we’re dealing with Docker’s new OS you may quite rightly ask?
|
||||
|
||||
Well, as you might have guessed, when it comes to containers their construction is all about losing bloat. It’s about not including anything unless it’s absolutely necessary. It’s about having confidence so that you can reap the rewards of decluttering your cupboards, garden shed, garage and sock drawer with total impunity.
|
||||
|
||||
Docker certainly deserve some credit for their foresight. Reportedly, early 2016 Docker hired a key driving force behind Alpine Linux, Nathaniel Copa, who helped switch the default, official image library away from Ubuntu to Alpine. The bandwidth that Docker Hub saved from the newly-streamlined image downloads alone must have been welcomed.
|
||||
|
||||
And, bringing us up-to-date, that work will stand arm-in-arm with the latest container-based OS work; Docker’s LinuxKit.
|
||||
|
||||
For clarity LinuxKit is not ever-likely destined to replace Alpine but rather to sit underneath the containers and act as a stripped-down OS that you can happily spin up your runtime daemon (in this case the Docker daemon which spawns your containers) upon.
|
||||
|
||||
**Blondie's Atomic**
|
||||
|
||||
A finely-tuned host is by no means a new thing (I mentioned the household devices embedded with Linux previously) and the evil geniuses who have been optimising Linux for the last couple of decades realised sometime ago that the underlying OS was key to churning out a server estate fulls of hosts brimming with containers.
|
||||
|
||||
For example the mighty Red Hat have long been touting Red Hat Atomic ([https://www.redhat.com/en/resources/red-hat-enterprise-linux-atomic-host][5]) having contributed to Project Atomic ([Project Atomic][6]). The latter goes on to explain:
|
||||
|
||||
“Based on proven technology either from Red Hat Enterprise Linux or the CentOS and Fedora projects, Atomic Host is a lightweight, immutable platform, designed with the sole purpose of running containerized applications.”
|
||||
|
||||
There’s good reason that the underlying, immutable Atomic OS is forwarded as the recommended choice with Red Hat’s OpenShift PaaS (Platform as a Service) product. It’s minimal, performant and sophisticated.
|
||||
|
||||
**Features**
|
||||
|
||||
The mantra that less-is-more was evident throughout Docker’s announcement regarding LinuxKit. The project to realise the vision of LinuxKit was apparently no small undertaking and with the guiding hand of expert Justin Cormack, a Docker veteran and master with unikernels ([https://en.wikipedia.org/wiki/Unikernel][7]), and in partnership with HPE, Intel, ARM, IBM and Microsoft LinuxKit can run on mainframes as well as IoT-based fridge freezers.
|
||||
|
||||
The configurable, pluggable and extensible nature of LinuxKit will appeal to many projects looking for a baseline upon which to build their services. By open-sourcing the project Docker are wisely inviting input from every man and their dog to contribute to its functionality which will mature like a good cheese undoubtedly over time.
|
||||
|
||||
**Proof of the pudding**
|
||||
|
||||
Having promised to point those eager to get going with this new OS, let us wait no longer. If you want to get your hands on LinuxKit you can do so from the GitHub page here: [LinuxKit][11]
|
||||
|
||||
On the GitHub page there’s instructions on how to get up and running along with some features.
|
||||
|
||||
Time permitting I plan to get my hands much dirtier with LinuxKit. The somewhat-contentious Kubernetes versus Docker Swarm orchestration capabilities will be interesting to try out. I’d like to see memory footprints, boot times and diskspace-usage benchmarking too.
|
||||
|
||||
If the promises are true then pluggable system services which run as containers is a fascinating way to build an OS. Docker blogged ([https://blog.docker.com/2017/04/introducing-linuxkit-container-os-toolkit][12]) the following on its tiny footprint: “Because LinuxKit is container-native, it has a very minimal size – 35MB with a very minimal boot time. All system services are containers, which means that everything can be removed or replaced.”
|
||||
|
||||
I don’t know about you but that certainly whets my appetite.
|
||||
|
||||
**Call the cops**
|
||||
|
||||
Features aside with my DevSecOps hat on I will be in seeing how the promise of security looks in reality.
|
||||
|
||||
Docker quotes from NIST (the National Institute of Standards and Technology: [https://www.nist.gov][8]) and claims on their blog that:
|
||||
|
||||
“Security is a top-level objective and aligns with NIST stating, in their draft Application Container Security Guide: “Use container-specific OSes instead of general-purpose ones to reduce attack surfaces. When using a container-specific OS, attack surfaces are typically much smaller than they would be with a general-purpose OS, so there are fewer opportunities to attack and compromise a container-specific OS.”
|
||||
|
||||
Possibly the most important container-to-host and host-to-container security innovation will be the fact that system containers (system services) are apparently heavily sandboxed into their own unprivileged space, given just the external access that they need.
|
||||
|
||||
Couple that functionality with the collaboration of the Kernel Self Protection Project (KSPP) ([https://kernsec.org/wiki/index.php/Kernel_Self_Protection_Project][9]) and with a resounding thumbs-up from me it looks like Docker have focussed on something very worthwhile. For those unfamiliar KSPP’s raison d’etre is as follows:
|
||||
|
||||
“This project starts with the premise that kernel bugs have a very long lifetime, and that the kernel must be designed in ways to protect against these flaws.”
|
||||
|
||||
The KSPP site goes on to state admirably that:
|
||||
|
||||
“Those efforts are important and on-going, but if we want to protect our billion Android phones, our cars, the International Space Station, and everything else running Linux, we must get proactive defensive technologies built into the upstream Linux kernel. We need the kernel to fail safely, instead of just running safely.”
|
||||
|
||||
And, initially, if Docker only take baby steps with LinuxKit the benefit that it will bring over time through maturity will likely make great strides in the container space.
|
||||
|
||||
**The End is far from nigh**
|
||||
|
||||
As the powerhouse that is Docker continues to grow arms and legs there’s no doubt whatsoever that these giant-sized leaps in the direction of solid progress will benefit users and other software projects alike.
|
||||
|
||||
I would encourage all with an interest in Linux to closely watch this (name)space...
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.devsecops.cc/devsecops/containers.html
|
||||
|
||||
作者:[Chris Binnie ][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.devsecops.cc/
|
||||
[1]:https://alpinelinux.org/downloads/
|
||||
[2]:https://hub.docker.com/_/alpine
|
||||
[3]:https://busybox.net/
|
||||
[4]:https://www.alpinelinux.org/about/
|
||||
[5]:https://www.redhat.com/en/resources/red-hat-enterprise-linux-atomic-host
|
||||
[6]:http://www.projectatomic.io/
|
||||
[7]:https://en.wikipedia.org/wiki/Unikernel
|
||||
[8]:https://www.nist.gov/
|
||||
[9]:https://kernsec.org/wiki/index.php/Kernel_Self_Protection_Project
|
||||
[10]:http://www.postfix.org/TLS_README.html
|
||||
[11]:https://github.com/linuxkit/linuxkit
|
||||
[12]:https://blog.docker.com/2017/04/introducing-linuxkit-container-os-toolkit
|
@ -0,0 +1,106 @@
|
||||
hkurj translating
|
||||
How to Find Difference Between Two Directories Using Diff and Meld Tools
|
||||
============================================================
|
||||
|
||||
In an earlier article, we reviewed [9 best file comparison and difference (Diff) tools for Linux][1] and in this article, we will describe how to find the difference between two directories in Linux.
|
||||
|
||||
Normally, to [compare two files in Linux][2], we use the diff – a simple and original Unix command-line tool that shows you the difference between two computer files; compares files line by line and it is easy to use, comes with pre-installed on most if not all Linux distributions.
|
||||
|
||||
The question is how do we get the difference between two directories in Linux? Here, we want to know what files/subdirectories are common in the two directories, those that are present in one directory but not in the other.
|
||||
|
||||
The conventional syntax for running diff is as follows:
|
||||
|
||||
```
|
||||
$ diff [OPTION]… FILES
|
||||
$ diff options dir1 dir2
|
||||
```
|
||||
|
||||
By default, its output is ordered alphabetically by file/subdirectory name as shown in the screenshot below. In this command, the `-q` switch tells diff to report only when files differ.
|
||||
|
||||
```
|
||||
$ diff -q directory-1/ directory-2/
|
||||
```
|
||||
[
|
||||
![Difference Between Two Directories](http://www.tecmint.com/wp-content/uploads/2017/05/Difference-Between-Two-Directories.png)
|
||||
][3]
|
||||
|
||||
Difference Between Two Directories
|
||||
|
||||
Again diff doesn’t go into the subdirectories, but we can use the `-r` switch to read the subdirectories as well like this.
|
||||
|
||||
```
|
||||
$ diff -qr directory-1/ directory-2/
|
||||
```
|
||||
|
||||
### Using Meld Visual Diff and Merge Tool
|
||||
|
||||
There is a cool graphical option called meld (a visual diff and merge tool for the GNOME Desktop) for those who enjoy using the mouse, you can install it as follows.
|
||||
|
||||
```
|
||||
$ sudo apt install meld [Debian/Ubuntu systems]
|
||||
$ sudo yum install meld [RHEL/CentOS systems]
|
||||
$ sudo dnf install meld [Fedora 22+]
|
||||
```
|
||||
|
||||
Once you have installed it, search for “meld” in the Ubuntu Dash or Linux Mint Menu, in Activities Overview in Fedora or CentOS desktop and launch it.
|
||||
|
||||
You will see the Meld interface below, where you can choose file or directory comparison as well as version control view. Click on directory comparison and move to the next interface.
|
||||
|
||||
[
|
||||
![Meld Comparison Tool](http://www.tecmint.com/wp-content/uploads/2017/05/Meld-Comparison-Tool.png)
|
||||
][4]
|
||||
|
||||
Meld Comparison Tool
|
||||
|
||||
Select the directories you want to compare, note that you can add a third directory by checking the option “3-way Comparison”.
|
||||
|
||||
[
|
||||
![Select Comparison Directories](http://www.tecmint.com/wp-content/uploads/2017/05/Select-Comparison-Directories.png)
|
||||
][5]
|
||||
|
||||
Select Comparison Directories
|
||||
|
||||
Once you selected the directories, click on “Compare”.
|
||||
|
||||
[
|
||||
![Listing Difference Between Directories](http://www.tecmint.com/wp-content/uploads/2017/05/Listing-Difference-Between-Directories.png)
|
||||
][6]
|
||||
|
||||
Listing Difference Between Directories
|
||||
|
||||
In this article, we described how to find the difference between two directories in Linux. If you know any other commandline or gui way don’t forget to share your thoughts to this article via the comment section below.
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
作者简介:
|
||||
|
||||
Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.
|
||||
|
||||
|
||||
|
||||
-------------------
|
||||
|
||||
via: http://www.tecmint.com/compare-find-difference-between-two-directories-in-linux/
|
||||
|
||||
作者:[Aaron Kili ][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.tecmint.com/author/aaronkili/
|
||||
[1]:http://www.tecmint.com/best-linux-file-diff-tools-comparison/
|
||||
[2]:http://www.tecmint.com/freefilesync-compare-synchronize-files-in-ubuntu/
|
||||
[3]:http://www.tecmint.com/wp-content/uploads/2017/05/Difference-Between-Two-Directories.png
|
||||
[4]:http://www.tecmint.com/wp-content/uploads/2017/05/Meld-Comparison-Tool.png
|
||||
[5]:http://www.tecmint.com/wp-content/uploads/2017/05/Select-Comparison-Directories.png
|
||||
[6]:http://www.tecmint.com/wp-content/uploads/2017/05/Listing-Difference-Between-Directories.png
|
||||
[7]:http://www.tecmint.com/compare-find-difference-between-two-directories-in-linux/#
|
||||
[8]:http://www.tecmint.com/compare-find-difference-between-two-directories-in-linux/#
|
||||
[9]:http://www.tecmint.com/compare-find-difference-between-two-directories-in-linux/#
|
||||
[10]:http://www.tecmint.com/compare-find-difference-between-two-directories-in-linux/#
|
||||
[11]:http://www.tecmint.com/compare-find-difference-between-two-directories-in-linux/#comments
|
||||
[12]:http://www.tecmint.com/author/aaronkili/
|
||||
[13]:http://www.tecmint.com/10-useful-free-linux-ebooks-for-newbies-and-administrators/
|
||||
[14]:http://www.tecmint.com/free-linux-shell-scripting-books/
|
@ -0,0 +1,153 @@
|
||||
Installing Google TensorFlow Neural Network Software for CPU and GPU on Ubuntu 16.04
|
||||
============================================================
|
||||
|
||||
### On this page
|
||||
|
||||
1. [1 Install CUDA][1]
|
||||
2. [2 Install the CuDNN library][2]
|
||||
3. [3 Add the installation location to Bashrc file][3]
|
||||
4. [4 Install TensorFlow with GPU support][4]
|
||||
5. [5 Install TensorFlow with only CPU support][5]
|
||||
|
||||
TensorFlow is an open source software for performing machine learning tasks. Google, its creator wanted to expose a powerful tool to help developers explore and build machine learning based applications and so they released this as an open source project. TensorFlow is an extremely powerful tool specializing in a type of neural network called the deep neural network.
|
||||
|
||||
Deep neural networks are used to perform complex machine learning tasks such as image recognition, handwriting recognition, Natural language processing, chatbots, and more. These neural networks are trained to learn the tasks it is supposed to perform. As the computations required for training is extremely huge, most of the time, a GPU support is required and this is where TensorFlow comes to the rescue. It is GPU enabled and thus by installing the software with GPU support, the training time required can be significantly reduced.
|
||||
|
||||
This tutorial helps you to install TensorFlow for CPU only and also with GPU support. So, to get TensorFlow with GPU support, you must have a Nvidia GPU with CUDA support. Installation of CUDA and CuDNN ( Nvidia computation libraries) are a bit tricky and this guide provides a step by step approach to installing them before actually coming to the installation of TensorFlow itself.
|
||||
|
||||
The Nvidia CUDA is a GPU-accelerated library that has highly tuned implementations for standard routines used in neural networks. the CuDNN is a tuning library for the GPU which takes care of GPU performance tuning automatically. TensorFlow relies on both these for training and running deep neural networks and hence they have to be installed before TensorFlow is installed.
|
||||
|
||||
It is very important to note that, those who DO NOT wish to install TensorFlow with GPU support, then you can skip all these following steps and jump straight to "Step 5: Install TensorFlow with only CPU support" section of this guide.
|
||||
|
||||
An introduction to TensorFlow can be found [here][10].
|
||||
|
||||
### 1 Install CUDA
|
||||
|
||||
Firstly, download CUDA for Ubuntu 16.04 from [here.][11] This file is pretty big (2GB) so, it might take sometime to get downloaded.
|
||||
|
||||
The downloaded file is ".deb" package. To install it, run the following commands:
|
||||
|
||||
sudo dpkg -i cuda-repo-ubuntu1604-8-0-local_8.0.44-1_amd64.deb
|
||||
|
||||
[
|
||||
![Install CUDA](https://www.howtoforge.com/images/installing_tensorflow_machine_learning_software_for_cpu_and_gpu_on_ubuntu_1604/image1.png)
|
||||
][12]
|
||||
|
||||
the following commands install any dependencies that have been missed and finally install the cuda toolkit:
|
||||
|
||||
sudo apt install -f
|
||||
|
||||
sudo apt update
|
||||
|
||||
sudo apt install cuda
|
||||
|
||||
If it successfully installed, you will get a message saying it's "successfully installed". If it's already installed, then you will get output similar to the image below:
|
||||
|
||||
[
|
||||
![Install CUDA with apt](https://www.howtoforge.com/images/installing_tensorflow_machine_learning_software_for_cpu_and_gpu_on_ubuntu_1604/image2.png)
|
||||
][13]
|
||||
|
||||
### 2 Install the CuDNN library
|
||||
|
||||
CuDNN downloading requires a bit of work sadly. Nvidia does not directly give you the files to download (It's free however). Follow the steps to get your CuDNN files.
|
||||
|
||||
1. click [here][8] to goto Nvidia's register page and create an account. First page asks you to enter your personal details and the second page asks you to answer a few survey questions. It's alright if you do not know answers to all, you can just select an option at random.
|
||||
2. The previous step would have lead to Nvidia sending you an activation link to your mail-Id. Once you have activated, head over to the CuDNN download link [here][9].
|
||||
3. Once you login to that page, you will have to fill out another smaller survey. Randomly click on the checkboxes and then click on "proceed to Download" button at the bottom of the survey and in the next page click on agree to terms of use.
|
||||
4. Finally, in the drop down, click on "Download cuDNN v5.1 (Jan 20, 2017), for CUDA 8.0", and within that drop down, you need to download two files by clicking on it:
|
||||
* [cuDNN v5.1 Runtime Library for Ubuntu14.04 (Deb)][6]
|
||||
* [cuDNN v5.1 Developer Library for Ubuntu14.04 (Deb)][7]
|
||||
|
||||
NOTE: even though the library says it's for Ubuntu 14.04, use that link only. it works for 16.04 as well
|
||||
|
||||
Now that you finally have both the CuDNN files, it's time to install them!! Use the following commands from the folder which contains this downloaded files:
|
||||
|
||||
sudo dpkg -i libcudnn5_5.1.5-1+cuda8.0_amd64.deb
|
||||
|
||||
sudo dpkg -i libcudnn5-dev_5.1.5-1+cuda8.0_amd64.deb
|
||||
|
||||
Following image shows the output of running these commands:
|
||||
|
||||
[
|
||||
![Install the CuDNN library](https://www.howtoforge.com/images/installing_tensorflow_machine_learning_software_for_cpu_and_gpu_on_ubuntu_1604/image3.png)
|
||||
][14]
|
||||
|
||||
### 3 Add the installation location to Bashrc file
|
||||
|
||||
the installation location should be added to the bashrc file so that from the next time onward, the system should know where to find the installed directory for CUDA. use the following command to open the bashrc file:
|
||||
|
||||
sudo gedit ~/.bashrc
|
||||
|
||||
once the file opens, add the following two lines at the end of that file:
|
||||
|
||||
```
|
||||
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64"
|
||||
export CUDA_HOME=/usr/local/cuda
|
||||
```
|
||||
|
||||
### 4 Install TensorFlow with GPU support
|
||||
|
||||
this step we install TensorFlow with GPU support. Run the following command if you are using python 2.7:
|
||||
|
||||
pip install TensorFlow-gpu
|
||||
|
||||
if you have python 3.x instead of the above command, use the following:
|
||||
|
||||
pip3 install TensorFlow-gpu
|
||||
|
||||
You will get a "successfully installed" message once the command finishes execution. Now, all that remains to test is whether it has installed correctly. To test this, open a command prompt and type the following commands:
|
||||
|
||||
python
|
||||
|
||||
import TensorFlow as tf
|
||||
|
||||
You should get an output similar to the image below. From the image you can observe that the CUDA libraries have been successfully opened. Now, if there were errors, messages saying failure to open CUDA and even modules not being found will appear. In that case you might have missed one of the step above and re-doing this tutorial carefully will be the way to go.
|
||||
|
||||
[
|
||||
![Install TensorFlow with GPU support](https://www.howtoforge.com/images/installing_tensorflow_machine_learning_software_for_cpu_and_gpu_on_ubuntu_1604/image4.png)
|
||||
][15]
|
||||
|
||||
### 5 Install TensorFlow with only CPU support
|
||||
|
||||
NOTE : This step has to be executed by people who do not have a GPU or people who do not have a Nvidia GPU. Others, please ignore this step!!
|
||||
|
||||
installing TensorFlow for CPU only is extremely easy. Use the following two commands :
|
||||
|
||||
pip install TensorFlow
|
||||
|
||||
if you have python 3.x instead of the above command, use the following:
|
||||
|
||||
pip3 install TensorFlow
|
||||
|
||||
Yes, it's that simple!
|
||||
|
||||
This concludes, the installation guide, you can now start to build your deep learning applications. If you are just starting out, then you can look at the official tutorial for beginners [here][16]. If you are looking for more advanced tutorials, then you can learn how to setup an image recognition system/tool which capable of identifying thousands of objects with high accuracy from [here][17].
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.howtoforge.com/tutorial/installing-tensorflow-neural-network-software-for-cpu-and-gpu-on-ubuntu-16-04/
|
||||
|
||||
作者:[Akshay Pai ][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://www.howtoforge.com/tutorial/installing-tensorflow-neural-network-software-for-cpu-and-gpu-on-ubuntu-16-04/
|
||||
[1]:https://www.howtoforge.com/tutorial/installing-tensorflow-neural-network-software-for-cpu-and-gpu-on-ubuntu-16-04/#-install-cuda
|
||||
[2]:https://www.howtoforge.com/tutorial/installing-tensorflow-neural-network-software-for-cpu-and-gpu-on-ubuntu-16-04/#-install-the-cudnn-library
|
||||
[3]:https://www.howtoforge.com/tutorial/installing-tensorflow-neural-network-software-for-cpu-and-gpu-on-ubuntu-16-04/#-add-the-installation-location-to-bashrc-file
|
||||
[4]:https://www.howtoforge.com/tutorial/installing-tensorflow-neural-network-software-for-cpu-and-gpu-on-ubuntu-16-04/#-install-tensorflow-with-gpu-support
|
||||
[5]:https://www.howtoforge.com/tutorial/installing-tensorflow-neural-network-software-for-cpu-and-gpu-on-ubuntu-16-04/#-install-tensorflow-with-only-cpu-support
|
||||
[6]:https://developer.nvidia.com/compute/machine-learning/cudnn/secure/v5.1/prod_20161129/8.0/libcudnn5_5.1.10-1+cuda8.0_amd64-deb
|
||||
[7]:https://developer.nvidia.com/compute/machine-learning/cudnn/secure/v5.1/prod_20161129/8.0/libcudnn5-dev_5.1.10-1+cuda8.0_amd64-deb
|
||||
[8]:https://developer.nvidia.com/group/node/873374/subscribe/og_user_node
|
||||
[9]:https://developer.nvidia.com/rdp/form/cudnn-download-survey
|
||||
[10]:http://sourcedexter.com/what-is-tensorflow/
|
||||
[11]:https://developer.nvidia.com/compute/cuda/8.0/Prod2/local_installers/cuda-repo-ubuntu1604-8-0-local-ga2_8.0.61-1_amd64-deb
|
||||
[12]:https://www.howtoforge.com/images/installing_tensorflow_machine_learning_software_for_cpu_and_gpu_on_ubuntu_1604/big/image1.png
|
||||
[13]:https://www.howtoforge.com/images/installing_tensorflow_machine_learning_software_for_cpu_and_gpu_on_ubuntu_1604/big/image2.png
|
||||
[14]:https://www.howtoforge.com/images/installing_tensorflow_machine_learning_software_for_cpu_and_gpu_on_ubuntu_1604/big/image3.png
|
||||
[15]:https://www.howtoforge.com/images/installing_tensorflow_machine_learning_software_for_cpu_and_gpu_on_ubuntu_1604/big/image4.png
|
||||
[16]:https://www.tensorflow.org/get_started/mnist/beginners
|
||||
[17]:https://www.tensorflow.org/tutorials/image_recognition
|
@ -1,238 +0,0 @@
|
||||
在 UEFI 模式下安装 Linux:快速安装指南
|
||||
============================================================
|
||||
|
||||
|
||||
此页面是免费浏览的,没有烦人的外部广告;然而,我的确花了时间准备,网站托管也花了钱。如果您发现此页面帮到了您,请考虑进行小额捐款,以帮助保持网站的运行。谢谢!
|
||||
|
||||
### 引言
|
||||
|
||||
几年来,一种新的固件技术一直潜伏在大多数普通用户中。该技术被称为 [可扩展固件接口(EFI)][29](译者注:Extensible Firmware Interface), 或更新的统一可扩展固件接口(UEFI, 本质上是 EFI 2. _x_ )(译者注:Unified EFI),它已经开始替代古老的[基本输入/输出系统(BIOS)][30](译者注:Basic Input/Output System)固件技术,有经验的计算机用户或多或少都有些熟悉。
|
||||
|
||||
本页面面向 Linux 用户,是使用 EFI 技术的一个快速介绍,其中包括有关开始将 Linux 安装到此类计算机上的建议。不幸的是,EFI 是一个密集的话题;EFI 软件本身是复杂的,许多实现有系统特定的怪异甚至是缺陷。因此,我无法在一个页面上描述在 EFI 计算机上安装和使用 Linux 的一切。我希望你能将本页面作为一个有用的起点,尽管如此,每个部分以及末尾[参考文献][31]部分的链接都会指向其他文档。
|
||||
|
||||
#### 目录
|
||||
|
||||
* [引言][18]
|
||||
* [你的计算机是否使用 EFI 技术?][19]
|
||||
* [你的发行版是否支持 EFI 技术?][20]
|
||||
* [准备安装 Linux][21]
|
||||
* [安装 Linux][22]
|
||||
* [修复安装后的问题][23]
|
||||
* [哎呀:将传统模式下安装的引导转为 EFI 模式下的引导][24]
|
||||
* [参考文献][25]
|
||||
|
||||
### 你的计算机是否使用 EFI 技术?
|
||||
|
||||
EFI 是一种_固件_,意味着它是内置于计算机中处理低级任务的软件。最重要的是,固件控制着计算机的引导过程,反过来说就是基于 EFI 的计算机与基于 BIOS 的计算机的引导过程不同。(有关此规律的例外之处稍后再说。)这种差异可能使操作系统安装介质的设计超级复杂化,但是一旦安装运行,它对计算机的日常操作几乎没有影响。请注意,大多数制造商使用术语 “BIOS” 来表示他们的 EFI。我认为这种用法很混乱,所以我避免了;在我看来,EFI 和 BIOS 是两种不同类型的固件。
|
||||
|
||||
**注意:**苹果公司的 Mac 使用的 EFI 在许多方面是不寻常的。尽管本页面的大部分内容同样适用于 Mac,但有些细节上的出入,特别是在设置 EFI 引导加载程序的时候。这个任务最好在 OS X 上进行,使用 Mac 的 [bless utility][49]工具,我不在此做过多描述。
|
||||
|
||||
自从2006年第一次推出以来,EFI 已被用于基于英特尔的 Mac 上。从2012年底开始,大多数安装 Windows 8 或更高版本系统的计算机就已经默认使用 UEFI 启动,实际上大多数 PC 从 2011 年中期就开始使用 UEFI,尽管默认情况下它们可能无法以 EFI 模式启动。尽管2011年前销出的 PC 大都默认使用 BIOS 模式启动,但也有一些支持 EFI。
|
||||
|
||||
如果你不确定你的计算机是否支持 EFI,则应查看固件设置实用程序,参考用户手册,以便了解 _EFI_、_UEFI_ 以及 _legacy booting_。(可以通过查找用户手册的 PDF 文件来快速了解。)如果你没有找到类似的参考,你的计算机可能使用老式的(“legacy”) BIOS 引导;但如果你找到了这些术语的参考,几乎可以肯定它使用了 EFI 技术。你还可以尝试_只_有 EFI 模式引导加载器的安装介质。使用 [rEFInd][50] 制作的 USB 闪存驱动器或 CD-R 镜像是用来测试不错的选择。
|
||||
|
||||
在继续之前,你应当了解大多数 _x_ 86 和 _x_ 86-64 架构的计算机上的 EFI 都包含一个叫做_兼容支持模块(CSM)_(译者注:Compatibility Support Module)的组件,这使得 EFI 能够使用旧的 BIOS 风格的引导机制来引导操作系统。这会非常方便,因为它向后兼容;但是这样也导致一些意外情况的发生,因为计算机不论以 EFI 模式引导还是以 BIOS 模式(也称为 CSM 或 legacy)引导,在控制时没有标准的使用规范和用户界面。特别地,你的 Linux 安装介质非常容易意外的以 BIOS/CSM/legacy 模式启动,这会导致 Linux 以 BIOS/CSM/legacy 模式安装。如果 Linux 是唯一的操作系统,也可以正常工作,但是如果与在 EFI 模式下的 Windows 组成双启动的话,就会非常复杂。(反过来问题也可能发生。)以下部分将帮助你以正确模式引导安装程序。如果你在阅读这篇文章之前就已经以 BIOS 模式安装了 Linux,并且希望切换引导模式,请阅读后续章节,[哎呀:将传统模式下安装的引导转为 EFI 模式下的引导][51]。
|
||||
|
||||
UEFI 的一个附加功能值得一提:_Secure Boot_(译者注:直译为安全启动)。此特性旨在最大限度的降低计算机受到 _boot kit_ 病毒感染的风险,这是一种感染计算机引导加载程序的恶意软件。Boot kits 很难检测和删除,阻止它们的运行刻不容缓。微软公司要求所有带有支持 Windows 8 标志的台式机和笔记本电脑启用 Secure Boot。这一配置使 Linux 的安装变得复杂,尽管有些发行版可以较好的处理这个问题。不要将 Secure Boot 和 EFI 或 UEFI 混淆;支持 EFI 的计算机不一定支持 Secure Boot,而且支持 EFI 的 _x_ 86-64 的计算机也可以禁用 Secure Boot。微软同意用户在 Windows 8 认证的 _x_ 86 和 _x_ 86-64 计算机上禁用 Secure Boot功能;然而对装有 Windows 8 的 ARM 计算机而言却相反,它们必须_不允许_禁用 Secure Boot。幸运的是,基于 ARM 的 Windows 8 计算机目前很少见。我建议避免使用它们。
|
||||
|
||||
### 你的发行版是否支持 EFI 技术?
|
||||
|
||||
大多数 Linux 发行版多年来一直支持 EFI。然而,不同的发行版对 EFI 的支持程度不同。大多数主流发行版(Fedora,OpenSUSE,Ubuntu 等)都能很好的支持 EFI,包括对 Secure Boot 的支持。另外一些“自定义”的发行版,比如 Gentoo,对 EFI 的支持较弱,但他们的性质使其很容易添加 EFI 支持。事实上,可以向_任意_ Linux 发行版添加 EFI 支持:你需要安装它(即使在 BIOS 模式下),然后在计算机上安装 EFI 引导加载程序。有关如何执行此操作的信息,请参阅[哎呀:将传统模式下安装的引导转为 EFI 模式下的引导][52]部分。
|
||||
|
||||
你应当查看发行版的功能列表,来确定它是否支持 EFI。你还应当注意你的发行版对 Secure Boot 的支持情况,特别是如果你打算和 Windows 8 组成双启动。请注意,即使正式支持 Secure Boot 的发行版也可能要求禁用此功能,因为 Linux 对 Secure Boot 的支持通常很差劲,或者导致意外情况的发生。
|
||||
|
||||
### 准备安装 Linux
|
||||
|
||||
下面几个准备步骤有助于在 EFI 计算机上 Linux 的安装,使其更加顺利:
|
||||
|
||||
1. **升级固件** — 有些 EFI 并不完整,但硬件制造商偶尔会发布其固件的更新。因此我建议你将固件升级到最新可用的版本。如果你从论坛的帖子知道自己计算机的 EFI 有问题,你应当在安装 Linux 之前更新它,因为如果安装 Linux 之后更新固件,会有些问题需要额外的操作才能解决。另一方面,升级固件是有一定风险的,所以如果制造商提供了 EFI 支持,最好的办法就是按他们提供的方式进行升级。
|
||||
|
||||
2. **了解如何使用固件** - 通常你可以通过在引导之前按 Del 键或功能键进入固件设置实用程序。按下开机键后尽快查看相关的提示信息,或者尝试每个功能键。类似的,ESC 键或功能键通常进入固件内置的引导管理器,可以选择要进入的操作系统或外部设备。一些制造商不断让这些设置隐藏的更深。在某些情况下,如[此页面][32]所述,你可以在 Windows 8 内这样做。
|
||||
|
||||
3. **调整以下固件设置:**
|
||||
|
||||
* **快速启动** — 此功能可以通过在硬件初始化时使用快捷方式来加快引导过程。这很好用,但会使 USB 设备不能初始化,导致计算机无法从 USB 闪存驱动器或类似的设备启动。因此禁用快速启动_可能_有一定的帮助,甚至是必须的;但是只有在 Linux 安装程序启动遇到问题时,你才能安全地将其停用。请注意,此功能有时可能会以其他名字出现。在某些情况下,你必须_启用_ USB 支持,而不是_禁用_快速启动功能。
|
||||
|
||||
* **安全启动** — Fedora,OpenSUSE,Ubuntu 以及其他的发行版官方就支持 Secure Boot;但是如果在启动引导加载程序或内核时遇到问题,可能需要禁用此功能。不幸的是,没办法具体描述怎么禁用,因为不同计算机的设置方法也不同。请参阅[我的 Secure Boot 页面][1]获取更多关于此话题的信息。
|
||||
|
||||
**注意:** 一些教程说安装 Linux 时需要启用 BIOS/CSM/legacy 支持。通常情况下,这样做是错的。启用这些支持可以解决启动安装程序涉及的问题,但也会带来新的问题。以这种方式安装的教程通常通过引导修复来解决这些问题,但最好从一开始就做对。本页面提供了帮助你以 EFI 模式启动 Linux 安装程序的提示,从而避免以后的问题。
|
||||
|
||||
* **CSM/legacy 选项** — 如果你想以 EFI 模式安装,请_关闭_这些选项。一些教程推荐启用这些选项,有时这是必须的 —— 比如,有些附加视频卡需要在固件中启用 BIOS 模式。尽管如此,大多数情况下启用 CSM/legacy 支持只会无意中增加以 BIOS 模式启动 Linux 的风险,但你并_不想_这样。请注意,Secure Boot 和 CSM/legacy 选项有时会交织在一起,因此更改任一选项之后务必检查另一个。
|
||||
|
||||
4. **禁用 Windows 的快速启动功能** — [这个页面][33]描述了如何禁用此功能,不禁用的话会导致文件系统损坏。请注意此功能与固件的快速启动不同。
|
||||
|
||||
5. **检查分区表** — 使用 [GPT fdisk][34],parted 或其他任意分区工具检查磁盘分区。理想情况下,你应该创建一个包含每个分区确切起点和终点(以扇区为单位)的硬拷贝。这会是很有用的参考,特别是在安装时进行手动分区的时候。如果已经安装了 Windows,确定可以识别你的 [EFI 系统分区(ESP)][35],它是一个 FAT 分区,设置了“启动标记”(parted 或 Gparted)或在 gdisk 中有名为 EF00 的类别码。
|
||||
|
||||
### 安装 Linux
|
||||
|
||||
大部分 Linux 发行版都提供了足够的安装说明;然而我注意到了在 EFI 模式安装中的几个常见的绊脚石:
|
||||
|
||||
* **确保使用正确位深的发行版** — EFI 启动加载器和 EFI 自身的位深相同。现代计算机通常是 64 位,尽管最初几代基于 Intel 的 Mac,一些现代的平板电脑和变形本,以及一些鲜为人知的电脑使用 32 位 EFI。虽然可以将 32 位 EFI 引导加载程序添加至 32 位发行版,但我还没有遇到过正式支持 32 位 EFI 的 Linux 发行版。(我的 [Managing EFI Boot Loaders for Linux][36] 工具一般包括引导加载程序,而且理解了这些原则你就可以修改 32 位发行版的安装程序,尽管这不是一个初学者该做的。)在 64 位 EFI 的计算机上安装 32 位发行版最让人头疼,而且我不在这里描述这一过程;在具有 64 位 EFI 的计算机上,你应当使用 64 位的发行版。
|
||||
|
||||
* **正确准备引导介质** — 将 .iso 镜像转移到 USB 闪存驱动器的第三方工具,比如 unetbootin,在创建正确的 EFI 模式引导项时经常失败。我建议按照发行版维护者的建议创建 USB 闪存驱动器。如果没有类似的建议,使用 Linux 的 dd 工具,通过执行 dd if=image.iso of=/dev/sdc 在识别为 /dev/sdc 的 USB 闪存驱动器上创建一个镜像。至于 Windows,有 [WinDD][37] 和 [dd for windows][38],但我从没测试过他们。请注意,使用不兼容 EFI 的工具创建安装介质是错误的,这会导致在 BIOS 模式下安装的巨大错误的发生,然后必须纠正它们,所以不要忽视这一点!
|
||||
|
||||
* **备份 ESP 分区** — 如果计算机已经存在 Windows 或者其他的操作系统,我建议在安装 Linux 之前备份你的 ESP 分区。尽管 Linux _不应_ 损坏 ESP 分区已有的文件,但似乎这时不时发生。发生这种事情时备份会有很大用处。只需简单的文件级的备份(使用 cp,tar,或者 zip 类似的工具)就足够了。
|
||||
|
||||
* **以 EFI 模式启动** — 以 BIOS/CSM/legacy 模式引导 Linux 安装程序的意外非常容易发生,特别是当固件启用 CSM/legacy 选项时。下面一些提示可以帮助你避免此问题:
|
||||
|
||||
* 进入 Linux shell 环境执行 ls /sys/firmware/efi 验证当前是否处于 EFI 模式。如果你看到一个文件和目录的列表,表明你已经以 EFI 模式启动,而且可以忽略以下多余的提示;如果没有,表明你是以 BIOS 模式启动的,应当重新检查你的设置。
|
||||
|
||||
* 使用固件内置的引导管理器(你应该已经知道在哪;请参阅[了解如何使用固件][26])使之以 EFI 模式启动。一般你会看到 CD-R 或 USB 闪存驱动器两个选项,其中一个选项包括 _EFI_ 或 _UEFI_ 字样的描述,另一个不包括。使用 EFI/UEFI 选项来启动介质。
|
||||
|
||||
* 禁用安全启动 - 即使你使用的发行版官方支持 Secure Boot,有时他们不能生效。在这种情况下,计算机会静默的转到下一个启动项,它可能是启动介质的 BIOS 模式,导致你以 BIOS 模式启动。请参阅[我的 Secure Boot 页面][27]以得到禁用 Secure Boot 的相关提示。
|
||||
|
||||
* 如果 Linux 安装程序总是无法以 EFI 模式启动,试试用我的 [rEFInd boot manager][28] 制作的 USB 闪存驱动器或 CD-R。如果 rEFInd 启动成功,它保证是以 EFI 模式运行的,而且在基于 UEFI 的 PC 上,它只显示 EFI 模式的引导项,因此若您启动到 Linux 安装程序,则应处于 EFI 模式。(但是在 Mac 上,除了 EFI 模式选项之外,rEFInd 还显示 BIOS 模式的引导项。)
|
||||
|
||||
* **准备 ESP 分区** — 除了 Mac,EFI 使用 ESP 分区来保存引导加载程序。如果你的计算机已经安装了 Windows,那么 ESP 分区就已存在,可以在 Linux 上直接使用。如果不是这样,那么我建议创建一个大小为 550 MB 的 ESP 分区。(如果你已有的 ESP 分区比这小,别担心,直接用就行。)在此分区上创建一个 FAT32 文件系统。如果你使用 Gparted 或者 parted 准备 ESP 分区,记得给它一个“启动标记”。如果你使用 GPT fdisk(gdisk,cgdisk 或 sgdisk)准备 ESP 分区,记得给它一个名为 EF00 的类别码。有些安装程序会创建一个较小的 ESP 分区,并且设置为 FAT16 文件系统。尽管这样能正常工作,但如果你之后需要重装 Windows,安装程序会无法识别 FAT16 文件系统的 ESP 分区,所以你需要将其备份后转为 FAT32 文件系统。
|
||||
|
||||
* **使用 ESP 分区** — 不同发行版的安装程序以不同的方式辨识 ESP 分区。比如,Debian 和 Ubuntu 的某些版本把 ESP 分区称为“EFI boot partition”,而且不会明确显示它的挂载点(尽管它会在后台挂载);但是有些发行版,像 Arch 或 Gentoo,需要你去手动挂载。尽管将 ESP 分区挂载到 /boot 进行相应配置后可以正常工作,特别是当你想使用 gummiboot 或 ELILO(译者注:gummiboot 和 ELILO 都是 EFI 引导工具)时,但是在 Linux 中最标准的 ESP 分区挂载点是 /boot/efi。某些发行版的 /boot 不能用 FAT 分区。因此,当你设置 ESP 分区挂载点时,请将其设置为 /boot/efi。除非 ESP 分区没有,否则_不要_为其新建文件系统 — 如果已经安装 Windows 或其他操作系统,它们的引导文件都在 ESP 分区里,新建文件系统会销毁这些文件。
|
||||
|
||||
* **设置引导程序的位置** — 某些发行版会询问将引导程序(GRUB)装到何处。如果 ESP 分区按上述内容被正确标记,不必理会此问题,但有些发行版仍会询问。请尝试使用 ESP 分区。
|
||||
|
||||
* **其他分区** — 除了 ESP 分区,不再需要其他的特殊分区;你可以设置 根(/)分区,swap 分区,/home 分区,或者其他你想在 BIOS 模式下安装时使用的分区。请注意 EFI 模式下_不需要设置_[BIOS 启动分区][39],所以如果安装程序提示你需要它,意味着你可能意外的进入了 BIOS 模式。另一方面,如果你创建了 BIOS 启动分区,会更灵活,因为你可以安装 BIOS 模式下的 GRUB,然后以任意模式(EFI模式 或 BIOS模式)引导。
|
||||
|
||||
* **解决无显示问题** — 2013 年,许多人在 EFI 模式下经常遇到(之后出现的频率逐渐降低)无显示的问题。有时可以在命令行下通过给内核添加 nomodeset 参数解决这一问题。在 GRUB 界面按 e 键会打开一个简易文本编辑器。大多数情况下你需要搜索有关此问题的更多信息,因为此问题更多是由特定硬件引起的。
|
||||
|
||||
在某些情况下,你可能不得不以 BIOS 模式安装 Linux。但你可以手动安装 EFI 引导程序让 Linux 以 EFI 模式启动。请参阅 [Managing EFI Boot Loaders for Linux][53] 页面获取更多有关它们以及如何安装的可用信息。
|
||||
|
||||
### 解决安装后的问题
|
||||
|
||||
如果 Linux 无法在 EFI 模式下工作,但在 BIOS 模式下成功了,那么你可以完全放弃 EFI 模式。在只有 Linux 的计算机上这非常简单;安装 BIOS 引导程序即可(如果你是在 BIOS 模式下安装的,引导程序也应随之装好)。如果是和 EFI 下的 Windows 组成双系统,最简单的方法是安装我的[rEFInd boot manager][54]。在 Windows 上安装它,然后编辑 refind.conf 文件:取消注释 scanfor 一行,并确保拥有 hdbios 选项。这样 rEFInd 在引导时会重定向到 BIOS 模式的引导项。
|
||||
|
||||
如果重启后计算机直接进入了 Windows,很可能是 Linux 的引导程序或管理器安装不正确。(但是应当首先尝试禁用 Secure Boot;之前提到过,它经常引发各种问题。)下面是关于此问题的几种可能的解决方案:
|
||||
|
||||
* **使用 efibootmgr** — 你可以以 _EFI 模式_引导一个 Linux 急救盘,使用 efibootmgr 实用工具尝试重写你的 Linux 引导程序,如[这里][40]所述。
|
||||
|
||||
* **使用 Windows 上的 bcdedit** — 在 Windows 管理员命令提示符窗口中,输入 bcdedit /set {bootmgr}path \EFI\fedora\grubx64.efi 会用 ESP 分区的 EFI/fedora/grubx64.efi 文件作为默认的引导。根据需要更改此路径,指向你想设置的引导文件。如果你启用了 Secure Boot,需要设置 shim.efi,shimx64.efi 或者 PreLoader.efi(不管有哪个)为引导而不是 grubx64.efi。
|
||||
|
||||
* **安装 rEFInd** — 有时候 rEFInd 可以解决这个问题。我推荐使用 [CD-R 或者 USB 闪存驱动器][41]进行测试。如果 Linux 可以启动,就安装 Debian 软件包,RPM 程序,或者 .zip 文件包。(请注意,你需要在一个高亮选项 Linux vmlinuz* 按两次 F2 或 Insert 修改启动项。如果你的启动分区是单独的,这就更有必要了,因为这种情况下,rEFInd 无法找到根(/)分区,也就无法传递参数给内核。)
|
||||
|
||||
* **修复引导** — Ubuntu 的[引导修复实用工具][42]可以自动修复一些问题;然而,我建议只在 Ubuntu 和 相关的发行版上使用,比如 Mint。有时候,有必要通过高级选项备份并替换 Windows 的引导。
|
||||
|
||||
* **劫持 Windows 引导程序** — 有些不完整的 EFI 引导只能引导 Windows,就是 ESP 分区上的 EFI/Microsoft/Boot/bootmgfw.efi 文件。因此,你可能需要将引导程序改名(我建议将其移动到上级目录 EFI/Microsoft/bootmgfw.efi),然后将首选引导程序复制到这里。(大多数发行版会在 EFI 的子目录放置 GRUB 的副本,例如 Ubuntu 的 EFI/ubuntu,Fedora 的 EFI/fedora。)请注意此方法是不光彩的破解行为,有用户反映 Windows 会替换引导程序,所以这个办法不是 100% 有效。然而,这是在不完整的 EFI 上生效的唯一办法。在尝试之前,我建议你升级固件并重新注册自己的引导程序,Linux 上用 efibootmgr,Windows 上用 bcdedit。
|
||||
|
||||
有关引导程序的其他类型的问题 - 如果 GRUB(或者你的发行版默认的其他引导程序或引导管理器)没有引导操作系统,你必须修复这个问题。因为 GRUB 2 引导 Windows 时非常挑剔,所以 Windows 经常启动失败。在某些情况下,Secure Boot 会加剧这个问题。请参阅[我的 GRUB 2 页面][55]获取一个引导 Windows 的 GRUB 2 示例。还会有很多原因导致 Linux 引导出现问题,类似于 BIOS 模式下的情况,所以我没有全部写出来。
|
||||
|
||||
尽管 GRUB 2 使用很普遍,但我对它的评价却不高 - 它很复杂,而且难以配置和使用。因此,如果你在使用 GRUB 的时候遇到了问题,我的第一反应就是用别的东西代替。[我的 EFI 引导程序页面][56]有其他的选择。其中包括我的 [rEFInd boot manager][57],它除了能够让许多发行版上的 GRUB 2 工作,也更容易安装和维护 - 但是它还不能完全代替 GRUB 2。
|
||||
|
||||
除此之外,EFI 引导的问题可能很奇怪,所以你需要去论坛发帖求助。尽量将问题描述完整。[Boot Info Script][58] 可帮助你提供有用的信息 - 运行此脚本,将生成的名为 RESULTS.txt 的文件粘贴到论坛的帖子上。一定要将文本粘贴到 [code] 和 [/code] 之间;不然会遭人埋怨。或者将 RESULTS.txt 文件上传到 pastebin 网站上,比如 [pastebin.com][59],然后将网站给你的 URL 地址发布到论坛。
|
||||
|
||||
### 哎呀:将传统模式下安装的引导转为 EFI 模式下的引导
|
||||
|
||||
**警告:**这些指南主要用于基于 UEFI 的 PC。如果你的 Mac 已经安装了 BIOS 模式下的 Linux,但想以 EFI 模式启动 Linux,可以_在 OS X_ 中安装引导程序。rEFInd(或者旧式的 rEFIt)是 Mac 上的常用选择,但 GRUB 可以做的更多。
|
||||
|
||||
论坛上有很多人看了错误的教程,在已经存在 EFI 模式的 Windows 的情况下,安装了 BIOS 引导的 Linux,这一问题在 2015 年初很普遍。这样配置效果很不好,因为大多数 EFI 很难在两种模式之间切换,而且 GRUB 也无法胜任这项工作。你可能会遇到不完整的 EFI 无法启动外部介质的情况,也可能遇到 EFI 模式下的显示问题,或者其他问题。
|
||||
|
||||
如前所述,在[解决安装后的问题][60]部分,解决办法之一就是_在 Windows_ 上安装 rEFInd,将其配置为支持 BIOS 模式引导。然后可以通过 rEFInd 和 chainload 引导 BIOS 模式下的 GRUB。在 Linux 上遇到 EFI 特定的问题时,例如无法使用显卡,我建议你使用这个办法修复。如果你没有这样的 EFI 特定的问题,在 Windows 中安装 rEFInd 和合适的 EFI 文件系统驱动可以让 Linux 直接以 EFI 模式启动。这个解决方案很完美,它和我下面描述的内容等同。
|
||||
|
||||
大多数情况下,最好将 Linux 配置为以 EFI 模式启动。有很多办法可以做到,但最好的是以 EFI 模式引导 Linux(或者,可以想到,Windows,或者一个 EFI shell)来注册首选引导管理器。实现这一目标的方法如下:
|
||||
|
||||
1. 下载适用于 USB 闪存驱动器或 CD-R 的 [rEFInd boot manager][43]。
|
||||
2. 从下载的镜像文件准备安装介质。可以在计算机上准备,不管是 EFI 还是 BIOS 的计算机都可以(或者在其他平台上使用其他方法)。
|
||||
3. 如果你还没有这样做,[请禁用 Secure Boot][44]。因为 rEFInd CD-R 和 USB 镜像不支持 Secure Boot,所以这很必要,你可以以后重新启用它。
|
||||
4. 在目标计算机上启动 rEFInd。如前所述,你可能需要调整固件设置,并使用内置引导管理器选择要引导的介质。你选择的那一项需要包含 _UEFI_ 这样描述的字符串。
|
||||
|
||||
5. 在 rEFInd 上测试引导项。你应该至少看到一个启动 Linux 内核的选项(名字含有 vmlinuz 这样的字符串)。有两种方法可以启动它:
|
||||
* 如果你_没有_独立的 /boot 分区,只需简单的在高亮选项上按回车键。Linux 就会启动。
|
||||
* 如果你_确定有_一个独立的 /boot 分区,按两次 Insert 或 F2 键。这样会打开一个编辑器,你可以用它来编辑内核选项。按 root= 格式添加这些选项以标识根(/)文件系统,如果根(/)分区在 /dev/sda5 上,就添加 root=/dev/sda5。如果不知道根文件系统是什么,那你需要重启并尽可能想到办法。在一些罕见的情况下,你可能需要添加其他内核选项来代替 root= 选项。比如配置了 LVM(译者注:Logical Volume Manager,逻辑卷管理)的 Gentoo 就需要 dolvm 选项。
|
||||
6. Linux 一旦启动,安装你想要的引导程序。rEFInd 的安装很简单,可以通过 RPM,Debian 软件包,PPA,或从[rEFInd 下载页面][45]下载的二进制 .zip 文件进行安装。在 Ubuntu 和相关的发行版上,Boot Repair 可以相对简单地修复你的 GRUB 设置,但它会有质的飞跃,从而正常工作。(它通常工作良好,但有时候会把事情搞得一团糟。)另外一些选项都在我的 [Managing EFI Boot Loader for Linux][46] 页面上。
|
||||
7. 如果你想在 Secure Boot 激活的情况下引导,只需重启并启用它。但是,请注意,可能需要额外的安装步骤才能将引导程序设置为使用 Secure Boot。有关详细信息,请参阅[我的主题页面][47]或引导程序有关 Secure Boot 的文档资料。
|
||||
|
||||
重启时,你可以看到刚才安装的引导程序。如果计算机进入了 BIOS 模式下的 GRUB,你应当进入固件禁用 BIOS/CSM/legacy 支持,或调整引导顺序。如果计算机直接进入了 Windows,那么你应当阅读前一部分,[解决安装后的问题][61]。
|
||||
|
||||
你可能想或需要调整你的配置。通常是为了看到额外的引导选项,或者隐藏某些选项。请参阅引导程序的文档资料,以了解如何进行这些更改。
|
||||
|
||||
### 参考和附加信息
|
||||
|
||||
|
||||
* **信息网页**
|
||||
* 我的 [Managing EFI Boot Loaders for Linux][2] 页面含有可用的 EFI 引导程序和引导管理器。
|
||||
* [OS X's bless tool 的手册页][3] 页面在设置 OS X 平台上的引导程序或引导管理器时可能会很有用。
|
||||
* [EFI 启动过程][4] 描述了 EFI 是启动时的大致框架。
|
||||
* [Arch Linux UEFI wiki page][5] 有大量关于 UEFI 和 Linux 的详细信息。
|
||||
* 亚当·威廉姆森写的 [什么是 EFI,它是怎么工作的][6]。
|
||||
* [这个页面][7] 描述了如何从 Windows 8 调整 EFI 的固件设置。describes how to adjust EFI firmware settings from within Windows 8.
|
||||
* 马修·J·加勒特是 Shim 引导程序的开发者,此程序支持 Secure Boot,他维护的[博客][8]经常更新有关 EFI 的问题。
|
||||
* 如果你对 EFI 软件的开发感兴趣,我的 [Programming for EFI][9] 页面可以为你起步助力。
|
||||
* **附加程序**
|
||||
* [rEFInd 官网][10]
|
||||
* [gummiboot 官网][11]
|
||||
* [ELILO 官网][12]
|
||||
* [GRUB 官网][13]
|
||||
* [GPT fdisk 分区软件官网][14]
|
||||
* Ubuntu 的 [Boot Repair 实用工具][15]可帮助解决一些引启动问题
|
||||
* **交流**
|
||||
* [Sourceforge 上的 rEFInd 交流论坛][16]是 rEFInd 用户互相交流或与我联系的一种方法。
|
||||
* Pastebin 网站,比如 [http://pastebin.com][17], 是在 Web 论坛上与其他用户交换大量文本的一种便捷的方法。
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.rodsbooks.com/linux-uefi/
|
||||
|
||||
作者:[Roderick W. Smith][a]
|
||||
译者:[fuowang](https://github.com/fuowang)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:rodsmith@rodsbooks.com
|
||||
[1]:http://www.rodsbooks.com/efi-bootloaders/secureboot.html#disable
|
||||
[2]:http://www.rodsbooks.com/efi-bootloaders/
|
||||
[3]:http://ss64.com/osx/bless.html
|
||||
[4]:http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/efi-boot-process.html
|
||||
[5]:https://wiki.archlinux.org/index.php/Unified_Extensible_Firmware_Interface
|
||||
[6]:https://www.happyassassin.net/2014/01/25/uefi-boot-how-does-that-actually-work-then/
|
||||
[7]:http://www.eightforums.com/tutorials/20256-uefi-firmware-settings-boot-inside-windows-8-a.html
|
||||
[8]:http://mjg59.dreamwidth.org/
|
||||
[9]:http://www.rodsbooks.com/efi-programming/
|
||||
[10]:http://www.rodsbooks.com/refind/
|
||||
[11]:http://freedesktop.org/wiki/Software/gummiboot
|
||||
[12]:http://elilo.sourceforge.net/
|
||||
[13]:http://www.gnu.org/software/grub/
|
||||
[14]:http://www.rodsbooks.com/gdisk/
|
||||
[15]:https://help.ubuntu.com/community/Boot-Repair
|
||||
[16]:https://sourceforge.net/p/refind/discussion/
|
||||
[17]:http://pastebin.com/
|
||||
[18]:http://www.rodsbooks.com/linux-uefi/#intro
|
||||
[19]:http://www.rodsbooks.com/linux-uefi/#isitefi
|
||||
[20]:http://www.rodsbooks.com/linux-uefi/#distributions
|
||||
[21]:http://www.rodsbooks.com/linux-uefi/#preparing
|
||||
[22]:http://www.rodsbooks.com/linux-uefi/#installing
|
||||
[23]:http://www.rodsbooks.com/linux-uefi/#troubleshooting
|
||||
[24]:http://www.rodsbooks.com/linux-uefi/#oops
|
||||
[25]:http://www.rodsbooks.com/linux-uefi/#references
|
||||
[26]:http://www.rodsbooks.com/linux-uefi/#using_firmware
|
||||
[27]:http://www.rodsbooks.com/efi-bootloaders/secureboot.html#disable
|
||||
[28]:http://www.rodsbooks.com/refind/getting.html
|
||||
[29]:https://en.wikipedia.org/wiki/Uefi
|
||||
[30]:https://en.wikipedia.org/wiki/BIOS
|
||||
[31]:http://www.rodsbooks.com/linux-uefi/#references
|
||||
[32]:http://www.eightforums.com/tutorials/20256-uefi-firmware-settings-boot-inside-windows-8-a.html
|
||||
[33]:http://www.eightforums.com/tutorials/6320-fast-startup-turn-off-windows-8-a.html
|
||||
[34]:http://www.rodsbooks.com/gdisk/
|
||||
[35]:http://en.wikipedia.org/wiki/EFI_System_partition
|
||||
[36]:http://www.rodsbooks.com/efi-bootloaders
|
||||
[37]:https://sourceforge.net/projects/windd/
|
||||
[38]:http://www.chrysocome.net/dd
|
||||
[39]:https://en.wikipedia.org/wiki/BIOS_Boot_partition
|
||||
[40]:http://www.rodsbooks.com/efi-bootloaders/installation.html
|
||||
[41]:http://www.rodsbooks.com/refind/getting.html
|
||||
[42]:https://help.ubuntu.com/community/Boot-Repair
|
||||
[43]:http://www.rodsbooks.com/refind/getting.html
|
||||
[44]:http://www.rodsbooks.com/efi-bootloaders/secureboot.html#disable
|
||||
[45]:http://www.rodsbooks.com/refind/getting.html
|
||||
[46]:http://www.rodsbooks.com/efi-bootloaders/
|
||||
[47]:http://www.rodsbooks.com/efi-bootloaders/secureboot.html
|
||||
[48]:mailto:rodsmith@rodsbooks.com
|
||||
[49]:http://ss64.com/osx/bless.html
|
||||
[50]:http://www.rodsbooks.com/refind/getting.html
|
||||
[51]:http://www.rodsbooks.com/linux-uefi/#oops
|
||||
[52]:http://www.rodsbooks.com/linux-uefi/#oops
|
||||
[53]:http://www.rodsbooks.com/efi-bootloaders/
|
||||
[54]:http://www.rodsbooks.com/refind/
|
||||
[55]:http://www.rodsbooks.com/efi-bootloaders/grub2.html
|
||||
[56]:http://www.rodsbooks.com/efi-bootloaders
|
||||
[57]:http://www.rodsbooks.com/refind/
|
||||
[58]:http://sourceforge.net/projects/bootinfoscript/
|
||||
[59]:http://pastebin.com/
|
||||
[60]:http://www.rodsbooks.com/linux-uefi/#troubleshooting
|
||||
[61]:http://www.rodsbooks.com/linux-uefi/#troubleshooting
|
@ -1,208 +0,0 @@
|
||||
|
||||
在树莓派上通过Apache Spark on YARN搭建Hadoop集群
|
||||
===
|
||||
有些时候我们想从DQYDJ网站的数据中分析点有用的东西出来,在过去,我们要用R语言提取固定宽度的数据,然后通过数学建模分析美国的最低收入补贴,当然也包括其他优秀的方法。
|
||||
|
||||
今天我将向你展示对大数据的一点探索,不过有点变化,使用的是全世界最流行的微型电脑————树莓派,如果手头没有,那就看下一篇吧(可能是已经处理好的数据)对于其他用户,请继续阅读吧,今天我们要建立一个树莓派 Hadoop集群!
|
||||
|
||||
|
||||
为什么要建立一个Raspberry Pi的Hadoop集群?
|
||||
|
||||
![](https://dqydj.com/wp-content/uploads/2016/08/IMG_9132-245x300.png)
|
||||
>由三个树莓派节点组成的Hadoop集群
|
||||
|
||||
对DQYDJ这句谚语我们做了大量的数据处理工作,但这些还不能称得上是大数据。
|
||||
|
||||
和许许多多有争议的话题一样,数据的大小之别被解释成这样一个笑话:
|
||||
|
||||
如果能被RAM所存储,那么它就不是大数据。 ————佚名
|
||||
|
||||
似乎这儿有两种解决问题的方法:
|
||||
|
||||
1.我们可以找到一个足够大的数据集合,任何家用电脑的内存都存不下。
|
||||
2.我们可以
|
||||
|
||||
上手树莓派2B
|
||||
|
||||
这个由设计师和工程师制作出来的精致小玩意儿拥有1GB的RAM,扩展SD卡充当它的硬盘,此外,每一台的价格都低于50刀,这意味着你可以花不到250刀的价格搭建一个集群。
|
||||
|
||||
或许天下没有比这更便宜的入场券来带你进入大数据的大门。
|
||||
|
||||
### 制作一个树莓派集群
|
||||
|
||||
我最喜欢制作的原材料。
|
||||
|
||||
这里我将给出我原来为了制作树莓派集群购买原材料的链接,如果以后要在亚马逊购买的话你可先这些链接收藏起来,也是对本站的一点支持。(谢谢)
|
||||
|
||||
- 树莓派2B x3
|
||||
- 集群原理图
|
||||
- 4层亚克力支架
|
||||
- 6口USB转接器
|
||||
- 内存卡
|
||||
- MicroUSB数据线
|
||||
- 短网线
|
||||
- 双面胶
|
||||
|
||||
开始制作
|
||||
|
||||
1.首先,装好三个树莓派,每一个用螺丝钉固定在亚克力面板上。(看下图)
|
||||
2.接下来,安装以太网交换机,用双面胶贴在其中一个在亚克力面板上。
|
||||
3.用双面胶贴将USB转接器贴在一个在亚克力面板使之成为最顶层。
|
||||
4.接着就是一层一层都拼好——这里我选择将树莓派放在交换机和USB转接器的底下(可以看看完整安装好的两张截图)
|
||||
|
||||
如果你需要电线的话我想出了一个好方法-如果你和我一样购买力USB线和网线,我可以将它们卷起来放在亚克力板子的每一层
|
||||
|
||||
现在不要急着上电,需要将系统烧录到SD卡上才能继续。
|
||||
|
||||
烧录
|
||||
|
||||
按照这个教程将Raspbian烧录到三张SD卡上,我使用的是Win7下的[Win32DiskImager][2]。
|
||||
|
||||
将其中一张烧录好的SD卡插在你想作为主节点的树莓派上,连接USB线并启动它。
|
||||
|
||||
启动主节点
|
||||
|
||||
这里有一篇非常棒的教程,讲如何安装Hadoop 2.7.1,此处就不再熬述。
|
||||
|
||||
在启动过程中有一些要注意的地方,我将和你一起设置直到最后一步,记住我现在使用的IP段为192.168.1.50 – 192.168.1.52,主节点是.50,从节点是.51和.52,你的网络可能会有所不同,如果你想设置静态IP的话可以在评论区看看或讨论。
|
||||
|
||||
一旦你完成了这些步骤,接下来要做的就是启用交换文件,Spark on YARN将分割出一块很接近内存空间的交换文件,当你内存快用完时便会使用这个交换分区。
|
||||
|
||||
(如果你以前没有做过有关交换分区的操作的话,可以看看这篇教程,记住交换分区不要太多,因为内存卡的性能扛不住)
|
||||
|
||||
现在我准备介绍有关我和其他Geek关于启动设置一些微妙的区别
|
||||
|
||||
对于初学者,确保你给你的树莓派起了一个名字——在/etc/hostname设置,我的主节点设置为‘RaspberryPiHadoopMaster’ ,从节点设置为 ‘RaspberryPiHadoopSlave#’
|
||||
|
||||
主节点的/etc/hosts配置如下:
|
||||
|
||||
如果你想让 Hadoop, YARN, and Spark运行正常的话,你也需要修改这些配置文件。
|
||||
|
||||
hdfs-site.xml:
|
||||
|
||||
```
|
||||
yarn-site.xml (Note the changes in memory!):
|
||||
|
||||
slaves:
|
||||
|
||||
core-site.xml:
|
||||
```
|
||||
|
||||
设置从节点:
|
||||
|
||||
接下来按照Because We Can Geek上的教程,你需要对上面的文件作出小小的改动。主节点没有改变其中的yarn-site.xml,所以从节点中不必含有这个文件。
|
||||
|
||||
III.在我们的树莓派集群中测试YARN!
|
||||
|
||||
如果所有设备都正常工作,在主节点上你应该执行如下命令:
|
||||
|
||||
> start-dfs.sh
|
||||
|
||||
> start-yarn.sh
|
||||
|
||||
当设备启动后,遵循教程以Hadoop用户方式执行。
|
||||
|
||||
接下来执行`hdfs dfsadmin -report`查看三个节点是否都正确启动,确认你看到一行粗体文字‘Live datanodes (3)’:
|
||||
|
||||
Configured Capacity: 93855559680 (87.41 GB)
|
||||
Raspberry Pi Hadoop Cluster picture Straight On
|
||||
Present Capacity: 65321992192 (60.84 GB)
|
||||
DFS Remaining: 62206627840 (57.93 GB)
|
||||
DFS Used: 3115364352 (2.90 GB)
|
||||
DFS Used%: 4.77%
|
||||
Under replicated blocks: 0
|
||||
Blocks with corrupt replicas: 0
|
||||
Missing blocks: 0
|
||||
Missing blocks (with replication factor 1): 0
|
||||
————————————————-
|
||||
Live datanodes (3):
|
||||
Name: 192.168.1.51:50010 (RaspberryPiHadoopSlave1)
|
||||
Hostname: RaspberryPiHadoopSlave1
|
||||
Decommission Status : Normal
|
||||
|
||||
你现在可以做一些简单的诸如‘Hello, World!’的测试,或者直接进行下一步。
|
||||
|
||||
IV.安装SPARK ON YARN
|
||||
|
||||
YARN是另一种非常好用的资源调度器,已经集成在Hadoop安装包中。
|
||||
|
||||
Apache Spark 是 Hadoop 生态圈中的一款软件包,它是一个可执行的引擎。就像著名的预装软件MapReduce一样。在一般情况下,Spark得益于存储在基于磁盘的MapReduce。运行负载堪比10-100倍的MapReduce-安装完成后你可以试试Spark 和 MapReduce的有什么不同。
|
||||
|
||||
我个人对Spark还是留下非常深刻的印象,因为它提供了两种数据工程师和科学家都比较擅长的语言– Python 和 R。
|
||||
|
||||
安装Apache Spark非常简单,在你家目录下,wget这个地址,然后‘tar -xzf ’,最后把解压出来的文件移动至 /opt 并清除刚才下载的文件,以上这些就是安装步骤。
|
||||
|
||||
我又创建了只有两行的文件spark-env.sh,其中包含Spark的配置文件目录。
|
||||
|
||||
SPARK_MASTER_IP=192.168.1.50
|
||||
|
||||
SPARK_WORKER_MEMORY=512m
|
||||
|
||||
(在YARN跑起来之前我不确定这些是否有必要。)
|
||||
|
||||
V. 你好,世界! 为Apache Spark发现一个有趣的数据集!
|
||||
|
||||
在Hadoop进行对‘Hello, World!’的单词计数。
|
||||
|
||||
我决定改进一下`hello world`的例子,这个例子在平常也用不上,也许统计一些关于我自己的大数据会更有用…
|
||||
|
||||
如果你有一个正在运行的`WordPress`博客,可以通过简单的两步来导出和
|
||||
|
||||
我使用`Export to Text‘导出文章的内容到纯文本文件中,我使用一些压缩库编写了一个`Python`来压缩了`HTML文件`,现在你可以将一个更小的文件复制到pi搭建的HDFS集群。
|
||||
|
||||
如果你没有进行上面的操作,还有一种方法将文件转移到pi上
|
||||
|
||||
>hdfs dfs -copyFromLocal dqydj_stripped.txt /dqydj_stripped.txt
|
||||
|
||||
现在准备进行最后一步 - 向Apache Spark写入相同的代码。
|
||||
|
||||
### VI: 点燃 Apache Spark
|
||||
|
||||
我们的单词计数程序基于Cloudera进行修改,你可以在这里找到。我们要修改我们的自己的单词计数程序。
|
||||
|
||||
在主节点上安装‘stop-words’这个`python`第三方包,有趣的是我在DQYDJ上使用了23,295次the这个单词,你可能不想看到这些语法单词占据着单词计数的前列,另外,用下列代码替换所有有关dqydj的参考文件,注意你自己的数据库路径。
|
||||
|
||||
保存好wordCount.py确保上面的路径都是正确无误的。
|
||||
|
||||
现在,通过运行在YARN上的Spark,你可以看到我在DQYDJ使用最多的单词是哪一个。
|
||||
|
||||
>/opt/spark-2.0.0-bin-hadoop2.7/bin/spark-submit –master yarn –executor-memory 512m –name wordcount –executor-cores 8 wordCount.py /dqydj_stripped.txt
|
||||
|
||||
### 我在DQYDJ使用最多的单词
|
||||
|
||||
可能入列的单词有哪一些呢?can, will, it’s, one, even, like, people, money, don’t, also“.
|
||||
|
||||
嘿,不差钱–悄悄进入前十。在一个致力于金融、投资和经济的网站上谈论这似乎是件好事,对吧?
|
||||
|
||||
这是余下的50个最常用的词汇,请用他们得出有关我余下文章的结论。
|
||||
|
||||
![](https://dqydj.com/wp-content/uploads/2016/08/dqydj_pk_most_used_words.png)
|
||||
|
||||
我希望你能喜欢这篇关于Hadoop, YARN, 和 Apache Spark的教程,现在你可以在Spark运行其他的任务。
|
||||
|
||||
你的下一步是任务是开始读pyspark文档(库或其他语言)去学习一些可用的功能。根据你的兴趣和你实际存储的数据,你将会深入学习到有流数据包的SQL,甚至机器学习!
|
||||
|
||||
你要建立一个树莓派集群吗?看看你使用最频繁的单词是什么?
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
原文: https://dqydj.com/raspberry-pi-hadoop-cluster-apache-spark-yarn/?utm_source=dbweekly&utm_medium=email
|
||||
|
||||
作者:[PK][a]
|
||||
译者:[popy32](https://github.com/sfantree)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 组织编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://dqydj.com/about/#contact_us
|
||||
[1]: https://www.raspberrypi.org/downloads/raspbian/
|
||||
[2]: https://sourceforge.net/projects/win32diskimager/
|
||||
[3]: http://www.becausewecangeek.com/building-a-raspberry-pi-hadoop-cluster-part-1/
|
||||
[4]: https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04
|
||||
[5]: http://www.becausewecangeek.com/building-a-raspberry-pi-hadoop-cluster-part-2/
|
||||
[6]: https://spark.apache.org/
|
||||
[7]: https://hadoop.apache.org/docs/r1.2.1/mapred_tutorial.html
|
||||
[8]: https://spark.apache.org/downloads.html
|
||||
[9]: https://wordpress.org/support/plugin/export-to-text
|
||||
[10]: https://pypi.python.org/pypi/bleach
|
||||
|
@ -1,167 +0,0 @@
|
||||
|
||||
###[Linux容器能否弥补IoT的安全短板?][28]
|
||||
|
||||
![](http://hackerboards.com/files/internet_of_things_wikimedia1-thm.jpg)
|
||||
在这个最后的物联网系列文章中,Canonical和Resin.io向以Linux容器技术作为物联网安全性和互操作性的解决方案发起挑战。
|
||||
|
||||
![](http://hackerboards.com/files/samsung_artik710-thm.jpg)
|
||||
|
||||
**Artik 7** |
|
||||
|
||||
尽管受到日益增长的安全威胁,物联网炒作没有显示减弱的迹象。为了刷存在感,公司正忙于重新安排物联网的路线图。物联网大潮迅猛异常,比移动互联网革命渗透地更加深入和广泛。IoT像黑洞一样,吞噬一切,包括智能手机,它通常是我们在物联网世界中的窗口,有时作为我们的集线器或传感器端点。
|
||||
|
||||
新的物联网处理器和嵌入式主板继续重塑技术版图。自从9月份推出[Linux和开源硬件IoT] [5]系列文章之后,我们看到了面向物联网网关的“Apollo Lake]”SoC [Intel Atom E3900] [6]以及[新三星Artik模块][7],包括用于网关并由Linux驱动的64位Artik 7 COM及自带RTOS的Cortex-M4 Artik。 ARM为具有ARMv8-M和TrustZone安全性的IoT终端发布了[Cortex-M23和Cortex-M33] [8]内核。
|
||||
|
||||
安全是这些产品的卖点。最近攻击Dyn服务并在一天内摧毁了美国大部分互联网的未来僵尸网络将基于Linux的物联网推到台前 - 当然这种方式似乎不太体面。通过DDoS攻击可以黑掉物联网设备,其设备所有者同样可能直接遭受恶意攻击。
|
||||
|
||||
![](http://hackerboards.com/files/arm_cortexm33m23-thm.jpg)
|
||||
|
||||
**Cortex-M33 和 -M23**
|
||||
|
||||
Dyn攻击让我们更加笃定,物联网将更加自信地在受控制和受保护的工业环境而不是家用环境中向前发展。这不是因为消费者[物联网安全技术] [9]不可用,但除非产品设计之初就以安全为目标,否则如我们的[智能家居集线器系列] [10]中的许多解决方案,后期再考虑安全就会增加成本和复杂性。
|
||||
|
||||
在物联网系列的最后一个未来展望的部分,我们将探讨两种基于Linux的面向Docker的容器技术,这些技术被提出作为物联网安全解决方案。容器还可以帮助解决在[物联网框架] [11]中探讨的开发复杂性和互操作性障碍的问题。
|
||||
|
||||
我们与Canonical的Ubuntu客户平台工程副总裁Oliver Ries讨论了Ubuntu Core和Docker友好的容器式Snaps包管理技术。我们还就新的基于Docker的物联网方案ResinO采访了Resin.io首席执行官和联合创始人Alexandros Marinos。
|
||||
|
||||
**Ubuntu Core 与快照管理**
|
||||
|
||||
Canonical面向物联网的[Snappy Ubuntu Core] [12]版本的Ubuntu是围绕一个类似容器的快照包管理机制构建,并提供应用商店支持。 snap技术最近[自行发布] [13]用于其他Linux发行版。 11月3日,Canonical发布了[Ubuntu Core 16] [14],该版本改进了白标应用商店和更新控制服务。
|
||||
|
||||
<center>
|
||||
[
|
||||
![](http://hackerboards.com/files/canonical_ubuntucore16_diagram-sm.jpg)
|
||||
][15]
|
||||
**传统Ubuntu(左)架构 与 Ubuntu Core 16**
|
||||
(点击图片放大)
|
||||
</center>
|
||||
|
||||
快照机制提供自动更新,并有助于阻止未经授权的更新。 使用事务系统管理,快照可确保更新按预期部署或根本不部署。 在Ubuntu Core中,使用AppArmor进一步加强了安全性,并且所有应用程序文件都只读且保存在隔离的孤岛中。
|
||||
![](http://hackerboards.com/files/limesdr-thm.jpg)
|
||||
|
||||
**LimeSDR** |
|
||||
|
||||
Ubuntu Core是我们最近展开的[开源物联网操作系统调查] [16]的一部分,现在运行在Gumstix主板,Erle机器人无人机,Dell Edge网关,[Nextcloud Box] [17],LimeSDR,Mycroft家庭集线器 ,英特尔的Joule和符合Linaro的96Boards规范的SBC上。 Canonical公司还与Linaro物联网和嵌入式(LITE)部门集团[96Boards物联网版] [18]合作。最初,96Boards IE专注于Zephyr驱动的Cortex-M4板卡,如Seeed的[BLE Carbon] [19] 它将扩展到可以运行Ubuntu Core的网关板卡。
|
||||
|
||||
“Ubuntu Core和快照具有从边缘到网关到云的相关性,”Canonical的Ries说。 “能够在任何主要发行版(包括Ubuntu Server和Ubuntu for Cloud)上运行快照包,使我们能够提供一致的体验。 Snaps可以使用事务更新以故障安全方式升级,可用于安全性,错误修复或新功能的持续更新,这在物联网环境中非常重要。
|
||||
|
||||
![](http://hackerboards.com/files/nextcloud_box3-thm.jpg)
|
||||
|
||||
**Nextcloud盒子** |
|
||||
|
||||
安全性和可靠性是关注的重点,Ries说。 “Snaps可以完全独立于彼此和操作系统运行,使得两个应用程序可以安全地在单个网关上运行,”他说。 “Snaps是只读的和经过认证的,可以保证代码的完整性。
|
||||
|
||||
Ries还采用了减少开发时间的技术。 “Snap软件包允许开发人员向支持它的任何平台提供相同的二进制包,从而降低开发和测试成本,减少部署时间和提高更新速度。 “使用snap包,开发人员完全控制开发生命周期,并可以立即更新。 Snap包提供所有必需的依赖项,因此开发人员可以选择定制他们使用的组件。
|
||||
|
||||
**ResinOS: 为IoT而生的Docker**
|
||||
|
||||
Resin.io公司,与其商用IoT框架同名,最近剥离了该框架的Yocto Linux [ResinOS 2.0] [20],ResinOS 2.0将作为一个独立的开源项目运营。 Ubuntu Core在snap包中运行Docker容器引擎,ResinOS在主机上运行Docker。 极致简约的ResinOS抽离了使用Yocto代码的复杂性,使开发人员能够快速部署Docker容器。
|
||||
|
||||
<center>
|
||||
[
|
||||
![](http://hackerboards.com/files/resinio_resinos_arch-sm.jpg)
|
||||
][21]
|
||||
**ResinOS 2.0 架构**
|
||||
(点击图片放大)
|
||||
</center>
|
||||
|
||||
与基于Linux的CoreOS一样,ResinOS集成了系统控制服务和网络协议栈,可通过异构网络安全地部署更新的应用程序。 但是,它为在资源受限的设备(如ARM黑客板)上运行而设计,与之相反,CoreOS和其他基于Docker的操作系统(例如基于Red Hat的Project Atomic)目前仅能运行在x86上,并且更喜欢资源丰富的服务器平台。 ResinOS可以在20个Linux设备上运行,包括Raspberry Pi,BeagleBone和Odroid-C1等。
|
||||
|
||||
“我们认为Linux容器对嵌入式系统比对于云更重要,”Resin.io的Marinos说。 “在云中,容器代表了对之前进程的优化,但在嵌入式中,它们代表了姗姗来迟的通用虚拟化“
|
||||
|
||||
![](http://hackerboards.com/files/beaglebone-hand-thm.jpg)
|
||||
|
||||
**BeagleBone Black** |
|
||||
|
||||
当应用于物联网时,完整的企业虚拟机有直接硬件访问的性能问题和限制,Marinos说。像OSGi和Android的Dalvik这样的移动虚拟机可以用于IoT,但是它们依赖Java并有其他限制。
|
||||
|
||||
对于企业开发人员来说,使用Docker似乎很自然,但是你如何说服嵌入式黑客转向全新的范式呢? “Marinos解释说,”ResinOS不是把云技术的实践经验照单全收,而是针对嵌入式进行了优化。”此外,他说,容器比典型的物联网技术更好地包容故障。 “如果有软件缺陷,主机操作系统可以继续正常工作,甚至保持连接。要恢复,您可以重新启动容器或推送更新。更新设备而不重新启动它的能力进一步消除了故障引发问题的机率。”
|
||||
|
||||
根据Marinos,其他好处源自与云技术的一致性,例如拥有更广泛的开发人员。容器提供了“跨数据中心和边缘的统一范式,以及一种方便地将技术,工作流,基础设施,甚至应用程序转移到边缘(终端)的方式。
|
||||
|
||||
Marinos说,容器中的固有安全性优势正在被其他技术增强。 “随着Docker社区推动实现签名的图像和证据,这些自然转移并应用到ResinOS,”他说。 “当Linux内核被强化以提高容器安全性时,或者获得更好地管理容器所消耗的资源的能力时,会产生类似的好处。
|
||||
|
||||
容器也适合开源IoT框架,Marinos说。 “Linux容器很容易与几乎各种协议,应用程序,语言和库结合使用,”Marinos说。 “Resin.io参加了AllSeen联盟,我们与使用IoTivity和Thread的伙伴合作。
|
||||
|
||||
**IoT的未来:智能网关与智能终端**
|
||||
|
||||
Marinos和Canonical的Ries对未来物联网的几个发展趋势具有一致的看法。 首先,物联网的最初概念(其中基于MCU的端点直接与云进行通信以进行处理)正在迅速被雾化计算架构取代。 这需要更智能的网关,也需要比仅仅在ZigBee和WiFi之间聚合和转换数据更多的功能。
|
||||
|
||||
第二,网关和智能边缘设备越来越多地运行多个应用程序。 第三,许多这些设备将提供板载分析,这些在最新的[智能家居集线器] [22]上都有体现。 最后,富媒体将很快成为物联网组合的一部分。
|
||||
|
||||
<center>
|
||||
[
|
||||
![](http://hackerboards.com/files/eurotech_reliagate2026-sm.jpg)
|
||||
][23] [
|
||||
![](http://hackerboards.com/files/advantech_ubc221-sm.jpg)
|
||||
][24]
|
||||
**最新设备网关: Eurotech’s [ReliaGate 20-26][1] 和 Advantech’s [UBC-221][2]**
|
||||
(点击图片放大)
|
||||
</center>
|
||||
|
||||
“智能网关正在接管最初为云服务设计的许多处理和控制功能,”Marinos说。 “因此,我们看到对容器化的推动力在增加,可以在IoT设备中使用类似云工作流程来部署与功能和安全相关的优化。 去中心化是由移动数据紧缩,不断发展的法律框架和各种物理限制等因素驱动的。
|
||||
|
||||
Ubuntu Core等平台正在使“可用于网关的软件爆炸式增长”,Canonical的Ries说。 “在单个设备上运行多个应用程序的能力吸引了众多单一功能设备的用户,以及现在可以产生持续的软件收入的设备所有者。
|
||||
|
||||
<center>
|
||||
[
|
||||
![](http://hackerboards.com/files/myomega_mynxg-sm.jpg)
|
||||
][25] [
|
||||
![](http://hackerboards.com/files/technexion_ls1021aiot_front-sm.jpg)
|
||||
][26]
|
||||
**两种IoT网关: [MyOmega MYNXG IC2 Controller (左) 和TechNexion’s ][3][LS1021A-IoT Gateway][4]**
|
||||
(点击图片放大)
|
||||
</center>
|
||||
|
||||
不仅是网关 - 终端也变得更聪明。 “阅读大量的物联网新闻报道,你得到的印象是所有终端都运行在微控制器上,”Marinos说。 “但是我们对大量的Linux终端,如数字标牌,无人机和工业机械等直接执行任务,而不是作为操作中介(数据转发)感到惊讶。我们称之为影子IoT。
|
||||
|
||||
Canonical的Ries同意,对简约技术的专注使他们忽视了新兴物联网领域。 “轻量化的概念在一个发展速度与物联网一样快的行业中初现端倪,”Ries说。 “今天的高级消费硬件可以持续为终端供电数月。“
|
||||
|
||||
虽然大多数物联网设备将保持轻量和“无头”(一种配置方式,比如物联网设备缺少显示器,键盘等),它们装备有传感器如加速度计和温度传感器并通过低速率的数据流通信,但是许多较新的物联网应用已经使用富媒体。 “媒体输入/输出只是另一种类型的外设,”Marinos说。 “总是存在多个容器竞争有限资源的问题,但它与传感器或蓝牙竞争天线资源没有太大区别。”
|
||||
|
||||
Ries看到了工业和家庭网关中“提高边缘智能”的趋势。 “我们看到人工智能,机器学习,计算机视觉和上下文意识的大幅上升,”Ries说。 “为什么要在云中运行面部检测软件,如果相同的软件可以在边缘设备运行而又没有网络延迟和带宽及计算成本?“
|
||||
|
||||
当我们在这个物联网系列的[开篇故事] [27]中探索时,我们发现存在与安全相关的物联网问题,例如隐私丧失和生活在监视文化中的权衡。还有一些问题如把个人决策交给可能由他人操控的AI裁定。这些不会被容器,快照或任何其他技术完全解决。
|
||||
|
||||
Perhaps we’d be happier if Alexa handled the details of our lives while we sweat the big stuff, and maybe there’s a way to balance privacy and utility. For now, we’re still exploring, and that’s all for the good.
|
||||
如果Alexa可以处理生活琐碎,而我们专注在要事上,也许我们会更快乐。或许有一个方法来平衡隐私和效用,现在,我们仍在探索,如此甚好。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://hackerboards.com/can-linux-containers-save-iot-from-a-security-meltdown/
|
||||
|
||||
作者:[Eric Brown][a]
|
||||
译者:[firstadream](https://github.com/firstadream)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://hackerboards.com/can-linux-containers-save-iot-from-a-security-meltdown/
|
||||
[1]:http://hackerboards.com/atom-based-gateway-taps-new-open-source-iot-cloud-platform/
|
||||
[2]:http://hackerboards.com/compact-iot-gateway-runs-yocto-linux-on-quark/
|
||||
[3]:http://hackerboards.com/wireless-crazed-customizable-iot-gateway-uses-arm-or-x86-coms/
|
||||
[4]:http://hackerboards.com/iot-gateway-runs-linux-on-qoriq-accepts-arduino-shields/
|
||||
[5]:http://hackerboards.com/linux-and-open-source-hardware-for-building-iot-devices/
|
||||
[6]:http://hackerboards.com/intel-launches-14nm-atom-e3900-and-spins-an-automotive-version/
|
||||
[7]:http://hackerboards.com/samsung-adds-first-64-bit-and-cortex-m4-based-artik-modules/
|
||||
[8]:http://hackerboards.com/new-cortex-m-chips-add-armv8-and-trustzone/
|
||||
[9]:http://hackerboards.com/exploring-security-challenges-in-linux-based-iot-devices/
|
||||
[10]:http://hackerboards.com/linux-based-smart-home-hubs-advance-into-ai/
|
||||
[11]:http://hackerboards.com/open-source-projects-for-the-internet-of-things-from-a-to-z/
|
||||
[12]:http://hackerboards.com/lightweight-snappy-ubuntu-core-os-targets-iot/
|
||||
[13]:http://hackerboards.com/canonical-pushes-snap-as-a-universal-linux-package-format/
|
||||
[14]:http://hackerboards.com/ubuntu-core-16-gets-smaller-goes-all-snaps/
|
||||
[15]:http://hackerboards.com/files/canonical_ubuntucore16_diagram.jpg
|
||||
[16]:http://hackerboards.com/open-source-oses-for-the-internet-of-things/
|
||||
[17]:http://hackerboards.com/private-cloud-server-and-iot-gateway-runs-ubuntu-snappy-on-rpi/
|
||||
[18]:http://hackerboards.com/linaro-beams-lite-at-internet-of-things-devices/
|
||||
[19]:http://hackerboards.com/96boards-goes-cortex-m4-with-iot-edition-and-carbon-sbc/
|
||||
[20]:http://hackerboards.com/can-linux-containers-save-iot-from-a-security-meltdown/%3Ca%20href=
|
||||
[21]:http://hackerboards.com/files/resinio_resinos_arch.jpg
|
||||
[22]:http://hackerboards.com/linux-based-smart-home-hubs-advance-into-ai/
|
||||
[23]:http://hackerboards.com/files/eurotech_reliagate2026.jpg
|
||||
[24]:http://hackerboards.com/files/advantech_ubc221.jpg
|
||||
[25]:http://hackerboards.com/files/myomega_mynxg.jpg
|
||||
[26]:http://hackerboards.com/files/technexion_ls1021aiot_front.jpg
|
||||
[27]:http://hackerboards.com/an-open-source-perspective-on-the-internet-of-things-part-1/
|
||||
[28]:http://hackerboards.com/can-linux-containers-save-iot-from-a-security-meltdown/
|
@ -1,146 +0,0 @@
|
||||
分区备份
|
||||
============
|
||||
|
||||
通常你可能会把数据放在一个分区上,尤其是通用串行总线(USB)设备。有时候可能需要对该设备或者上面的一个分区进行备份。树莓派用户为了可引导 SD 卡当然有这个需求。其它小型机的用户也会发现这非常有用。有时候设备看起来要出现故障时最好快速做个备份。
|
||||
|
||||
进行本文中的实验你需要一个叫 ‘dcfldd’ 的工具。
|
||||
|
||||
**dcfldd 工具**
|
||||
|
||||
该工具是 'coreutils' 软件包中 ‘dd’ 工具的增强版。‘dcfldd’ 是 Nicholas Harbour 在国防部计算机取证实验室(DCFL)工作期间研发的。该工具的名字也基于他工作的地方 - ‘dcfldd’。
|
||||
|
||||
对于仍然在使用 CoreUtils 8.23 或更低版本的系统,无法轻松查看正在创建副本的进度。有时候看起来就像什么都没有发生然后你就想取消掉备份。
|
||||
|
||||
**注意:**如果你使用 8.24 或更新版本的 ‘dd’ 工具,你就不需要使用 ‘dcfldd’,只需要用 ‘dd’ 替换 ‘dcfldd’ 即可。所有其它参数仍然适用。
|
||||
|
||||
在 Debian 系统上你只需要在 Package Manager 中搜索 ‘dcfldd’。你也可以打开一个终端然后输入下面的命令:
|
||||
|
||||
_sudo apt-get install dcfldd_
|
||||
|
||||
对于 Red Hat 系统,可以用下面的命令:
|
||||
|
||||
_cd /tmp
|
||||
wget dl.fedoraproject.org/pub/epel/6/i386/dcfldd-1.3.4.1-4.el6.i686.rpm
|
||||
sudo yum install dcfldd-1.3.4.1-4.el6.i686.rpm
|
||||
dcfldd --version_
|
||||
|
||||
**注意:** 上面的命令安装的是 32 位版本。对于 64 位版本,使用下面的命令:
|
||||
|
||||
_cd /tmp
|
||||
wget dl.fedoraproject.org/pub/epel/6/x86_64/dcfldd-1.3.4.1-4.el6.x86_64.rpm
|
||||
sudo yum install dcfldd-1.3.4.1-4.el6.x86_64.rpm
|
||||
dcfldd --version_
|
||||
|
||||
每组命令中的最后一个语句会列出 ‘dcfldd’ 的版本并显示该命令文件已经被加载。
|
||||
|
||||
**注意:**确保你以 root 用户执行 ‘dd’ 或者 ‘dcfldd’ 命令。
|
||||
|
||||
安装完该工具后你就可以继续使用它备份和恢复分区。
|
||||
|
||||
**备份分区**
|
||||
|
||||
备份设备的时候可以备份整个设备也可以只是其中的一个分区。如果设备有多个分区,我们可以分别备份每个分区。
|
||||
|
||||
在进行备份之前,先让我们来看一下设备和分区的区别。假设我们有一个已经被格式化为一大块设备 SD 卡。SD 卡只有一个分区。如果空间被切分使得 SD 卡看起来是两个设备,那么它就有两个分区。如果用类似 GParted 的程序打开 SD 卡,如图 1 所示,你可以看到它有两个分区。
|
||||
|
||||
**图 1**
|
||||
|
||||
设备 /dev/sdc 有 /dev/sdc1 和 /dev/sdc2 两个分区。
|
||||
|
||||
假设我们有一个树莓派中的 SD 卡。SD 卡容量为 8 GB,有两个分区(如图 1 所示)。第一个分区存放 BerryBoot 启动引导器。第二个分区存放 Kali(译者注:Kali Linux 是一个 Debian 派生的 Linux 发行版)。现在已经没有可用的空间用来安装第二个操作系统。我们使用大小为 16 GB 的第二个 SD 卡,但拷贝到第二个 SD 卡之前第一个 SD 卡必须先备份。
|
||||
|
||||
要备份第一个 SD 卡我们需要备份设备 /dev/sdc。进行备份的命令如下所示:
|
||||
|
||||
_dcfldd if=/dev/sdc of=/tmp/SD-Card-Backup.img_
|
||||
|
||||
备份包括输入文件(if)以及被设置为 '/tmp' 目录下名为 'SD-Card-Backup.img' 的输出文件(of)。
|
||||
|
||||
‘dd’ 和 ‘dcfldd’ 都是每次读写文件中的一个字节。通过上述命令,它一次读写的默认值为 512 个字节。记住,该复制是一个精准的拷贝 - 逐位逐字节。
|
||||
|
||||
默认的 512 个字节可以通过块大小参数 - ‘bs=’ 更改。例如,要每次读写 1 兆字节,参数为 ‘bs=1M’。以下所用的缩写有一些差异:
|
||||
|
||||
* b – 512 字节
|
||||
* KB – 1000 字节
|
||||
* K – 1024 字节
|
||||
* MB – 1000x1000 字节
|
||||
* M – 1024x1024 字节
|
||||
* GB – 1000x1000x1000 字节
|
||||
* G – 1024x1024x1024 字节
|
||||
|
||||
你也可以单独指定读和写的块大小。要指定读块的大小使用 ‘ibs=’。要指定写块的大小使用 ‘obs=’。
|
||||
|
||||
我使用三个不同的块大小做了一个 120 MB 分区的备份测试。第一个时候默认的 512 字节,它用了 7 秒钟。第二个块大小为 1024 K,它用时 2 秒。第三个块大小是 2048 K,它用时 3 秒。用时会随系统以及其它硬件实现的不同而变化,但通常来说更大的块大小会比默认的稍微快一点。
|
||||
|
||||
一旦你完成了一次备份,你还需要知道如何把数据恢复到设备中。
|
||||
|
||||
**恢复分区**
|
||||
|
||||
现在我们已经有了一个备份点,假设数据可能被损毁了或者由于某些原因需要进行恢复。
|
||||
|
||||
命令和备份时相同,只是源和目标相反。对于上面的例子,命令会变为:
|
||||
|
||||
_dcfldd of=/dev/sdc if=/tmp/SD-Card-Backup.img_
|
||||
|
||||
这里,镜像文件被用作输入文件(if)而设备(sdc)被用作输出文件(of)。
|
||||
|
||||
**注意:** 要记住输出设备会被重写,它上面的所有数据都会丢失。通常来说在恢复数据之前最好用 GParted 删除 SD 卡上的所有分区。
|
||||
|
||||
假如你在使用多个 SD 卡,例如多个树莓派主板,你可以一次性写多块 SD 卡。为了做到这点你需要知道系统中卡的 ID。例如,假设我们想把镜像 ‘BerryBoot.img’ 拷贝到两个 SD 卡。SD 卡分别是 /dev/sdc 和 /dev/sdd。下面的命令在显示进度时每次读写 1 MB 的块。命令如下:
|
||||
|
||||
_dcfldd if=BerryBoot.img bs=1M status=progress | tee >(dcfldd of=/dev/sdc) | dcfldd of=/dev/sdd_
|
||||
|
||||
在这个命令中,第一个 dcfldd 指定输入文件并把块大小设置为 1 MB。status 被设置为显示进度。然后输入通过管道(|)传输给命令 ‘tee’。‘tee’ 用于将输入分发到多个地方。第一个输出是到命令 ‘(dcfldd of=/dev/sdc)’。命令被放到小括号内被作为一个命令执行。我们还需要最后一个管道(|),否则命令 ‘tee’ 会把信息发送到 ‘stdout’ (屏幕)。因此,最后的输出是被发送到命令 ‘_dcfldd of=/dev/sdd’_。如果你有第三个 SD 卡,甚至更多,只需要添加另外的重定向和命令,类似 ‘_>(dcfldd of=/dev/sde_’。
|
||||
|
||||
**注意:**记住最后一个命令必须在管道(|)后面。
|
||||
|
||||
必须验证写的数据确保数据是正确的。
|
||||
|
||||
**验证数据**
|
||||
|
||||
一旦创建了一个镜像或者恢复了一个备份,你可以验证这些写的数据。要验证数据你会使用名为 ‘_diff_’ 的领一个不同程序。
|
||||
|
||||
使用 ‘diff’ 你需要指定镜像文件的位置以及系统中拷贝自或写入的物理媒介。你可以在创建备份或者恢复了一个镜像之后使用 ‘_diff_’ 命令。
|
||||
|
||||
该命令有两个参数。第一个是物理媒介,第二个是镜像文件名称。
|
||||
|
||||
对于例子 ‘_dcfldd of=/dev/sdc if=/tmp/SD-Card-Backup.img’_,对应的 ‘_diff_’ 命令是:
|
||||
|
||||
_diff /dev/sdc /tmp/SD-Card-Backup.img_
|
||||
|
||||
如果镜像和物理设备有任何的不同,你会被告知。如果没有显示任何信息,那么数据就验证为完全相同。
|
||||
|
||||
确保数据完全一致是验证备份和恢复完整性的关键。进行备份时需要注意的一个主要问题是镜像大小。
|
||||
|
||||
**分割镜像**
|
||||
|
||||
假设你想要备份一个 16GB 的 SD 卡。镜像文件大小会大概相同。如果你只能把它备份到 FAT32 分区会怎样呢?FAT32 最大文件大小限制是 4 GB。
|
||||
|
||||
必须做的是文件必须被切分为 4 GB 的分片。通过管道(|)将数据传输给 ‘_split_’ 命令可以切分正在被写的镜像文件。
|
||||
|
||||
创建备份的方法相同,但命令会包括管道和切分命令。对于命令为 ‘_dcfldd if=/dev/sdc of=/tmp/SD-Card-Backup.img_’ 的事例备份,切分文件的新命令如下:
|
||||
|
||||
_dcfldd if=/dev/sdc | split -b 4000MB - /tmp/SD-Card-Backup.img_
|
||||
|
||||
**注意:** 大小后缀和 ‘_dd_’ 及 ‘_dcfldd_’ 命令的意义相同。 ‘_split_’ 命令中的破折号用于将通过管道从 ‘_dcfldd_’ 命令传输过来的数据填充到输入文件。
|
||||
|
||||
文件会被保存为 ‘_SD-Card-Backup.imgaa_’ 和 ‘_SD-Card-Backup.imgab_’,如此类推。如果你担心文件大小太接近 4 GB 的限制,可以试着用 3500MB。
|
||||
|
||||
将文件恢复到设备也很简单。你使用 ‘_cat_’ 命令将它们连接起来然后像下面这样用 ‘_dcfldd_’ 写输出:
|
||||
|
||||
_cat /tmp/SD-Card-Backup.img* | dcfldd of=/dev/sdc_
|
||||
|
||||
你可以在 “_dcfldd_” 命令中包含任何需要的参数。
|
||||
|
||||
我希望你了解并能执行任何需要的数据备份和恢复,正如 SD 卡和类似设备所需的那样。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.linuxforum.com/threads/partition-backup.3638/
|
||||
|
||||
作者:[Jarret][a]
|
||||
译者:[ictlyh](https://github.com/ictlyh)
|
||||
校对:[jasminepeng](https://github.com/jasminepeng)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://www.linuxforum.com/members/jarret.268/
|
@ -1,98 +0,0 @@
|
||||
# Fedora 25: Wayland 大战 Xorg
|
||||
|
||||
就像异形大战铁血战士一样,后者略胜一筹。不管怎样,你可能知道,我最近测试了 [Fedora 25][1],体验还可以。总的来说,这个发行版表现的相当不错。它不是最快速的,但随着一系列的改进,变得足够稳定也足够可用。最重要的是,除了一些性能以及响应性的损失,Wayland 并没有造成我的系统瘫痪。但这还仅仅是个开始。
|
||||
|
||||
Wayland 作为一种消费者技术还处在它的襁褓期,或者至少是当人们在处理桌面事物时应理所当然的这么认为。因此,我必须继续测试,绝不弃坑。在过去的积极地使用 Fedora 25 的几个星期里,我确实碰到了几个其他的问题,有些不用太担心,有些确实很恼人,有些很奇怪,有些却无意义。让我们来讲述一下吧!
|
||||
|
||||
![Teaser](http://www.dedoimedo.com/images/computers-years/2016-2/fedora-wayland-xorg-teaser.jpg)
|
||||
|
||||
注: 图片来自 [Wikimedia][2] 并做了些修改, 证书为 [CC BY-SA 3.0][3].
|
||||
|
||||
### Wayland 并不支持所有软件
|
||||
|
||||
当然不,这是一个事实。如果你去网站上阅读相关的信息,你会发现各种各样的软件都还没为 Wayland 做好准备。但是,我们都知道 Fedora 是一个激进的高端发行版,所以它是为了探索新功能的测试床。这很公平。有一段时间,所有东西都很正常,没有瞎忙活,没有错误。但接下来,我突然需要使用 GParted。我当时很着急,正在排除一个大故障,然后我不得不让自己侧重于无意义的额外工作。 GParted 没办法在 Wayland 下直接启动。在探索了更多一些细节之后,我知道了分区软件目前还没有被支持。
|
||||
|
||||
![GParted 无法运行于 Wayland](http://www.dedoimedo.com/images/computers-years/2016-2/fedora-wayland-xorg-gparted.jpg)
|
||||
|
||||
问题就在于我并不太清楚其他哪些应用不能在 Wayland 下运行,并且我不能在一个正确估计的时间敏锐地发现。通过在线搜索,我还是不能找到一个目前的简要的不兼容列表。可能只是我,在搜索中遇到了困难,但显然的是一定有什么东西和 "Wayland + 兼容性" 一样琐碎。
|
||||
|
||||
我已经找到的是一个告诉我们 Wayland 很棒的[自我评论][4],一个目前已被这个新玩意儿支持的 [Gnome][5] 应用程序列表,一些 ArchWiki 上的死板的资料,一个在 [英伟达][6] 开发论坛上的呆板得让我后悔点进去的主题,以及一些其他含糊的讨论。
|
||||
|
||||
### 再次提到性能
|
||||
|
||||
在 Fedora 25 上,我把登录会话从 Gnome(Wayland)切换到 Gnome Xorg,观察会对系统产生什么影响。我之前已经提到过在同一个笔记本([联想 G50][8])上的性能跑分和与 [Fedora 24][7] 的比较,但这次会给我们提供更加准确的结果。
|
||||
|
||||
Wayland(截图 1)空闲时的内存占用为 1.4GB, CPU 的平均负载约为 4-5%。Xorg(截图 2)占用了同样大小的内存,处理器消耗了全部性能的 3-4%,单纯从数字上来看少了一小点。但是 Xorg 会话的体验却好得多。虽然只是毫秒级,但你感受的到差距。传统的会话看起来更加的灵动、快速、清新一点。但(Wayland)落后并不明显。如果你对你的电脑响应速度很敏感,你可能不会对这点延迟满意。当然,这可能只会成为新手的一点点优化措施,Wayland 会随时间进步。但它也是我们所不能忽视的。
|
||||
|
||||
![Wayland resources](http://www.dedoimedo.com/images/computers-years/2016-2/fedora-wayland-xorg-resources-wayland.jpg)
|
||||
|
||||
![Xorg resources](http://www.dedoimedo.com/images/computers-years/2016-2/fedora-wayland-xorg-resources-xorg.jpg)
|
||||
|
||||
### 杂谈
|
||||
|
||||
我对此并不高兴。并不是很愤怒,但我不喜欢为了能完全享受我的桌面体验,我却需要登录到传统的 X 会话。因为 X 给了我 100%,但 Wayland 没有。这意味着在一天结束的时候,我不是在用着 Wayland。我喜欢探索科技,但我不是一个盲目的狂热追随者。我只是想用我的桌面,有时我可能需要它快速响应。注销然后重新登录在急需使用的时候会成为恼人的麻烦。我们遇到这个问题的原因就是 Wayland 没有让 Linux 桌面用户的生活变得更简单,而恰恰相反。引用:
|
||||
|
||||
> Wayland 是为了成为 X 的更加简单的替代品,更加容易开发和维护。建议 GNOME 和 KDE 都使用它。
|
||||
|
||||
你能看到,这就是问题的一方面原因。东西不应该被设计成容易开发或维护。它能成为所有其他消费需求碰撞后提供的有益的副产品。但如果它们不是,那么不管它对于程序员敲代码来说多么困难或简单都将不重要。那是他们的工作。科技的所有目的都是为了达到一种无缝并且流畅的用户体验。
|
||||
|
||||
不幸的是,现在很大数量的产品都被重新设计或者开发,只是为了使软件人员更加轻松,而不是用户。在很大程度上,Gnome 3、PulseAudio、[Systemd][9] 和 Wayland 都没有遵循提高用户体验的宗旨。在这个意义上来说,它们更像是一种侵略,而没有为 Linux 桌面生态的稳定性和易用性作出贡献。
|
||||
|
||||
这也是为什么 Linux 桌面是一个相对不成熟产品的一个主要原因————它被设计成开发人员的自我支持产品,更像一个活生生的生物。而不是依附于用户各种怪念头和想法的奴隶。这也是伟大事物是如何形成的。你满足于主要需求,接下来只是担心细节方面。优秀的用户体验不依赖于(也永远不依赖于)编程语言、编译器的选择,或任何其他无意义的东西。如果依赖了,那么不管谁来设计这个抽象层做的不够好的产品,我们都会得到一个失败的作品,需要把它的存在抹去。
|
||||
|
||||
那么在我的展望中,我不在乎是否要花费 10 升心血,或其他的什么,去编译一个版本。我是一个用户,我所在乎的只是我的桌面能否像它昨天或者 5 年前一样健壮地工作。如果没发生那种事,我不会对宏、类、变量、声明、结构体,或其他任何极客的计算机科技感兴趣。那是不着边际的。一个产品宣传自己是被创造出来为人们的开发提供方便的,那是个悖论。接下来也不用去开发它了。这样反而会使事情更简单。
|
||||
|
||||
现在,事实是 Wayland 大体上可用,但它仍然不像 X 那么好。并且它也不应该在任何的桌面上作为就绪的产品被提供。一但它能够无缝取代那人们没听说过的过时技术,到那时,它能够在它需要去实现的目标取得成功。然后,它能够用 C、D 或者 K 语言重写,拥有开发者需要的任何东西。在那之前,它都是一个蚕食资源和人们思想的寄生虫。
|
||||
|
||||
不要误会,我们需要进步,需要改变。但它不得不为了进化的目而服务。现在 X 能很好地掌握用户需求了吗?它能为第三方库提供图形支持吗?它能支持 HD、UHD、DPI 或其他的什么吗?你能用它玩最新的游戏吗?是或否?如果不能,那么它需要被修复。这些就是进化的驱动力。而不是写代码或者编译代码的困难程度。软件开发者是数字工业的矿工,他们需要努力工作来使用户开心。就像短语“更加易于开发”应该被取缔一样,那些崇尚于此的人也应该用老式收音机的电池处以电刑,然后用没有空调的飞船流放到火星上去。如果你不能写出高明的代码,那是你的问题。用户不能因为开发者认为自己是公主而遭受折磨。
|
||||
|
||||
### 结语
|
||||
|
||||
说到这里。大体上说,Wayland 还可以,并不差。但这说的就像是某人决定修改你工资单上的布局,导致你从昨天能赚 100% 到今天只能赚 83% 一样。讲道理这是不能接受的,即使 Wayland 工作的相当好。正是那些不能运作的东西导致如此大的不同。忽略所有数落它的一方, Wayland 被认为的降低了可用性、性能以及软件的知名度,正是 Fedora 亟待解决的问题。
|
||||
|
||||
其他的发行版会跟进,然后我们会看到一个循环的模式,就像 Gnome 3 和 Systemd 所发生的一样。没有完全准备好的东西被放到开放环境中,然后我们花费一两年时间修复无需修复的东西,最终我们将拥有我们已经拥有的相同功能,只是用不同的编程语言来实现。我并不感兴趣。计算机科学曾在 1999 年非常受欢迎,当时 Excel 用户每小时能赚 50 美元。现在,编程就像是躲在平底船下划桨,人们并不会在乎你在甲板下流下的汗水与磨出的水泡。
|
||||
|
||||
性能可能已经不是一个问题,因为你可以放弃 1-2% 的变化,尤其是它会受随机的来自任何一个因素的影响。如果你已经用 Linux 超过一、两年你就会知道的。但是无法启动应用是个大问题。至少 Fedora 也友好地提供了传统的平台。但是,它可能会在 Wayland 100% 成熟前就消失了。我们再来看看,不,不会有灾难。我原本的 Fedora 25 宣称支持这种看法。我们有的就是烦恼,不必要的烦恼。啊,这是 Linux 故事中的第 9000 部。
|
||||
|
||||
那么,在今天结束之际,我们已经讨论了所有事情。从中我们学到:臣伏于 Xorg!天呐!真棒,现在我将淡入背景,而笑声会将你的欢乐带给寒冷的夜晚。再见!
|
||||
|
||||
干杯。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
作者简介:
|
||||
|
||||
我是 Igor Ljubuncic。现在大约 38 岁,已婚但还没有孩子。我现在在一个大胆创新的云科技公司做首席工程师。直到大约 2015 年初,我还在一个全世界最大的 IT 公司之一中做系统架构工程师,和一个工程计算团队开发新的基于 Linux 的解决方案,优化内核以及攻克 Linux 的问题。在那之前,我是一个为高性能计算环境设计创新解决方案的团队的技术领导。还有一些其他花哨的头衔,包括系统专家、系统程序员等等。所有这些都曾是我的爱好,但从 2008 年开始成为了我的有偿的工作。还有什么比这更令人满意的呢?
|
||||
|
||||
从 2004 年到 2008 年间,我曾通过作为医学影像行业的物理学家来糊口。我的工作专长集中在解决问题和算法开发。为此,我广泛地使用了Matlab,主要用于信号和图像处理。另外,我得到了几个主要的工程方法学的认证,包括 MEDIC 六西格玛绿带、试验设计以及统计工程学。
|
||||
|
||||
我也写过书,包括《Linux 上的高幻想和技术工作》和《相互包容》。
|
||||
|
||||
请参阅我的完整开源项目,出版物和专利列表,只需向下滚动。
|
||||
|
||||
有关我的奖项、提名和 IT 相关认证的完整列表,请进行跳转。
|
||||
|
||||
|
||||
-------------
|
||||
|
||||
|
||||
via: http://www.dedoimedo.com/computers/fedora-25-wayland-vs-xorg.html
|
||||
|
||||
作者:[Igor Ljubuncic][a]
|
||||
译者:[cycoe](https://github.com/cycoe)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.dedoimedo.com/faq.html
|
||||
|
||||
[1]:http://www.dedoimedo.com/computers/fedora-25-gnome.html
|
||||
[2]:https://commons.wikimedia.org/wiki/File:DragonCon-AlienVsPredator.jpg
|
||||
[3]:https://creativecommons.org/licenses/by-sa/3.0/deed.en
|
||||
[4]:https://wayland.freedesktop.org/faq.html
|
||||
[5]:https://wiki.gnome.org/Initiatives/Wayland/Applications
|
||||
[6]:https://devtalk.nvidia.com/default/topic/925605/linux/nvidia-364-12-release-vulkan-glvnd-drm-kms-and-eglstreams/
|
||||
[7]:http://www.dedoimedo.com/computers/fedora-24-gnome.html
|
||||
[8]:http://www.dedoimedo.com/computers/lenovo-g50-distros-second-round.html
|
||||
[9]:http://www.ocsmag.com/2016/10/19/systemd-progress-through-complexity/
|
@ -0,0 +1,478 @@
|
||||
如何安装 pandom : 一个针对 linux 的真随机数生成器
|
||||
============================================================
|
||||
|
||||
### 在本文中,你将看到
|
||||
|
||||
1. [简介][40]
|
||||
2. [1 pandom 的安装][41]
|
||||
1. [1.1 获取 root 权限][1]
|
||||
2. [1.2 安装编译所需的依赖][2]
|
||||
3. [基于 Arch 的系统][3]
|
||||
4. [基于 Debian 的系统][4]
|
||||
5. [基于 Red Hat 的系统][5]
|
||||
6. [基于 SUSE 的系统][6]
|
||||
7. [1.3 下载并析出源码][7]
|
||||
8. [1.4 在安装前进行测试 (推荐)][8]
|
||||
9. [1.5 确定初始化系统][9]
|
||||
10. [1.6 安装 pandom][10]
|
||||
11. [基于 init.d 的初始化系统 (例如 upstart、sysvinit)][11]
|
||||
12. [以 systemd 作为初始化程序的系统][12]
|
||||
3. [2 checkme 文件的分析][42]
|
||||
1. [2.1 获取 root 权限][13]
|
||||
2. [2.2 安装编译所需的依赖][14]
|
||||
3. [基于 Arch 的系统][15]
|
||||
4. [基于 Debian 的系统][16]
|
||||
5. [基于 Red Hat 的系统][17]
|
||||
6. [基于 SUSE 的系统][18]
|
||||
7. [2.3 下载并析出源码][19]
|
||||
8. [2.4 安装 entropyarray][20]
|
||||
9. [2.5 分析 checkme 文件][21]
|
||||
10. [2.6 卸载 entropyarray (可选)][22]
|
||||
4. [3 使用 debian 软件仓库安装 pandom][43]
|
||||
1. [3.1 获取 root 权限][23]
|
||||
2. [3.2 安装密钥][24]
|
||||
3. [3.3 安装软件源列表][25]
|
||||
4. [Wheezy][26]
|
||||
5. [Jessie][27]
|
||||
6. [Stretch][28]
|
||||
7. [3.4 更新软件源列表][29]
|
||||
8. [3.5 测试 pandom][30]
|
||||
9. [3.6 安装 pandom][31]
|
||||
5. [4 管理 pandom][44]
|
||||
1. [4.1 性能测试][32]
|
||||
2. [4.2 熵及序列相关性测试][33]
|
||||
3. [4.3 系统服务][34]
|
||||
4. [基于 init.d 的初始化系统 (例如 upstart、sysvinit)][35]
|
||||
5. [以 systemd 作为初始化程序的系统][36]
|
||||
6. [5 增强不可预测性或者性能][45]
|
||||
1. [5.1 编辑源文件][37]
|
||||
2. [5.2 测试不可预测性][38]
|
||||
3. [5.3 安装个人定制的 pandom][39]
|
||||
|
||||
本教程只针对 amd64/x86_64 架构 linux 内核版本大于等于 2.6.9 的系统。本文将解释如何安装 [pandom][46],一个由 ncomputers.org 维护的定时颤动真随机数生成器。
|
||||
|
||||
### 简介
|
||||
|
||||
以现代的眼光来看,Linux 内核内置的真随机数发生器提供了一个很低的吞吐量,例如在配置固态硬盘 (SSD) 的个人电脑和虚拟专用服务器 (VPS)的环境中。
|
||||
|
||||
各种不同的加密目的使得对真随机数的需求持续增长,从而使得这个低吞吐量问题在各种 linux 实现中变得越来越普遍。
|
||||
|
||||
在相同的物理或者虚拟环境下,并假设没有其他进程以 root 身份向 /dev/random 进行写操作的话,64 [ubits][47]/64 bits 的 pandom 可以以 8 KiB/s 的速率生成随机数。
|
||||
|
||||
### 1 pandom 的安装
|
||||
|
||||
### 1.1 获得 root 权限
|
||||
|
||||
Pandom 必须以 root 身份来安装,所以在必要的时候请运行如下命令:
|
||||
|
||||
su -
|
||||
|
||||
### 1.2 安装编译所需的依赖
|
||||
|
||||
为了下载并安装 pandom,你需要 GNU **as** 汇编器、GNU **make**、GNU **tar** 和 GNU **wget** (最后两个工具通常已被安装)。随后你可以按照你的意愿卸载它们。
|
||||
|
||||
### 基于 Arch 的系统
|
||||
|
||||
pacman -S binutils make
|
||||
|
||||
### 基于 Debian 的系统
|
||||
|
||||
apt-get install binutils make
|
||||
|
||||
### 基于 Red Hat 的系统
|
||||
|
||||
dnf install binutils make
|
||||
|
||||
yum install binutils make
|
||||
|
||||
### 基于 SUSE 的系统
|
||||
|
||||
zypper install binutils make
|
||||
|
||||
### 1.3 下载并析出源码
|
||||
|
||||
下面的命令将使用 **wget** 和 **tar** 从 ncomputers.org 下载 pandom 的源代码并将它们解压出来:
|
||||
|
||||
wget [http://ncomputers.org/pandom.tar.gz][48]
|
||||
tar xf pandom.tar.gz
|
||||
cd pandom/amd64-linux
|
||||
|
||||
### 1.4 在安装前进行测试 (推荐)
|
||||
|
||||
这个被推荐的测试将花费大约 8 分钟的时间,它将检查内核支持情况并生成一个名为 **checkme** 的文件 (在下一节中将被分析)。
|
||||
|
||||
make check
|
||||
|
||||
### 1.5 确定系统的初始化程序
|
||||
|
||||
在安装 pandom 之前,你需要知道你的系统使用的是哪个初始化程序。假如下面命令的输出中包含 **running**,则意味着你的系统使用了 **systemd**,否则你的系统则可能使用了一个 **init.d** 的实现 (例如 upstart、sysvinit)。
|
||||
|
||||
systemctl is-system-running
|
||||
|
||||
```
|
||||
running
|
||||
```
|
||||
|
||||
### 1.6 安装 pandom
|
||||
|
||||
一旦你知道了你的系统使用何种 linux 实现,那么你就可以相应地安装 pandom 了。
|
||||
|
||||
### 使用基于 init.d 作为初始化程序(如: upstart、sysvinit) 的系统
|
||||
|
||||
假如你的系统使用了一个 **init.d** 的实现(如: upstart、sysvinit),请运行下面的命令来安装 pandom:
|
||||
|
||||
make install-init.d
|
||||
|
||||
### 以 systemd 作为初始化程序的系统
|
||||
|
||||
假如你的系统使用 **systemd**,则请运行以下命令来安装 pandom:
|
||||
|
||||
make install-systemd
|
||||
|
||||
### 2 checkme 文件的分析
|
||||
|
||||
在使用 pandom 进行加密之前,强烈建议分析一下先前在安装过程中生成的 **checkme** 文件。通过分析我们便可以知道用 pandom 生成的数是否真的随机。本节将解释如何使用 ncomputers.org 的 shell 脚本 **entropyarray** 来测试由 pandom 产生的输出的熵及序列相关性。
|
||||
|
||||
**注**:整个分析过程也可以在另一台电脑上完成,例如在一个笔记本电脑或台式机上。举个例子:假如你正在一个资源受到限制的 VPS 上安装 pandom 程序,或许你更倾向于将 **checkme** 复制到自己的个人电脑中,然后再进行分析。
|
||||
|
||||
### 2.1 获取 root 权限
|
||||
|
||||
`entropyarray` 程序也必须以 root 身份来安装,所以在必要时请运行如下命令:
|
||||
|
||||
su -
|
||||
|
||||
### 2.2 安装编译所需的依赖
|
||||
|
||||
为了下载并安装 entropyarray, 你需要 GNU **g++** 编译器、GNU **make**、GNU **tar** 和 GNU **wget**。在随后你可以任意卸载这些依赖。
|
||||
|
||||
### 基于 Arch 的系统
|
||||
|
||||
pacman -S gcc make
|
||||
|
||||
### 基于 Debian 的系统
|
||||
|
||||
apt-get install g++ make
|
||||
|
||||
### 基于 Red Hat 的系统
|
||||
|
||||
dnf install gcc-c++ make
|
||||
|
||||
yum install gcc-c++ make
|
||||
|
||||
### 基于 SUSE 的系统
|
||||
|
||||
zypper install gcc-c++ make
|
||||
|
||||
### 2.3 下载并析出源码
|
||||
|
||||
以下命令将使用 **wget** 和 **tar** 从 ncomputers.org 下载到 entropyarray 的源码并进行解压:
|
||||
|
||||
wget [http://ncomputers.org/rearray.tar.gz][50]
|
||||
wget [http://ncomputers.org/entropy.tar.gz][51]
|
||||
wget [http://ncomputers.org/entropyarray.tar.gz][52]
|
||||
|
||||
tar xf entropy.tar.gz
|
||||
tar xf rearray.tar.gz
|
||||
tar xf entropyarray.tar.gz
|
||||
|
||||
### 2.4 安装 entropyarray
|
||||
|
||||
**注**:如果在编译过程中报有关 -std=c++11 的错误,则说明当前系统安装的 GNU **g++** 版本不支持 ISO C++ 2011 标准,那么你可能需要在另一个支持该标准的系统中编译 ncomputers.org/**entropy** 和 ncomputers.org/**rearray** (例如在一个你喜爱的较新的 linux 发行版本中来编译)。接着使用 **make install** 来安装编译好的二进制文件,再接着你可能想继续运行 **entropyarray** 程序,或者跳过运行该程序这一步骤,然而我还是建议在使用 pandom 来达到加密目地之前先分析一下 **checkme** 文件。
|
||||
|
||||
cd rearray; make install; cd ..
|
||||
cd entropy; make install; cd ..
|
||||
cd entropyarray; make install; cd ..
|
||||
|
||||
### 2.5 分析 checkme 文件
|
||||
|
||||
**注**:64 [ubits][53] / 64 bits 的 pandom 实现所生成的结果中熵应该高于 **15.977** 且 **max** 字段低于 **70**。假如你的结果与之相差巨大,或许你应该按照下面第 5 节介绍的那样增加你的 pandom 实现的不可预测性。假如你跳过了生成 checkme 文件的那一步,你也可以使用其他的工具来进行测试,例如 [伪随机数序列测试][54]。
|
||||
|
||||
entropyarray checkme
|
||||
|
||||
```
|
||||
entropyarray in /tmp/tmp.mbCopmzqsg
|
||||
15.977339
|
||||
min:12
|
||||
med:32
|
||||
max:56
|
||||
15.977368
|
||||
min:11
|
||||
med:32
|
||||
max:58
|
||||
15.977489
|
||||
min:11
|
||||
med:32
|
||||
max:59
|
||||
15.977077
|
||||
min:12
|
||||
med:32
|
||||
max:60
|
||||
15.977439
|
||||
min:8
|
||||
med:32
|
||||
max:59
|
||||
15.977374
|
||||
min:13
|
||||
med:32
|
||||
max:60
|
||||
15.977312
|
||||
min:12
|
||||
med:32
|
||||
max:67
|
||||
```
|
||||
|
||||
### 2.6 卸载 entropyarray (可选)
|
||||
|
||||
假如你打算不再使用 entropyarray,那么你可以按照你自己的需求卸载它:
|
||||
|
||||
cd entropyarray; make uninstall; cd ..
|
||||
cd entropy; make uninstall; cd ..
|
||||
cd rearray; make uninstall; cd ..
|
||||
|
||||
### 3 使用 debian 的软件仓库来进行安装
|
||||
|
||||
假如你想在你基于 debian 的系统中让 pandom 保持更新,则你可以使用 ncomputers.org 的 debian 软件仓库来安装或者重新安装它。
|
||||
|
||||
### 3.1 获取 root 权限
|
||||
|
||||
以下的 debian 软件包必须以 root 身份来安装,所以在必要时请运行下面这个命令:
|
||||
|
||||
su -
|
||||
|
||||
### 3.2 安装密钥
|
||||
|
||||
下面的 debian 软件包中包含 ncomputers.org debian 软件仓库的公匙密钥:
|
||||
|
||||
wget [http://ncomputers.org/debian/keyring.deb][55]
|
||||
dpkg -i keyring.deb
|
||||
rm keyring.deb
|
||||
|
||||
### 3.3 安装软件源列表
|
||||
|
||||
下面这些 debian 软件包含有 ncomputers.org debian 软件仓库的软件源列表,这些软件源列表对应最新的 debian 发行版本(截至 2017 年)。
|
||||
|
||||
**注**:你也可以将下面的以 `#` 注释的行加入 **/etc/apt/sources.list** 文件中,而不是为你的 debian 发行版本安装对应的 debian 软件包。但假如这些源在将来改变了,你就需要手动更新它们。
|
||||
|
||||
### Wheezy
|
||||
|
||||
#deb [http://ncomputers.org/debian][56] wheezy main
|
||||
wget [http://ncomputers.org/debian/wheezy.deb][57]
|
||||
dpkg -i wheezy.deb
|
||||
rm wheezy.deb
|
||||
|
||||
### Jessie
|
||||
|
||||
#deb [http://ncomputers.org/debian][58] jessie main
|
||||
wget [http://ncomputers.org/debian/jessie.deb][59]
|
||||
dpkg -i jessie.deb
|
||||
rm jessie.deb
|
||||
|
||||
### Stretch
|
||||
|
||||
#deb [http://ncomputers.org/debian][60] stretch main
|
||||
wget [http://ncomputers.org/debian/stretch.deb][61]
|
||||
dpkg -i stretch.deb
|
||||
rm stretch.deb
|
||||
|
||||
### 3.4 升级软件源列表
|
||||
|
||||
一旦密钥和软件源列表安装完成,则可以使用下面的命令来更新:
|
||||
|
||||
apt-get update
|
||||
|
||||
### 3.5 测试 pandom
|
||||
|
||||
测试完毕后,你可以随意卸载下面的软件包。
|
||||
|
||||
**注**:假如你已经在你的 linux 中测试了 pandom , 则你可以跳过这一步。
|
||||
|
||||
apt-get install pandom-test
|
||||
pandom-test
|
||||
|
||||
```
|
||||
generating checkme file, please wait around 8 minutes ...
|
||||
entropyarray in /tmp/tmp.5SkiYsYG3h
|
||||
15.977366
|
||||
min:12
|
||||
med:32
|
||||
max:57
|
||||
15.977367
|
||||
min:13
|
||||
med:32
|
||||
max:57
|
||||
15.977328
|
||||
min:12
|
||||
med:32
|
||||
max:61
|
||||
15.977431
|
||||
min:12
|
||||
med:32
|
||||
max:59
|
||||
15.977437
|
||||
min:11
|
||||
med:32
|
||||
max:57
|
||||
15.977298
|
||||
min:11
|
||||
med:32
|
||||
max:59
|
||||
15.977196
|
||||
min:10
|
||||
med:32
|
||||
max:57
|
||||
```
|
||||
|
||||
### 3.6 安装 pandom
|
||||
|
||||
apt-get install pandom
|
||||
|
||||
### 4 管理 pandom
|
||||
|
||||
在 pandom 安装完成后,你可能想对它进行管理。
|
||||
|
||||
### 4.1 性能测试
|
||||
|
||||
pandom 提供大约 8 kB/s 的随机数生成速率,但它的性能可能根据环境而有所差异。
|
||||
|
||||
dd if=/dev/random of=/dev/null bs=8 count=512
|
||||
|
||||
```
|
||||
512+0 records in
|
||||
512+0 records out
|
||||
4096 bytes (4.1 kB, 4.0 KiB) copied, 0.451253 s, 9.1 kB/s
|
||||
```
|
||||
|
||||
### 4.2 熵和序列相关性检验
|
||||
|
||||
除了 ncomputers.org/**entropyarray**,还存在更多的测试,例如 [Ilja Gerhardt 的 NIST 测试套件][62].
|
||||
|
||||
entropyarray /dev/random 1M
|
||||
|
||||
### 4.3 系统服务
|
||||
|
||||
pandom 还可以以系统服务的形式运行。
|
||||
|
||||
### 基于 init.d 的初始化系统(如 upstart、sysvinit)
|
||||
|
||||
/etc/init.d/random status
|
||||
/etc/init.d/random start
|
||||
/etc/init.d/random stop
|
||||
/etc/init.d/random restart
|
||||
|
||||
### 以 systemd 作为初始化程序的系统
|
||||
|
||||
systemctl status random
|
||||
systemctl start random
|
||||
systemctl stop random
|
||||
systemctl restart random
|
||||
|
||||
### 5 增强不可预测性或者性能
|
||||
|
||||
假如你想增加你编译的 pandom 程序的不可预测性或者性能,你可以尝试增加或删减 CPU 时间测量选项。
|
||||
|
||||
### 5.1 编辑源文件
|
||||
|
||||
请按照自己的意愿,在源文件 **test.s** 和 **tRNG.s** 中增加或者移除 measurement blocks 字段。
|
||||
|
||||
```
|
||||
#measurement block
|
||||
mov $35,%rax
|
||||
syscall
|
||||
rdtsc
|
||||
[...]
|
||||
|
||||
#measurement block
|
||||
mov $35,%rax
|
||||
syscall
|
||||
rdtsc
|
||||
[...]
|
||||
```
|
||||
|
||||
### 5.2 测试不可预测性
|
||||
|
||||
我们总是建议在使用个人定制的 pandom 实现来用于加密目地之前,先进行一些测试。
|
||||
|
||||
make check
|
||||
|
||||
### 5.3 安装定制的 pandom
|
||||
|
||||
假如你对测试的结果很满意,你就可以使用下面的命令来安装你的 pandom 实现。
|
||||
|
||||
make install
|
||||
|
||||
更多额外信息及更新详见 [http://ncomputers.org/pandom][63]
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/
|
||||
|
||||
作者:[Oliver][a]
|
||||
译者:[FSSlc](https://github.com/FSSlc)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/
|
||||
[1]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-gain-root-access
|
||||
[2]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-install-build-dependencies
|
||||
[3]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#arch-based-systems
|
||||
[4]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#debian-based-systems
|
||||
[5]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#red-hat-based-systems
|
||||
[6]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#suse-based-systems
|
||||
[7]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-download-and-extract-sources
|
||||
[8]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-test-before-installing-recommended
|
||||
[9]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-determine-init-system
|
||||
[10]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-install-pandom
|
||||
[11]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#initd-based-init-system-eg-upstart-sysvinit
|
||||
[12]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#systemd-as-init-system
|
||||
[13]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-gain-root-access-2
|
||||
[14]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-install-build-dependencies-2
|
||||
[15]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#arch-based-systems-2
|
||||
[16]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#debian-based-systems-2
|
||||
[17]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#red-hat-based-systems-2
|
||||
[18]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#suse-based-systems-2
|
||||
[19]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-download-and-extract-sources-2
|
||||
[20]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-install-entropyarray
|
||||
[21]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-analyze-checkme-file
|
||||
[22]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-uninstall-entropyarray-optional
|
||||
[23]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-gain-root-access-3
|
||||
[24]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-install-keyring
|
||||
[25]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-install-sources-list
|
||||
[26]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#wheezy
|
||||
[27]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#jessie
|
||||
[28]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#stretch
|
||||
[29]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-update-sources-list
|
||||
[30]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-test-pandom
|
||||
[31]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-install-pandom-2
|
||||
[32]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-performance-test
|
||||
[33]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-entropy-and-serial-correlation-test
|
||||
[34]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-system-service
|
||||
[35]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#initd-based-init-system-eg-upstart-sysvinit-2
|
||||
[36]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#systemd-as-init-system-2
|
||||
[37]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-edit-source-files
|
||||
[38]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-test-the-unpredictability
|
||||
[39]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-install-personalized-pandom
|
||||
[40]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#introduction
|
||||
[41]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-installation-of-pandom
|
||||
[42]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-analysis-of-checkme-file
|
||||
[43]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-installation-using-debian-repository
|
||||
[44]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-managing-pandom
|
||||
[45]:https://www.howtoforge.com/tutorial/how-to-install-pandom-a-true-random-number-generator/#-increasing-unpredictability-or-performance
|
||||
[46]:http://ncomputers.org/pandom
|
||||
[47]:http://ncomputers.org/ubit
|
||||
[48]:http://ncomputers.org/pandom.tar.gz
|
||||
[49]:http://unix.stackexchange.com/a/18210/94448
|
||||
[50]:http://ncomputers.org/rearray.tar.gz
|
||||
[51]:http://ncomputers.org/entropy.tar.gz
|
||||
[52]:http://ncomputers.org/entropyarray.tar.gz
|
||||
[53]:http://ncomputers.org/ubit
|
||||
[54]:http://www.fourmilab.ch/random/
|
||||
[55]:http://ncomputers.org/debian/keyring.deb
|
||||
[56]:http://ncomputers.org/debian
|
||||
[57]:http://ncomputers.org/debian/wheezy.deb
|
||||
[58]:http://ncomputers.org/debian
|
||||
[59]:http://ncomputers.org/debian/jessie.deb
|
||||
[60]:http://ncomputers.org/debian
|
||||
[61]:http://ncomputers.org/debian/stretch.deb
|
||||
[62]:https://gerhardt.ch/random.php
|
||||
[63]:http://ncomputers.org/pandom
|
@ -0,0 +1,277 @@
|
||||
如何在 CentOS 7 上安装 iRedMail 用于 Samba4 AD 集成 - 第 10 部分
|
||||
============================================================
|
||||
|
||||
本系列教程将引导你了解如何在 CentOS 7 安装 iRedMail 以及[ Samba4 AD 域控制器][3],以便域帐户可以通过 Thunderbird 桌面客户端或通过 Roundcube Web 界面发送或接收邮件。
|
||||
|
||||
将安装 iRedMail 的 CentOS 7 服务器需允许通过 25 和 587 端口进行 SMTP 或邮件路由服务,并且还将通过 Dovecot 作为邮件传递代理,提供 POP3 和 IMAP 服务,两者都使用安装中签发的自签名证书进行安全保护。
|
||||
|
||||
收件人邮箱将与 Roundcube 提供的 webmail 用户代理一起存储在同一台 CentOS 服务器上。iRedMail 将使用 Samba4 AD 来查询和验证收件人帐户,在 AD 组的帮助下创建邮件列表,并通过 Samba4 AD DC 控制邮件帐户。
|
||||
|
||||
#### 需要:
|
||||
|
||||
1. [在 Ubuntu 上使用 Samba4 创建 AD 基础架构][1]
|
||||
|
||||
### 步骤 1:在 CentOS 7 上安装 iRedMail
|
||||
|
||||
1. 在安装 iRedMail 之前,请先确保你使用下面的指南在你的机器上安装了一个全新的 CentOS 7 操作系统:
|
||||
|
||||
1. [全新安装 CentOS 7 Minimal][2]
|
||||
|
||||
2. 同样使用下面的命令确保系统更新了最新的安全补丁和软件包。
|
||||
|
||||
```
|
||||
# yum update
|
||||
```
|
||||
|
||||
3. 系统同样需要一个 FQDN 主机名,使用下面的命令设置。使用你自定义的 FQDN 代替 `mail.tecmint.lan` 变量。
|
||||
|
||||
```
|
||||
# hostnamectl set-hostname mail.tecmint.lan
|
||||
```
|
||||
|
||||
使用下面的命令验证系统主机名。
|
||||
|
||||
```
|
||||
# hostname -s # Short name
|
||||
# hostname -f # FQDN
|
||||
# hostname -d # Domain
|
||||
# cat /etc/hostname # Verify it with cat command
|
||||
```
|
||||
[
|
||||
![Verify CentOS 7 Hostname](http://www.tecmint.com/wp-content/uploads/2017/03/Verify-CentOS-7-Hostname.png)
|
||||
][4]
|
||||
|
||||
验证 CentOS 7 主机名
|
||||
|
||||
4. 通过手动编辑 `/etc/hosts`,将机器的 FQDN 和短名称映射到机器回环 IP 地址。添加如下所示的值,并相应替换 `mail.tecmint.lan` 和 mail 的值。
|
||||
|
||||
```
|
||||
127.0.0.1 mail.tecmint.lan mail localhost localhost.localdomain
|
||||
```
|
||||
|
||||
5. iRedMail 专家建议应该完全禁用 SELinux。通过编辑 /etc/selinux/config 并将 SELINUX 参数的值从 `permissive` 设置成 `disabled` 来禁用 SELinux。
|
||||
|
||||
```
|
||||
SELINUX=disabled
|
||||
```
|
||||
|
||||
重启机器并应用新的 SELinux 策略,或者运行 setenforce 带上参数 0 来强制 SELinux 立即禁用。
|
||||
|
||||
```
|
||||
# reboot
|
||||
或者
|
||||
# setenforce 0
|
||||
```
|
||||
|
||||
6. 接下来,安装下面这些接下来会用来系统管理的软件包:
|
||||
|
||||
```
|
||||
# yum install bzip2 net-tools bash-completion wget
|
||||
```
|
||||
|
||||
7. 要安装 iRedMail,首先打牌下载页 [http://www.iredmail.org/download.html][5] 中并用下面的命令下载最新的版本。
|
||||
|
||||
```
|
||||
# wget https://bitbucket.org/zhb/iredmail/downloads/iRedMail-0.9.6.tar.bz2
|
||||
```
|
||||
|
||||
8. 下载完成后,使用下面命令解压压缩包并进入解压后的 iRedMail 目录。
|
||||
|
||||
```
|
||||
# tar xjf iRedMail-0.9.6.tar.bz2
|
||||
# cd iRedMail-0.9.6/
|
||||
# ls
|
||||
```
|
||||
|
||||
9. 使用下面的命令执行 iRedMail 的 shell 脚本来开始安装。接下来安装器会询问一系列的问题。
|
||||
|
||||
```
|
||||
# bash iRedMail.sh
|
||||
```
|
||||
|
||||
10. 在首个欢迎提示中,点击 `Yes` 来继续安装。
|
||||
|
||||
[
|
||||
![iRedMail Setup Wizard](http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-Setup-Wizard.png)
|
||||
][6]
|
||||
|
||||
iRedMail 安装向导
|
||||
|
||||
11. 接下来,选择邮件存储的位置。iRedMail 默认邮箱的存储位置在 `/var/vmail/` 中。
|
||||
|
||||
如果这个目录所在的分区有足够的空间来保存你所有域帐户的邮件,接着点击 Next 来继续。
|
||||
|
||||
否则,如果你已经配置一个更大的分区来用于邮件存储,那么就用不同的目录来更改默认位置。
|
||||
|
||||
[
|
||||
![iRedMail Mail Storage Path](http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-Mail-Storage-Path.png)
|
||||
][7]
|
||||
|
||||
iRedMail 邮件存储路径
|
||||
|
||||
12. 在下一步中,选择要与 iRedMail 进行交互的前端 Web 服务器。今后将完全禁用 iRedMail 管理面板,因此我们将使用前端 Web 服务器仅通过 Roundcube Web 面板访问帐户邮件。
|
||||
|
||||
如果你每小时没有数以千计的邮件帐户访问 webmail 界面,那么你应该使用 Apache Web 服务器来实现其灵活性和易于管理。
|
||||
|
||||
[
|
||||
![iRedMail Preferred Web Server](http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-Preferred-Web-Server.png)
|
||||
][8]
|
||||
|
||||
iRedMail 偏好的 Web 服务器
|
||||
|
||||
13. 在此步骤中,由于 Samba4 域控制器的兼容性原因,请选择 OpenLDAP 后端数据库,并点击 Next 继续,但是一旦将 iRedMail 集成到 Samba 域控制器中,我们将不再使用该 OpenLDAP 数据库。
|
||||
|
||||
[
|
||||
![iRedMail LDAP Backend](http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-LDAP-Backend.png)
|
||||
][9]
|
||||
|
||||
iRedMail LDAP 后端
|
||||
|
||||
14.接下来,如下图所示,为你的 Samba4 域名指定 LDAP 后缀,然后点击 Next 继续。
|
||||
|
||||
[
|
||||
![iRedMail LDAP Suffix](http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-LDAP-Suffix.png)
|
||||
][10]
|
||||
|
||||
iRedMail LDAP 后缀
|
||||
|
||||
15. 在接下来的提示中,只要输入你的域名,并点击 Next 继续。相应地替换 `tecmint.lan` 值。
|
||||
|
||||
[
|
||||
![iRedMail Mail Domain](http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-Mail-Domain.png)
|
||||
][11]
|
||||
|
||||
iRedMail 邮件域
|
||||
|
||||
16. 现在,为 `postmaster@yourdomain.tld` 管理员设置一个密码,并点击 Next 继续。
|
||||
|
||||
[
|
||||
![iRedMail Mail Domain Administrator](http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-Mail-Domain-Administrator.png)
|
||||
][12]
|
||||
|
||||
iRedMail 邮件域管理员
|
||||
|
||||
17. 接下来,从列表中选择要与邮件服务器集成的可选组件。我强烈建议你安装 Roundcube,以便为域帐户提供访问邮件的 Web 界面,尽管你也可以在不同的计算机上安装并配置 Roundcube,以便在高负载情况下释放邮件服务器资源。
|
||||
|
||||
对于受限访问互联网的本地域,特别是在我们使用域集成时,除了 Awstats 以防你需要邮件分析,其他组件不是非常有用。
|
||||
|
||||
[
|
||||
![iRedMail Optional Components](http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-Optional-Components.png)
|
||||
][13]
|
||||
|
||||
iRedMail 可选组件
|
||||
|
||||
18. 在下一步中输入 `Y` 来应用配置并开始安装。
|
||||
|
||||
[
|
||||
![iRedMail Configuration Changes](http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-Configuration-Changes.png)
|
||||
][14]
|
||||
|
||||
iRedMail 配置更改
|
||||
|
||||
19. 最后,所有的问题都输入 yes,接受 iRedMail 脚本自动配置你的防火墙以及 MySQL 配置文件。
|
||||
|
||||
[
|
||||
![iRedMail System Configuration](http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-System-Configuration.png)
|
||||
][15]
|
||||
|
||||
iRedMail 系统配置
|
||||
|
||||
20. 安装完成后,安装器会提供一些敏感信息。比如 iRedAdmin 凭证、web 面板的 URL 地址以及安装过程中使用的所有参数的文件位置。
|
||||
|
||||
[
|
||||
![iRedMail Installation Summary](http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-Installation-Summary.png)
|
||||
][16]
|
||||
|
||||
iRedMail 安装总结
|
||||
|
||||
仔细阅读上面的信息,使用下面的命令重启机器来使所有的邮件服务启用。
|
||||
|
||||
```
|
||||
# init 6
|
||||
```
|
||||
|
||||
21. 系统重启后,使用 root 权限的帐户登录或以 root 身份登录,并使用下面的命令列出所有的网络套接字以及你邮件服务器监听的相关程序。
|
||||
|
||||
在套接字列表中,你会看到邮件服务器几乎覆盖邮件服务器正常运行所需的所有服务:SMTP/S、POP3/S、IMAP/S 和防病毒以及垃圾邮件保护。
|
||||
|
||||
```
|
||||
# netstat -tulpn
|
||||
```
|
||||
[
|
||||
![iRedMail Network Sockets](http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-Network-Sockets.png)
|
||||
][17]
|
||||
|
||||
iRedMail 网络套接字
|
||||
|
||||
22. 为了查看 iRedMail 已修改的所有配置文件的位置、iRedMail 安装过程中用于数据库管理的凭据、邮件管理帐户以及其他帐户,那么就显示 iRedMail.tips 这个文件。
|
||||
|
||||
该文件位于你最初解压安装包的目录中。请注意,你应该移动并保护此文件,因为它包含有关邮件服务器的敏感信息。
|
||||
|
||||
```
|
||||
# less iRedMail-0.9.6/iRedMail.tips
|
||||
```
|
||||
|
||||
23. 上面提到的包含邮件服务器详细信息的文件也将自动发送到 postmaster 这个邮件服务器管理员帐户中。
|
||||
|
||||
通过在浏览器中输入机器的 IP 地址,你可以通过 HTTPS 协议安全地访问 webmail。接受 iRedMail 自签名证书在浏览器中生成的错误,并使用在安装中为 postmaster@your_domain.tld 帐户设置的密码登录。阅读并将此电子邮件存储到一个安全的邮箱。
|
||||
|
||||
```
|
||||
https://192.168.1.254
|
||||
```
|
||||
[
|
||||
![iRedMail Account Login](http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-Account-Login.png)
|
||||
][18]
|
||||
|
||||
iRedMail 登录帐户
|
||||
|
||||
[
|
||||
![iRedMail Web Mail](http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-Web-Mail.png)
|
||||
][19]
|
||||
|
||||
iRedMail Web 邮件
|
||||
|
||||
就是这样了!到目前为止,你已经配置了一台完整的自己运行的邮件服务器了,但尚未与 Samba4 AD 域控制器服务集成。
|
||||
|
||||
在下一部分中,我们将看到如何修改 iRedMail 服务(postfix,dovecot 和 roundcube 配置文件),以便查询域帐户、发送、接收和读取邮件。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
作者简介:
|
||||
|
||||
我是一个电脑上瘾的家伙,开源和基于 linux 系统软件的粉丝,在 Linux 发行版桌面、服务器和 bash 脚本方面拥有大约 4 年的经验。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.tecmint.com/install-iredmail-on-centos-7-for-samba4-ad-integration/
|
||||
|
||||
作者:[Matei Cezar][a]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.tecmint.com/author/cezarmatei/
|
||||
|
||||
[1]:http://www.tecmint.com/install-samba4-active-directory-ubuntu/
|
||||
[2]:http://www.tecmint.com/centos-7-3-installation-guide/
|
||||
[3]:http://www.tecmint.com/install-samba4-active-directory-ubuntu/
|
||||
[4]:http://www.tecmint.com/wp-content/uploads/2017/03/Verify-CentOS-7-Hostname.png
|
||||
[5]:http://www.iredmail.org/download.html
|
||||
[6]:http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-Setup-Wizard.png
|
||||
[7]:http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-Mail-Storage-Path.png
|
||||
[8]:http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-Preferred-Web-Server.png
|
||||
[9]:http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-LDAP-Backend.png
|
||||
[10]:http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-LDAP-Suffix.png
|
||||
[11]:http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-Mail-Domain.png
|
||||
[12]:http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-Mail-Domain-Administrator.png
|
||||
[13]:http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-Optional-Components.png
|
||||
[14]:http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-Configuration-Changes.png
|
||||
[15]:http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-System-Configuration.png
|
||||
[16]:http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-Installation-Summary.png
|
||||
[17]:http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-Network-Sockets.png
|
||||
[18]:http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-Account-Login.png
|
||||
[19]:http://www.tecmint.com/wp-content/uploads/2017/03/iRedMail-Web-Mail.png
|
||||
[20]:http://www.tecmint.com/author/cezarmatei/
|
||||
[21]:http://www.tecmint.com/10-useful-free-linux-ebooks-for-newbies-and-administrators/
|
||||
[22]:http://www.tecmint.com/free-linux-shell-scripting-books/
|
@ -0,0 +1,142 @@
|
||||
bd - 快速返回到父目录而不用冗余地输入 “cd ../../ ..”
|
||||
============================================================
|
||||
|
||||
|
||||
在 Linux 系统上通过命令行切换文件夹时,为了回到父目录(长路径),我们通常会重复输入[ cd 命令][1](`cd ../../..`),直到进入感兴趣的目录。
|
||||
|
||||
对于经验丰富的 Linux 用户或需要进行各种不同任务的系统管理员而言,这可能非常乏味,因此希望在操作系统时有一个快捷方式来简化工作。
|
||||
|
||||
**建议阅读:** [Autojump - 一个快速浏览 Linux 文件系统的高级 “cd” 命令][2]
|
||||
|
||||
在本文中,我们将在 bd 工具的帮助下,用这个简单而有用的工具快速回到 Linux 中的父目录。
|
||||
|
||||
bd 是用于切换文件夹的便利工具,它可以使你快速返回到父目录,而不必重复键入 `cd ../../..` 。 你可以可靠地将其与其他 Linux 命令组合以执行几个日常操作。
|
||||
|
||||
### 如何在 Linux 中安装 bd
|
||||
|
||||
运行下面的命令,使用[ wget 命令][3]下载并安装 bd 到 `/usr/bin/` 中,添加执行权限,并在 `~/.bashrc` 中创建需要的别名:
|
||||
|
||||
```
|
||||
$ wget --no-check-certificate -O /usr/bin/bd https://raw.github.com/vigneshwaranr/bd/master/bd
|
||||
$ chmod +rx /usr/bin/bd
|
||||
$ echo 'alias bd=". bd -si" >> ~/.bashrc
|
||||
$ source ~/.bashrc
|
||||
```
|
||||
|
||||
注意:要启用大小写敏感的目录名匹配,在上面创建的别名中,设置 `-s` 标志而不是 `-si` 标志。
|
||||
|
||||
要启用自动补全支持,运行这些命令:
|
||||
|
||||
```
|
||||
$ sudo wget -O /etc/bash_completion.d/bd https://raw.github.com/vigneshwaranr/bd/master/bash_completion.d/bd
|
||||
$ sudo source /etc/bash_completion.d/bd
|
||||
```
|
||||
|
||||
#### 如何在 Linux 中使用 bd
|
||||
|
||||
假设你目前在这个路径的顶层目录:
|
||||
|
||||
```
|
||||
/media/aaronkilik/Data/Computer Science/Documents/Books/LEARN/Linux/Books/server $
|
||||
```
|
||||
|
||||
你想要快速进入 “Documents” 目录,只要输入:
|
||||
|
||||
```
|
||||
$ bd Documents
|
||||
```
|
||||
|
||||
接着直接进入到 Data 目录,你可以输入:
|
||||
|
||||
```
|
||||
$ bd Data
|
||||
```
|
||||
[
|
||||
![Switch Between Directories Quickly](http://www.tecmint.com/wp-content/uploads/2017/03/Switch-Between-Directories-Quickly.png)
|
||||
][4]
|
||||
|
||||
目录间快速切换
|
||||
|
||||
实际上,bd 让它变得更加直接,你要做的是输入 “bd <开头几个字母>”,比如:
|
||||
|
||||
```
|
||||
$ bd Doc
|
||||
$ bd Da
|
||||
```
|
||||
[
|
||||
![Quickly Switch Directories](http://www.tecmint.com/wp-content/uploads/2017/03/Quickly-Switch-Directories.png)
|
||||
][5]
|
||||
|
||||
快速切换目录
|
||||
|
||||
重要:如果层次结构中有不止一个具有相同名称的目录,bd 将会移动到最接近的目录,而不考虑最接近的父目录,如下面的例子那样。
|
||||
|
||||
例如,在上面的路径中,有两个名称相同的目录 Books,如果你想移动到:
|
||||
|
||||
```
|
||||
/media/aaronkilik/Data/ComputerScience/Documents/Books/LEARN/Linux/Books
|
||||
```
|
||||
|
||||
输入 “bd Books” 会进入:
|
||||
|
||||
```
|
||||
/media/aaronkilik/Data/ComputerScience/Documents/Books
|
||||
```
|
||||
[
|
||||
![Move to 'Books' Directory Quickly](http://www.tecmint.com/wp-content/uploads/2017/03/Move-to-Directory-Quickly.png)
|
||||
][6]
|
||||
|
||||
快速进入 ‘Books’ 目录
|
||||
|
||||
另外,在引号中使用 bd 如 ``bd <letter(s)>`` 会打印出路径而不更改当前目录,所以你可以与其他常见的 Linux 命令,如 [ls][7],[echo][8] 等一起使用 ``bd <letter(s)>` 。
|
||||
|
||||
在下面的例子中,当前在 /var/www/html/internship/assets/filetree 目录中,要打印出绝对路径、详细列出内容、统计目录 html 中所有文件的大小,你不必进入它,只需要键入:
|
||||
|
||||
```
|
||||
$ echo `bd ht`
|
||||
$ ls -l `bd ht`
|
||||
$ du -cs `bd ht`
|
||||
```
|
||||
[
|
||||
![Switch Directory with Listing](http://www.tecmint.com/wp-content/uploads/2017/03/Switch-Directory-with-Listing.png)
|
||||
][9]
|
||||
|
||||
列出切换的目录
|
||||
|
||||
要在 Github 上了解更多关于 bd 的信息:[https://github.com/vigneshwaranr/bd][10]
|
||||
|
||||
就是这样了!在本文中,我们展示了使用 bd 程序[在 Linux 中快速切换文件夹][11]的便捷方法。
|
||||
|
||||
通过下面的反馈栏单发表你的看法。此外,你还知道其他类似的工具么,在评论中让我们知道。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
作者简介:
|
||||
|
||||
Aaron Kili是一名 Linux 和 F.O.S.S 的爱好者,未来的 Linux 系统管理员、网站开发人员,目前是 TecMint 的内容创作者,他喜欢用电脑工作,并乐于分享知识。
|
||||
|
||||
---------------
|
||||
|
||||
via: http://www.tecmint.com/bd-quickly-go-back-to-a-linux-parent-directory/
|
||||
|
||||
作者:[Aaron Kili ][a]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.tecmint.com/author/aaronkili/
|
||||
[1]:http://www.tecmint.com/cd-command-in-linux/
|
||||
[2]:http://www.tecmint.com/autojump-a-quickest-way-to-navigate-linux-filesystem/
|
||||
[3]:http://www.tecmint.com/10-wget-command-examples-in-linux/
|
||||
[4]:http://www.tecmint.com/wp-content/uploads/2017/03/Switch-Between-Directories-Quickly.png
|
||||
[5]:http://www.tecmint.com/wp-content/uploads/2017/03/Quickly-Switch-Directories.png
|
||||
[6]:http://www.tecmint.com/wp-content/uploads/2017/03/Move-to-Directory-Quickly.png
|
||||
[7]:http://www.tecmint.com/tag/linux-ls-command/
|
||||
[8]:http://www.tecmint.com/echo-command-in-linux/
|
||||
[9]:http://www.tecmint.com/wp-content/uploads/2017/03/Switch-Directory-with-Listing.png
|
||||
[10]:https://github.com/vigneshwaranr/bd
|
||||
[11]:http://www.tecmint.com/autojump-a-quickest-way-to-navigate-linux-filesystem/
|
||||
[12]:http://www.tecmint.com/author/aaronkili/
|
||||
[13]:http://www.tecmint.com/10-useful-free-linux-ebooks-for-newbies-and-administrators/
|
||||
[14]:http://www.tecmint.com/free-linux-shell-scripting-books/
|
@ -0,0 +1,99 @@
|
||||
如何在 Ubuntu 中安装 Discord
|
||||
============================================================
|
||||
|
||||
![](https://www.maketecheasier.com/assets/uploads/2017/04/discord-feat.jpg "How to Install Discord on Ubuntu Linuxs")
|
||||
|
||||
|
||||
Discord 是一个非常受欢迎的文字和语音聊天程序。虽然开始了主要面向游戏玩家,但它几乎获得了所有人的了广泛青睐。
|
||||
|
||||
Discord 不仅仅是一个很好的聊天客户端。当你安装它时,你还可以获得其强大的服务端功能,包括电池。游戏玩家和非玩家都可以在几分钟内开启自己的私人聊天服务,这使 Discord 成为团队、公会和各种社区的明显选择。
|
||||
|
||||
Linux 用户经常在游戏世界中被遗忘。但 Discord 并不是这样。它的开发人员也在 Linux 下积极构建并维护其流行聊天平台。Ubuntu 用户拥有更好的功能。Discord 捆绑在方便的 Debian/Ubuntu .deb 包中。
|
||||
|
||||
### 获取并安装软件包
|
||||
|
||||
有几种方法在 Ubuntu 下获取 Discord。你可以都看一下,并选择一个你喜欢的。
|
||||
|
||||
### 依赖
|
||||
|
||||
在 Discord 的下载页面上没有什么关于依赖的内容,但是在 Ubuntu 上安装之前,你需要安装一些依赖。没什么大不了的。打开你的终端,并输入以下命令以获得所需内容:
|
||||
|
||||
```
|
||||
sudo apt install libgconf-2-4 libappindicator1
|
||||
```
|
||||
|
||||
### 图形化安装
|
||||
|
||||
图形化安装会耗时长一点,但是这对 Linux 新手而言更简单。
|
||||
|
||||
![Download Discord for Linux](https://www.maketecheasier.com/assets/uploads/2017/04/discord-download.jpg "Download Discord for Linux")
|
||||
|
||||
首先进入 Discord 的[网站][11]。该网站应该能自动检测到你正在运行的 Linux,并在页面正中建议正确的包。
|
||||
|
||||
如果没有,只需向下滚动一下。页面的下一部分会显示其他可用的下载,而 Linux 包就在那里。
|
||||
|
||||
找到 Linux 的下载链接后,请检查是否选择了 “deb”,然后单击 “Download” 按钮。
|
||||
|
||||
![Ubuntu prompt to install Discord](https://www.maketecheasier.com/assets/uploads/2017/04/discord-install1.jpg "Ubuntu prompt to install Discord")
|
||||
|
||||
浏览器会询问你想要用 Ubuntu 软件安装器打开或者下载文件。你可以选择任意一个,但是自动用软件安装器打开会更快。
|
||||
|
||||
![Ubuntu Software Center Discord Inst all](https://www.maketecheasier.com/assets/uploads/2017/04/discord-install2.jpg "Ubuntu Software Center Discord Inst all")
|
||||
|
||||
下载很快,所以安装程序会立即打开,并允许你安装新下载的软件包。这是一个非常简单的窗口,没有漂亮的图标或很多描述性的文本,所以不要犹豫。这是正常的。单击 “Install” 开始安装。
|
||||
|
||||
安装过程不会耗费太长时间。之后,Discord 就可以使用了。
|
||||
|
||||
### 命令行安装
|
||||
|
||||
懒惰的 Linux 熟手并不在意花哨的 GUI 工具。如果你是这个阵营的人,那么你有一个更直接的命令行选项。
|
||||
|
||||
首先,打开一个终端并进入你的下载目录。在那里可以使用 `wget` 直接下载 .deb 包。
|
||||
|
||||
```
|
||||
cd ~/Downloads
|
||||
wget -O discord-0.0.1.deb https://discordapp.com/api/download?platform=linux&format=deb
|
||||
```
|
||||
|
||||
下载完成后,你可以使用 dpkg 直接安装 .deb 软件包。运行下面的命令:
|
||||
|
||||
```
|
||||
sudo dpkg -i discord-0.0.1.deb
|
||||
```
|
||||
|
||||
### 测试一下
|
||||
|
||||
![Discord icon in Unity](https://www.maketecheasier.com/assets/uploads/2017/04/discord-start-unity.jpg "Discord icon in Unity")
|
||||
|
||||
现在你可以打开软件启动器并搜索 Discord。单击图标运行。
|
||||
|
||||
![Login to Discord on Ubuntu](https://www.maketecheasier.com/assets/uploads/2017/04/discord-login.jpg "Login to Discord on Ubuntu")
|
||||
|
||||
首次启动,你需要创建一个帐户或者登录。做任意一个你需要做的。
|
||||
|
||||
![Discord running on Ubuntu Linux](https://www.maketecheasier.com/assets/uploads/2017/04/discord-running.jpg "Discord running on Ubuntu Linux")
|
||||
|
||||
登录后,你就进入 Discord 了。它会提供一些介绍教程和建议。你可以直接略过开始尝试。欢迎进入你新的 Linux 聊天体验!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.maketecheasier.com/install-discord-ubuntu/
|
||||
|
||||
作者:[ Nick Congleton][a]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://www.maketecheasier.com/author/nickcongleton/
|
||||
[1]:https://www.maketecheasier.com/author/nickcongleton/
|
||||
[2]:https://www.maketecheasier.com/install-discord-ubuntu/#respond
|
||||
[3]:https://www.maketecheasier.com/category/linux-tips/
|
||||
[4]:http://www.facebook.com/sharer.php?u=https%3A%2F%2Fwww.maketecheasier.com%2Finstall-discord-ubuntu%2F
|
||||
[5]:http://twitter.com/share?url=https%3A%2F%2Fwww.maketecheasier.com%2Finstall-discord-ubuntu%2F&text=How+to+Install+Discord+on+Ubuntu+Linux
|
||||
[6]:mailto:?subject=How%20to%20Install%20Discord%20on%20Ubuntu%20Linux&body=https%3A%2F%2Fwww.maketecheasier.com%2Finstall-discord-ubuntu%2F
|
||||
[7]:https://www.maketecheasier.com/faulty-graphics-card-and-the-fix/
|
||||
[8]:https://www.maketecheasier.com/set-power-button-turn-off-display-windows10/
|
||||
[9]:https://support.google.com/adsense/troubleshooter/1631343
|
||||
[10]:https://support.google.com/adsense/troubleshooter/1631343
|
||||
[11]:https://discordapp.com/download
|
Loading…
Reference in New Issue
Block a user