mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-02-10 00:00:29 +08:00
commit
4b8f0f9dc5
171
published/20151117 Linux 101--Get the most out of Systemd.md
Normal file
171
published/20151117 Linux 101--Get the most out of Systemd.md
Normal file
@ -0,0 +1,171 @@
|
||||
Linux 101:最有效地使用 Systemd
|
||||
================================================================================
|
||||
干嘛要这么做?
|
||||
|
||||
- 理解现代 Linux 发行版中的显著变化;
|
||||
- 看看 Systemd 是如何取代 SysVinit 的;
|
||||
- 搞定单元(unit)和新的 journal 日志。
|
||||
|
||||
吐槽邮件、人身攻击、死亡威胁——Lennart Poettering,Systemd 的作者,对收到这些东西早就习以为常了。这位 Red Hat 公司的员工之前在 Google+ 上怒斥 FOSS 社区([http://tinyurl.com/poorlennart][1])的本质,悲痛且失望地表示:“那真是个令人恶心的地方”。他着重指出 Linus Torvalds 在邮件列表上言辞极其刻薄的帖子,并谴责这位内核的领导者为在线讨论定下基调,并使得人身攻击及贬抑之辞成为常态。
|
||||
|
||||
但为何 Poettering 会遭受如此多的憎恨?为何就这么个搞搞开源软件的人要忍受这等愤怒?答案就在于他的软件的重要性。如今大多数发行版中,Systemd 是 Linux 内核发起的第一个程序,并且它还扮演多种角色。它会启动系统服务、处理用户登录,每隔特定的时间执行一些任务,还有很多很多。它在不断地成长,并逐渐成为 Linux 的某种“基础系统”——提供系统启动和发行版维护所需的所有工具。
|
||||
|
||||
如今,在以下几点上 Systemd 颇具争议:它逃避了一些已经确立的 Unix 传统,例如纯文本的日志文件;它被看成是个“大一统”的项目,试图接管一切;它还是我们这个操作系统的支柱的重要革新。然而大多数主流发行版已经接受了(或即将接受)它,因此它就活了下来。而且它确实是有好处的:更快地启动,更简单地管理那些有依赖的服务程序,提供强大且安全的日志系统等。
|
||||
|
||||
因此在这篇教程中,我们将探索 Systemd 的特性,并向您展示如何最有效地利用这些特性。即便您此刻并不是这款软件的粉丝,读完本文后您至少可以更加了解和适应它。
|
||||
|
||||
![](http://narf-archive.com/pix/bd0fb252416206158627fb0b1bff9b4779dca13f.gif)
|
||||
|
||||
*这部没正经的动画片来自[http://tinyurl.com/m2e7mv8][2],它把 Systemd 塑造成一只狂暴的动物,吞噬它路过的一切。大多数批评者的言辞可不像这只公仔一样柔软。*
|
||||
|
||||
### 启动及服务 ###
|
||||
|
||||
大多数主流发行版要么已经采用 Systemd,要么即将在下个发布中采用(如 Debian 和 Ubuntu)。在本教程中,我们使用 Fedora 21(该发行版已经是 Systemd 的优秀实验场地)的一个预览版进行演示,但不论您用哪个发行版,要用到的命令和注意事项都应该是一样的。这是 Systemd 的一个加分点:它消除了不同发行版之间许多细微且琐碎的区别。
|
||||
|
||||
在终端中输入 `ps ax | grep systemd`,看到第一行,其中的数字 **1** 表示它的进程号是1,也就是说它是 Linux 内核发起的第一个程序。因此,内核一旦检测完硬件并组织好了内存,就会运行 `/usr/lib/systemd/systemd` 可执行程序,这个程序会按顺序依次发起其他程序。(在还没有 Systemd 的日子里,内核会去运行 `/sbin/init`,随后这个程序会在名为 SysVinit 的系统中运行其余的各种启动脚本。)
|
||||
|
||||
Systemd 的核心是一个叫*单元* (unit)的概念,它是一些存有关于服务(service)(在运行在后台的程序)、设备、挂载点、和操作系统其他方面信息的配置文件。Systemd 的其中一个目标就是简化这些事物之间的相互作用,因此如果你有程序需要在某个挂载点被创建或某个设备被接入后开始运行,Systemd 可以让这一切正常运作起来变得相当容易。(在没有 Systemd 的日子里,要使用脚本来把这些事情调配好,那可是相当丑陋的。)要列出您 Linux 系统上的所有单元,输入以下命令:
|
||||
|
||||
systemctl list-unit-files
|
||||
|
||||
现在,`systemctl` 是与 Systemd 交互的主要工具,它有不少选项。在单元列表中,您会注意到这儿有一些格式化:被使能(enabled)的单元显示为绿色,被禁用(disabled)的显示为红色。标记为“static”的单元不能直接启用,它们是其他单元所依赖的对象。若要限制输出列表只包含服务,使用以下命令:
|
||||
|
||||
systemctl list-unit-files --type=service
|
||||
|
||||
注意,一个单元显示为“enabled”,并不等于对应的服务正在运行,而只能说明它可以被开启。要获得某个特定服务的信息,以 GDM (Gnome Display Manager) 为例,输入以下命令:
|
||||
|
||||
systemctl status gdm.service
|
||||
|
||||
这条命令提供了许多有用的信息:一段给人看的服务描述、单元配置文件的位置、启动的时间、进程号,以及它所从属的 CGroups(用以限制各组进程的资源开销)。
|
||||
|
||||
如果您去查看位于 `/usr/lib/systemd/system/gdm.service` 的单元配置文件,您可以看到各种选项,包括要被运行的二进制文件(“ExecStart”那一行),相冲突的其他单元(即不能同时进入运行的单元),以及需要在本单元执行前进入运行的单元(“After”那一行)。一些单元有附加的依赖选项,例如“Requires”(必要的依赖)和“Wants”(可选的依赖)。
|
||||
|
||||
此处另一个有趣的选项是:
|
||||
|
||||
Alias=display-manager.service
|
||||
|
||||
当您启动 **gdm.service** 后,您将可以通过 `systemctl status display-manager.service` 来查看它的状态。当您知道有*显示管理程序* (display manager)在运行并想对它做点什么,但您不关心那究竟是 GDM,KDM,XDM 还是什么别的显示管理程序时,这个选项会非常有用。
|
||||
|
||||
![Image](http://www.linuxvoice.com/wp-content/uploads/2015/10/status-large.jpg)
|
||||
|
||||
*使用 systemctl status 命令后面跟一个单元名,来查看对应的服务有什么情况。*
|
||||
|
||||
### “目标(target)”锁定 ###
|
||||
|
||||
如果您在 `/usr/lib/systemd/system` 目录中输入 `ls` 命令,您将看到各种以 `.target` 结尾的文件。*启动目标* (target)是一种将多个单元聚合在一起以致于将它们同时启动的方式。例如,对大多数类 Unix 操作系统而言有一种“多用户(multi-user)”状态,意思是系统已被成功启动,后台服务正在运行,并且已准备好让一个或多个用户登录并工作——至少在文本模式下。(其他状态包括用于进行管理工作的单用户(single-user)状态,以及用于机器关机的重启(reboot)状态。)
|
||||
|
||||
如果您打开 **multi-user.target** 文件一探究竟,您可能期待看到的是一个要被启动的单元列表。但您会发现这个文件内部几乎空空如也——其实,一个服务会通过 **WantedBy** 选项让自己成为启动目标的依赖。因此如果您去打开 **avahi-daemon.service**, **NetworkManager.service** 及其他 **.service** 文件看看,您将在 Install 段看到这一行:
|
||||
|
||||
WantedBy=multi-user.target
|
||||
|
||||
因此,切换到多用户启动目标会使能(enable)那些包含上述语句的单元。还有其他一些启动目标可用(例如 **emergency.target** 提供一个紧急情况使用的 shell,以及 **halt.target** 用于机器关机),您可以用以下方式轻松地在它们之间切换:
|
||||
|
||||
systemctl isolate emergency.target
|
||||
|
||||
在许多方面,这些都很像 SysVinit 中的*运行级* (runlevel),如文本模式的 **multi-user.target** 类似于第3运行级,**graphical.target** 类似于第5运行级,**reboot.target** 类似于第6运行级,诸如此类。
|
||||
|
||||
![Image](http://www.linuxvoice.com/wp-content/uploads/2015/10/unit-large.jpg)
|
||||
|
||||
**与传统的脚本相比,单元配置文件也许看起来很陌生,但并不难以理解。**
|
||||
|
||||
### 开启与停止 ###
|
||||
|
||||
现在您也许陷入了沉思:我们已经看了这么多,但仍没看到如何停止和开启服务!这其实是有原因的。从外部看,Systemd 也许很复杂,像野兽一般难以驾驭。因此在您开始摆弄它之前,有必要从宏观的角度看看它是如何工作的。实际用来管理服务的命令非常简单:
|
||||
|
||||
systemctl stop cups.service
|
||||
systemctl start cups.service
|
||||
|
||||
(若某个单元被禁用了,您可以先通过 `systemctl enable` 加上该单元名的方式将其使能。这种做法会为该单元创建一个符号链接,并将其放置在当前启动目标的 `.wants` 目录下,这些 `.wants` 目录在`/etc/systemd/system` 文件夹中。)
|
||||
|
||||
还有两个有用的命令是 `systemctl restart` 和 `systemctl reload`,后面接单元名。后者用于让单元重新加载它的配置文件。Systemd 的绝大部分都有良好的文档,因此您可以查看手册 (`man systemctl`) 了解每条命令的细节。
|
||||
|
||||
### 定时器单元:取代 Cron ###
|
||||
|
||||
除了系统初始化和服务管理,Systemd 还染指了其他方面。在很大程度上,它能够完成 **cron** 的工作,而且可以说是以更灵活的方式(并带有更易读的语法)。**cron** 是一个以规定时间间隔执行任务的程序——例如清除临时文件,刷新缓存等。
|
||||
|
||||
如果您再次进入 `/usr/lib/systemd/system` 目录,您会看到那儿有多个 `.timer` 文件。用 `less` 来查看这些文件,您会发现它们与 `.service` 和 `.target` 文件有着相似的结构,而区别在于 `[Timer]` 段。举个例子:
|
||||
|
||||
[Timer]
|
||||
OnBootSec=1h
|
||||
OnUnitActiveSec=1w
|
||||
|
||||
**OnBootSec** 选项告诉 Systemd 在系统启动一小时后启动这个单元。第二个选项的意思是:自那以后每周启动这个单元一次。关于定时器有大量选项您可以设置,输入 `man systemd.time` 查看完整列表。
|
||||
|
||||
Systemd 的时间精度默认为一分钟。也就是说,它会在设定时刻的一分钟内运行单元,但不一定精确到那一秒。这么做是基于电源管理方面的原因,但如果您需要一个没有任何延时且精确到毫秒的定时器,您可以添加以下一行:
|
||||
|
||||
AccuracySec=1us
|
||||
|
||||
另外, **WakeSystem** 选项(可以被设置为 true 或 false)决定了定时器是否可以唤醒处于休眠状态的机器。
|
||||
|
||||
![Image](http://www.linuxvoice.com/wp-content/uploads/2015/10/systemd_gui-large.jpg)
|
||||
|
||||
*有一个 Systemd 的图形界面程序,即便它已有多年未被积极维护。*
|
||||
|
||||
### 日志文件:向 journald 问声好 ###
|
||||
|
||||
Systemd 的第二个主要部分是 journal 。这是个日志系统,类似于 syslog 但也有些显著区别。如果您是个 Unix 日志管理模式的粉丝,准备好出离愤怒吧:这是个二进制日志,因此您不能使用常规的命令行文本处理工具来解析它。这个设计决定不出意料地在网上引起了激烈的争论,但它的确有些优点。例如,日志可以被更系统地组织,带有更多的元数据,因此可以更容易地根据可执行文件名和进程号等过滤出信息。
|
||||
|
||||
要查看整个 journal,输入以下命令:
|
||||
|
||||
journalctl
|
||||
|
||||
像许多其他的 Systemd 命令一样,该命令将输出通过管道的方式引向 `less` 程序,因此您可以使用空格键向下滚动,键入`/`(斜杠)查找,以及其他熟悉的快捷键。您也能在此看到少许颜色,像红色的警告及错误信息。
|
||||
|
||||
以上命令会输出很多信息。为了限制其只输出本次启动的消息,使用如下命令:
|
||||
|
||||
journalctl -b
|
||||
|
||||
这就是 Systemd 大放异彩的地方!您想查看自上次启动以来的全部消息吗?试试 **journalctl -b -1** 吧。再上一次的?用 **-2** 替换 **-1** 吧。那自某个具体时间,例如2014年10月24日16:38以来的呢?
|
||||
|
||||
journalctl -b --since=”2014-10-24 16:38”
|
||||
|
||||
即便您对二进制日志感到遗憾,那依然是个有用的特性,并且对许多系统管理员来说,构建类似的过滤器比起写正则表达式而言容易多了。
|
||||
|
||||
我们已经可以根据特定的时间来准确查找日志了,那可以根据特定程序吗?对单元而言,试试这个:
|
||||
|
||||
journalctl -u gdm.service
|
||||
|
||||
(注意:这是个查看 X server 产生的日志的好办法。)那根据特定的进程号?
|
||||
|
||||
journalctl _PID=890
|
||||
|
||||
您甚至可以请求只看某个可执行文件产生的消息:
|
||||
|
||||
journalctl /usr/bin/pulseaudio
|
||||
|
||||
若您想将输出的消息限制在某个优先级,可以使用 **-p** 选项。该选项参数为 0 的话只会显示紧急消息(也就是说,是时候向 **$DEITY** 祈求保佑了)(LCTT 译注: $DEITY 是一个计算机方面的幽默,DEITY 是指广义上的“神”,$前缀表示这是一个变量),为 7 的话会显示所有消息,包括调试消息。请查看手册 (`man journalctl`) 获取更多关于优先级的信息。
|
||||
|
||||
值得指出的是,您也可以将多个选项结合在一起,若想查看在当前启动中由 GDM 服务输出的优先级数小于等于 3 的消息,请使用下述命令:
|
||||
|
||||
journalctl -u gdm.service -p 3 -b
|
||||
|
||||
最后,如果您仅仅想打开一个随 journal 持续更新的终端窗口,就像在没有 Systemd 时使用 `tail` 命令实现的那样,输入 `journalctl -f` 就好了。
|
||||
|
||||
![](http://www.linuxvoice.com/wp-content/uploads/2015/10/journal-large.jpg)
|
||||
|
||||
*二进制日志并不流行,但 journal 的确有它的优点,如非常方便的信息查找及过滤。*
|
||||
|
||||
### 没有 Systemd 的生活?###
|
||||
|
||||
如果您就是完全不能接受 Systemd,您仍然有一些主流发行版中的选择。尤其是 Slackware,作为历史最为悠久的发行版,目前还没有做出改变,但它的主要开发者并没有将其从未来规划中移除。一些不出名的发行版也在坚持使用 SysVinit 。
|
||||
|
||||
但这又将持续多久呢?Gnome 正越来越依赖于 Systemd,其他的主流桌面环境也会步其后尘。这也是引起 BSD 社区一阵恐慌的原因:Systemd 与 Linux 内核紧密相连,导致在某种程度上,桌面环境正变得越来越不可移植。一种折衷的解决方案也许会以 Uselessd ([http://uselessd.darknedgy.net][3]) 的形式到来:一种裁剪版的 Systemd,纯粹专注于启动和监控进程,而不消耗整个基础系统。
|
||||
|
||||
![Image](http://www.linuxvoice.com/wp-content/uploads/2015/10/gentoo-large.jpg)
|
||||
|
||||
若您不喜欢 Systemd,可以尝试一下 Gentoo 发行版,它将 Systemd 作为初始化工具的一种选择,但并不强制用户使用 Systemd。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.linuxvoice.com/linux-101-get-the-most-out-of-systemd/
|
||||
|
||||
作者:[Mike Saunders][a]
|
||||
译者:[Ricky-Gong](https://github.com/Ricky-Gong)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.linuxvoice.com/author/mike/
|
||||
[1]:http://tinyurl.com/poorlennart
|
||||
[2]:http://tinyurl.com/m2e7mv8
|
||||
[3]:http://uselessd.darknedgy.net/
|
@ -1,20 +1,20 @@
|
||||
如何更新ISPConfig 3 SSL证书
|
||||
如何更新 ISPConfig 3 SSL 证书
|
||||
================================================================================
|
||||
本教程描述了如何再ISPConfig 3控制面板中更新SSL证书。有两个可选的方法:
|
||||
本教程描述了如何在 ISPConfig 3控制面板中更新 SSL 证书。有两个可选的方法:
|
||||
|
||||
- 用OpenSSL创建一个新的OpenSSL证书和CSR。
|
||||
- 用ISPConfig updater更新SSL证书
|
||||
- 用 OpenSSL 创建一个新的 OpenSSL 证书和 CSR。
|
||||
- 用 ISPConfig updater 更新 SSL 证书
|
||||
|
||||
我将会用手工的方法更新ssl证书。
|
||||
我将从用手工的方法更新 SSL 证书开始。
|
||||
|
||||
### 1)用OpenSSL创建一个新的ISPConfig 3 SSL 证书 ###
|
||||
### 1)用 OpenSSL 创建一个新的 ISPConfig 3 SSL 证书 ###
|
||||
|
||||
用root用户登录你的服务器。在创建一个新的SSL证书之前,备份现有的。SSL证书是安全敏感的,因此我将它存储在/root/目录下。
|
||||
用 root 用户登录你的服务器。在创建一个新的 SSL 证书之前,先备份现有的。SSL 证书是安全敏感的,因此我将它存储在 /root/ 目录下。
|
||||
|
||||
tar pcfz /root/ispconfig_ssl_backup.tar.gz /usr/local/ispconfig/interface/ssl
|
||||
chmod 600 /root/ispconfig_ssl_backup.tar.gz
|
||||
|
||||
> 现在创建一个新的SSL证书密钥,证书请求(csr)和自签发证书。
|
||||
> 现在创建一个新的 SSL 证书密钥,证书请求(CSR)和自签发证书。
|
||||
|
||||
cd /usr/local/ispconfig/interface/ssl
|
||||
openssl genrsa -des3 -out ispserver.key 4096
|
||||
@ -25,13 +25,13 @@
|
||||
mv ispserver.key ispserver.key.secure
|
||||
mv ispserver.key.insecure ispserver.key
|
||||
|
||||
重启apache来加载新的SSL证书
|
||||
重启 apache 来加载新的 SSL 证书
|
||||
|
||||
service apache2 restart
|
||||
|
||||
### 2)用ISPConfig安装器来更新SSL证书 ###
|
||||
### 2)用 ISPConfig 安装器来更新 SSL 证书 ###
|
||||
|
||||
另一个获取新的SSL证书的替代方案是使用ISPConfig更新脚本。下载ISPConfig到/tmp目录下,解压包并运行脚本。
|
||||
另一个获取新的 SSL 证书的替代方案是使用 ISPConfig 更新脚本。下载 ISPConfig 到 /tmp 目录下,解压包并运行脚本。
|
||||
|
||||
cd /tmp
|
||||
wget http://www.ispconfig.org/downloads/ISPConfig-3-stable.tar.gz
|
||||
@ -39,11 +39,11 @@
|
||||
cd ispconfig3_install/install
|
||||
php -q update.php
|
||||
|
||||
更新脚本会在更新时询问下面的额问题:
|
||||
更新脚本会在更新时询问下面的问题:
|
||||
|
||||
Create new ISPConfig SSL certificate (yes,no) [no]:
|
||||
|
||||
这里回答“yes”,SSL证书创建对话框就会启动。
|
||||
这里回答“yes”,SSL 证书创建对话框就会启动。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
@ -51,7 +51,7 @@ via: http://www.faqforge.com/linux/how-to-renew-the-ispconfig-3-ssl-certificate/
|
||||
|
||||
作者:[Till][a]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
@ -0,0 +1,79 @@
|
||||
提升 emacs 生产力的十大最佳插件
|
||||
================================================================================
|
||||
|
||||
一年前的这个时候,我想要寻找[将 Vim 打造成一个成熟的全功能的 IDE][1] 的最好插件。有趣的是,那篇文章的很多评论提到了 Emacs 已经大部分有了这些内置插件,已经是一个很棒的 IDE 了。尽管我对 Emacs 的难以置信的多样化表示赞同,它依旧不是一个可以开箱即用的高级编辑器。还好,其庞大的插件库可以解决这个问题。但在过多的选择中,有时很难弄清该如何入手。因此,现在让我试着收集一个不可或缺的插件的简短列表,来提升你使用 Emacs 时的工作效率。 虽然我主要侧重于与编程相关的生产力提升,但是这些插件对所有人或不同用途都是有用的。
|
||||
|
||||
### 1. Ido-mode ###
|
||||
|
||||
![](https://c2.staticflickr.com/6/5718/23311895573_c1fb34337c_c.jpg)
|
||||
|
||||
Ido 或许是对新手最有用的一个插件,Ido 的意思是交互式工作(interactively do)。它取代了大部分的用花哨字符匹配菜单的枯燥提示。好比说,它用列出了当前目录所有文件的列表来取代了常规的打开文件提示符。输入一些字符,Ido 将尝试匹配最合适的文件。它通过可视化让你的操作变得更容易,这也是一个快速遍历所有文件都有相同前缀的文件夹的方法。
|
||||
|
||||
### 2. Smex ###
|
||||
|
||||
![](https://c2.staticflickr.com/2/1517/23310442314_2a22a60c34_c.jpg)
|
||||
|
||||
它不算最著名的一个、但却是一个替代 Ido-mode 的好选择:Smex 可以优雅的替代普通的`M-x`提示符,灵感大部分来自于 Ido-mode。它也给调用`M-x`后输入的命令带来了同样的交互搜索能力。它简单而有效,是一个为常用操作提升效率的最好方法。
|
||||
|
||||
### 3. Auto Complete ###
|
||||
|
||||
![](https://c2.staticflickr.com/6/5794/23643004900_3042f77952_c.jpg)
|
||||
|
||||
知道这个插件的存在之前,我在 Emacs 里面有一半的时间花在敲击 `M-/` 来补完单词上。现在,我有一个漂亮的弹出菜单可以为我做自动补全。无须多说,我们都需要它。
|
||||
|
||||
### 4. YASnippet ###
|
||||
|
||||
![](https://c2.staticflickr.com/2/1688/23830403072_0d8df6ef4c_b.jpg)
|
||||
|
||||
这是真正的程序员必备利器。总有一些代码片段会让我们觉得我们一辈子都在写它。对我来说,就是调试 PHP 时不断输入的 `var_dump(...);exit;`。经过一段时间一遍又一遍的输入`var_dump(...);exit;`,我觉得我可以预先把其做成录制好的、方便用到的代码片段。使用 YASnippets,可以很容易导入代码片段文件或者自己做个。之后,只要按下一个 tab 键,就可以将一个小的关键词扩展成一大段预先写好的代码,然后可以很方便地在里面修改。
|
||||
|
||||
### 5. Org-mode ###
|
||||
|
||||
![](https://c2.staticflickr.com/6/5687/23570808789_d683c949e4.jpg)
|
||||
|
||||
免责声明,我最近才开始使用 Org-mode,但它已经深深的吸引了我。从我看过数以百计的文章来说,Org-mode 可以改变你的生活。它背后的想法很简单:它是一种用普通文本做简单备注的模式,可以很容易地在任务列表和各种数据中转来转去,并进行一些比如按优先级或到期日期的过滤,或设置一个重复日期。然而,虽然思路简单,但你可以做到很多,用各种方法用于各种用途。与其去看一个长长的介绍,我觉得你可以去读读[现有教程][2],有很多视频可以看,自己去体验一下 Org-mode 是多么强大。
|
||||
|
||||
### 6. Helm ###
|
||||
|
||||
![](https://c2.staticflickr.com/2/1489/23310442334_5e6db22b79_c.jpg)
|
||||
|
||||
一些使用者喜欢它,但是其他人没有这么大的使用热情。我是后者的一部分。但在拥有这样一个庞大的追随者的情况下,是不能不提到它的。Helm 旨在完全变换你的 Emacs 使用体验。简单来说,Helm 是一个在 Emacs 中帮助你快速找到一个文件或命令的框架。根据你的输入,它将尝试使用词语自动完成来引导你将大脑的念头变为行动。起初感觉有点奇怪,但对一些人来说,Helm 本身就是一个信仰。虽然我不是 Helm 的粉丝,我欣赏 helm-occur 这一个伟大的工具可以在一个大文档搜索字符串并且在一个单独的缓冲区显示所有匹配结果,以便很容易在它们之间跳转。如果你正在寻找一个快速演示来了解 Helm 能做什么,我推荐[这篇文章][3]。
|
||||
|
||||
### 7. ace-jump-mode ###
|
||||
|
||||
![](https://c2.staticflickr.com/2/1710/23856168871_6df1faa565_c.jpg)
|
||||
|
||||
这是另一个有一大群追随者的插件,我正在试图成为 ace-jump-mode 的粉丝。掌握这个插件,你会体验到超越鼠标感受。简单描述一下,通过你选择的快捷方式触发 ace-jump-mode 后,你会被提示输入字符。输入一个字符,所有以该字符开头的单词中的那个字符就会替换成一个唯一字符并被高亮。输入一个屏幕上的高亮字符,你的光标会直接跳转到高亮显示的那个词。我不得不承认,这让我使用它时有点反应不过来,但是,一旦你掌握它,它将显著提升你在一个文档里的移动速度。(LCTT 译注:用文字描述比较困难,如截图中,你输入的是一个“i”,然后屏幕中所有以“i”开头的单词中的那个“i”都被替换成了从 a 到 z 的字符,并高亮;你可以输入这些高亮的字符直接跳转到那个位置。)
|
||||
|
||||
### 8. find-file-in-project ###
|
||||
|
||||
![](https://c2.staticflickr.com/2/1492/23570808809_96ec8454a9_c.jpg)
|
||||
|
||||
如果你喜欢 Sublime text 以及它可以用非常方便的`Ctrl-p`模糊搜索来打开一个项目中的任何文件的功能,你将会喜欢上 find-file-in-project (简称 ffip)的。使用设置指定了您的版本控制的根文件夹后,您可以轻松地调出一个很酷的文本条,通过快速扫描和搜索你的代码,来根据你输入的名称找到匹配的文件。我喜欢把它绑定到键盘上的 F6 键。如果你不知道整个目录从上到下的复杂结构,这很简单,而且非常易用。
|
||||
|
||||
### 9. Flymake ###
|
||||
|
||||
![](https://c2.staticflickr.com/6/5708/23310442354_cbba657ed3.jpg)
|
||||
|
||||
对 IDE 的爱好者来说,我认为语法检查器是 IDE 最强大的特性之一,它非常适合初学者和方便了那些疲惫的程序员。感谢 Flymake,Emacs 用户也可以享受到了语法检查器。因为我工作中用 PHP 很多,Flymake 就不需要任何额外的配置。当我写代码的时候,它会自动检查我的代码和高亮任何一个包含问题的行。对于编译语言,Flymake 将寻找一个用于检查你的代码的 Makefile。真神奇。
|
||||
|
||||
### 10. electric-pair ###
|
||||
|
||||
最后,但并非最不重要,在我看来,electric-pair 是最简单但最强大的插件之一。它会自动关闭你输入的括号。它起初看起来并不是很有用,但相信我,在被寻找配对括号折磨几百次之后,你会很高兴有这么一个插件,可以确保你所有的表达式的括号都是一一对应的。
|
||||
|
||||
总结一下,Emacs 是一个奇妙的工具。这可不是一个令人惊讶的说法。试试这些插件,看着你的效率直线飙升吧。这个列表当然不是详尽的列表。如果你想贡献你的建议,请在评论中这样做。我自己一直在寻找新的插件来试着发现 Emacs 的新体验。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://xmodulo.com/best-plugins-to-increase-productivity-on-emacs.html
|
||||
|
||||
作者:[Adrien Brochard][a]
|
||||
译者:[zky001](https://github.com/zky001)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://xmodulo.com/author/adrien
|
||||
[1]:http://xmodulo.com/turn-vim-full-fledged-ide.html
|
||||
[2]:http://orgmode.org/worg/org-tutorials/
|
||||
[3]:http://tuhdo.github.io/helm-intro.html
|
236
published/20151229 Grub 2--Heal your bootloader.md
Normal file
236
published/20151229 Grub 2--Heal your bootloader.md
Normal file
@ -0,0 +1,236 @@
|
||||
Grub 2:拯救你的 bootloader
|
||||
================================================================================
|
||||
|
||||
**没有什么事情比 bootloader 坏掉更让气人的了。充分发挥 Grub 2 的作用,让 bootloader 安分工作吧。**
|
||||
|
||||
为什么这么说?
|
||||
|
||||
- Grub 2 是最受欢迎的 bootloader ,几乎用在所有 Linux 发行版上。
|
||||
- bootloader 是一个至关重要的软件,但是非常容易损坏。
|
||||
- Grub 2 是兼具扩展性和灵活性的一款引导加载程序,提供了大量可定制选项。
|
||||
|
||||
Grub 2 是一款精彩的功能强大的软件。它不是 bootloader 界的一枝独秀,但却最受欢迎,几乎所有主要的桌面发行版都在使用它。 Grub 的工作有两个。首先,它用一个菜单展示计算机上所有已经安装的操作系统供你选择。其次,当你从启动菜单中选择了一个 Linux 操作系统, Grub 便加载这个 Linux 的内核。
|
||||
|
||||
你知道,如果使用 Linux ,你就离不开 bootloader 。然而它却是 Linux 发行版内部最鲜为人知的部分。在这篇文章里,我们将带你熟悉 Grub 2 一些著名的特性,强化你相关技能,使你在 bootloader 跑飞的时候能够自行处理。
|
||||
|
||||
Grub 2 最重要的部分是一堆文本文件和两个脚本文件。首先需要了解的是 `/etc/default/grub` 。这是一个文本文件,你可以在里面设置通用配置变量和 Grub 2 菜单(见下方 “常见用户设置” )的其它特性。
|
||||
|
||||
Grub 2 另一个重要的部分是 `/etc/grub.d` 文件夹。定义每个菜单项的所有脚本都放置在这里。这些脚本的名称必须有两位的数字前缀。其目的是,在构建 Grub 2 菜单时定义脚本的执行顺序以及相应菜单项的顺序。文件 `00_header` 首先被读取,负责解析 `/etc/default/grub` 配置文件。然后是 Linux 内核的菜单项,位于 `10_linux` 文件中。这个脚本在默认的 `/boot` 分区为每个内核创建一个正规菜单项和一个恢复菜单项。
|
||||
|
||||
紧接着的是为第三方应用所用的脚本,如 `30_os-prober` 和 `40_custom` 。 **os-prober** 脚本为内核和其它分区里的操作系统创建菜单项。它能识别安装的 Linux、 Windows、 BSD 以及 Mac OS X 。 如果你的硬盘布局比较独特,使得 **os-prober** 无法找到已经安装的发行版,你可以在 `40_custom` 文件(见下方 “添加自定义菜单项”)中添加菜单项。
|
||||
|
||||
**Grub** 2 不需要你手动维护你的启动选项的配置文件:取而代之的是使用 `grub2-mkconfig` 命令产生 `/boot/grub/grub.cfg` 文件。这个功能会解析 `/etc/grub.d` 目录中的脚本以及 `/etc/default/grub` 设置文件来定义你的设置情况。
|
||||
|
||||
###图形化的引导修复###
|
||||
|
||||
多亏了 Boot Repair 应用,只需要点击按钮,Grub 2 许许多多的问题都能轻易解决。这个漂亮小巧的应用有一个直观的用户界面,可以扫描并识别多种硬盘布局和分区方案,还能发现并正确识别安装在其中的操作系统。这个应用可以处理传统计算机里的主引导记录(Master Boot Record) (MBR),也可以处理新型 UEFI 计算机中的 GUID 分区表(GUID Partition Table)(GPT)。
|
||||
|
||||
Boot Repair 最简单的使用方式是安装到 Live Ubuntu 会话中。在一个 bootloader 损坏的机器上启动 Ubuntu Live 发行版,先通过添加它的 PPA 版本库来安装 Boot Repair ,命令如下:
|
||||
|
||||
sudo add-apt-repository ppa:yannubuntu/Boot Repair
|
||||
|
||||
然后刷新版本库列表:
|
||||
|
||||
sudo apt-get update
|
||||
|
||||
安装应用,如下:
|
||||
|
||||
sudo apt-get install -y Boot Repair
|
||||
|
||||
安装完毕后就启动应用。在显示它的界面(由一对按键组成)之前将会扫描你的硬盘。根据工具的指示,只需按下 Recommended Repair(推荐的修复)按钮,即可修复大部分坏掉的 bootloader 。修复 bootloader 之后,这个工具会输出一个短小的 URL ,你应该把它记录下来。这个 URL 包含了硬盘详尽的信息:分区信息以及重要的 Grub 2 文件(如 `/etc/default/grub` 和 `/boot/grub/grub.cfg` )的内容。如果工具不能解决 bootloader 的问题,可以把你这个 URL 共享在你的发行版的论坛上,让其他人可以分析你的硬盘布局以便给你建议。
|
||||
|
||||
![](http://www.linuxvoice.com/wp-content/uploads/2015/10/boot-repair-large.jpg)
|
||||
|
||||
*Boot Repair 也可以让你定制 Grub 2 的选项。*
|
||||
|
||||
### Bootloader 急救 ###
|
||||
|
||||
Grub 2 引导问题会让系统处于几种不同状态。屏幕(如你所想,本该显示 bootloader 菜单的地方)所展示的文本会指示出系统的当前状态。如果系统中止于 **grub>** 提示符,表明 Grub 2 模块已经被加载,但是找不到 **grub.cfg** 文件。当前是完全版的 Grub 2 命令行 shell,你可以通过多种方式解决此问题。如果你看到的是 **grub rescue>** 提示符,表明 bootloader 不能找到 Grub 2 模块或者找不到任何引导文件( boot files )。然而,如果你的屏幕只显示 ‘GRUB’ 一词,表明 bootloader 找不到通常位于主引导记录( Master Boot Record )里的最基本的信息。
|
||||
|
||||
你可以通过使用 live CD 或者在 Grub 2 shell 中修正此类错误。如果你够幸运, bootloader 出现了 **grub>** 提示符,你就能获得 Grub 2 shell 的支配权,来帮助你排错。
|
||||
|
||||
接下来几个命令工作在 **grub>** 和 **grub rescue>** 提示符下。 **set pager=1** 命令设置显示分页( pager ),防止文本在屏幕上一滚而过。你还可以使用 **ls** 命令列出 Grub 识别出的所有分区,如下:
|
||||
|
||||
grub> ls
|
||||
(hd0) (hd0,msdos5) (hd0,msdos6) (hd1,msdos1)
|
||||
|
||||
如你所见,这个命令列出分区的同时一并列出了分区表方案(即 msdos)。
|
||||
|
||||
你还可以在每个分区上面使用 **ls** 来查找你的根文件系统:
|
||||
|
||||
grub> ls (hd0,5)/
|
||||
lost+found/ var/ etc/ media/ bin/ initrd.gz
|
||||
boot/ dev/ home/ selinux/ srv/ tmp/ vmlinuz
|
||||
|
||||
你可以不写上分区名的 **msdos** 部分。同样,如果你忘记了尾部的斜杠( trailing slash )只输入 `ls (hd0,5)` ,那你将获得分区的信息,比如文件系统类型、总体大小和最后修改时间。如果你有多个分区,可以使用 `cat` 读取 `/etc/issue` 文件中的内容,来确定发行版,格式如 `cat (hd0,5)/etc/issue` 。
|
||||
|
||||
假设你在 **(hd0,5)** 中找到根文件系统,请确保它包含 `/boot/grub` 目录,以及你想引导进入的内核镜像,如 **vmlinuz-3.13.0-24-generic** 。此时输入以下命令:
|
||||
|
||||
grub> set root=(hd0,5)
|
||||
grub> linux /boot/vmlinuz-3.13.0-24-generic root=/dev/sda5
|
||||
grub> initrd /boot/initrd.img-3.13.0-24-generic
|
||||
|
||||
第一个命令把 Grub 指向我们想引导进入的发行版所在的分区。接着第二个命令告知 Grub 内核镜像在分区中的位置,以及根文件系统的位置。最后一行设置虚拟文件系统( initial ramdisk )文件的位置。你可以使用 tab 补全功能补全内核名字和虚拟文件系统( initrd: initial ramdisk )的名字,节省时间和精力。
|
||||
|
||||
输入完毕,在下一个 **grub>** 提示符后输入 `boot` , Grub 将会引导进入指定的操作系统。
|
||||
|
||||
如果你在 **grub rescue>** 提示符下,情况会有些许不同。因为 bootloader 未能够找到并加载任何必需的模块,你需要手动添加这些模块:
|
||||
|
||||
grub rescue> set root=(hd0,5)
|
||||
grub rescue> insmod (hd0,5)/boot/grub/normal.mod
|
||||
grub rescue> normal
|
||||
grub> insmod linux
|
||||
|
||||
如上所示,跟之前一样,使用 `ls` 命令列出所有分区之后,使用 `set` 命令标记起来。然后添加 **normal** 模块,此模块激活时将会恢复到标准 **grub>** 模式。如果 linux 模块没加载,接下来的命令会进行添加。如果这个模块已经加载,你可以跟之前一样,把引导加载程序指向内核镜像和虚拟文件系统( initrd )文件,然后使用 `boot` 启动发行版,完美收官。
|
||||
|
||||
一旦成功启动发行版,别忘了为 Grub 重新产生新的配置文件,使用
|
||||
|
||||
grub-mkconfig -o /boot/grub/grub.cfg
|
||||
|
||||
命令。你还需要往 MBR 里安装一份 bootloader 的拷贝,使用
|
||||
|
||||
sudo grub2-install /dev/sda
|
||||
|
||||
命令。
|
||||
|
||||
![](http://www.linuxvoice.com/wp-content/uploads/2015/10/grub2-cfg-large.jpg)
|
||||
|
||||
*想要禁用 `/etc/grub.d` 目录下的脚本,你只需移除其可执行位,比如使用 `chmod -x /etc/grub.d/20_memtest86+` 就能将 ‘Memory Test’ 选项从菜单中移除。*
|
||||
|
||||
### Grub 2 和 UEFI ###
|
||||
|
||||
在支持 UEFI 的机器(最近几年上市的机器大部分都是)调试坏掉的 Grub 2 增加了另一复杂的层次。恢复安装在 UEFI 机器上的 **Grub 2** 的和安装在非 UEFI 机器上的并没多大区别,只是新的固件处理方式不一样,从而导致了很多种恢复结果。
|
||||
|
||||
对于基于 UEFI 的系统,不要在 MBR 上安装任何东西。相反,你要在 EFI 系统分区(EFI System Partition)( ESP )里安装 Linux EFI bootloader,并且借助工具把它设置为 EFI 的默认启动程序,这个工具对于 Linux 用户是 `efibootmgr` ,对于 window 用户则是 `bcdedit` 。
|
||||
|
||||
照目前情况看,在安装任何与 Windows 8 兼容的主流桌面 Linux 发行版前,应该正确安装好 Grub 2。然而,如果 bootloader 损坏,你可以使用 live 发行版修复机器。在启动 live 介质之时,请确保是以 UEFI 模式启动。计算机每个可移动驱动器的启动菜单将会有两个: 一个普通的和一个以 EFI 标记的。使用后者会用到 **/sys/firmware/efi/** 文件中的 EFI 变量。
|
||||
|
||||
在 live 环境中,挂载教程前面所提的安装挂掉系统的根文件系统。除此之外,还需要挂载 ESP 分区。假设分区是 **/dev/sda1** ,你可以如下所示挂载:
|
||||
|
||||
sudo mount /dev/sda1 /mnt/boot/efi
|
||||
|
||||
接着在 chroot 到安装完毕的发行版前之前,使用 `modprobe efivars` 加载 **efivars** 模块。
|
||||
|
||||
在这里, Fedora 用户可以使用如下命令重新安装 bootloader
|
||||
|
||||
yum reinstall grub2-efi shim
|
||||
|
||||
但在此之前,需要使用
|
||||
|
||||
grub2-mkconfig -o /boot/grub2/grub.cfg
|
||||
|
||||
来产生新的配置文件。 Ubuntu 用户则改用以下命令
|
||||
|
||||
apt-get install --reinstall grub-efi-amd64
|
||||
|
||||
一旦 bootloader 正确就位,退出 chroot ,卸载所有分区,重启到 Grub 2 菜单。
|
||||
|
||||
### 伙计,我的 Grub 哪去了? ###
|
||||
|
||||
Grub 2 最好的特性是可以随时重新安装。因此,当其它像 Windows 之类的系统用它们自己的 bootloader 替换后,导致 Grub 2 丢失,你可以使用 live 发行版,寥寥数步即可重装 Grub 。假设你在 `/dev/sda5` 安装了一个发行版,若要重装 Grub ,你只需首先使用以下命令为发行版创建一个挂载目录:
|
||||
|
||||
sudo mkdir -p /mnt/distro
|
||||
|
||||
然后挂载分区,如下:
|
||||
|
||||
mount /dev/sda5 /mnt/distro
|
||||
|
||||
接着就能重装 Grub 了,如下:
|
||||
|
||||
grub2-install --root-directory=/mnt/distro /dev/sda
|
||||
|
||||
这个命令会改写 `/dev/sda` 设备上的 MBR 信息,指向当前 Linux 系统,并重写一些 Grub 2 文件,如 **grubenv** 和 **device.map** 。
|
||||
|
||||
另一个问题常见于装有多个发行版的计算机上。当你安装了新的 Linux 发行版,它的 bootloader 应当要能找到所有已经安装的发行版。一旦不行,只要引导进入新安装的发行版,并运行
|
||||
|
||||
grub2-mkconfig
|
||||
|
||||
在运行这个命令之前,请确保启动菜单中缺失的发行版的 root 分区已经挂载。如果你想添加的发行版有单独的 `/root` 和 `/home` 分区,在运行 `grub2-mkconfig` 之前,只需挂载包含 `/root` 的分区。
|
||||
|
||||
虽然 Grub 2 能够找到大部分发行版,但是在 Ubuntu 中尝试添加安装的 Fedora 系统需要额外的一个步骤。如果你以默认设置安装了 Fedora ,则发行版的安装器已经创建了 LVM 分区。此时你需要使用发行版的包管理系统安装 **lvm2** 驱动,如下
|
||||
|
||||
sudo apt-get install lvm2
|
||||
|
||||
才能使得 Grub 2 的 `os-prober` 脚本能够找到并将 Fedora 添加进启动菜单。
|
||||
|
||||
### 常见用户设置 ###
|
||||
|
||||
Grub 2 有很多可配置变量。 这里有一些 `/etc/default/grub` 文件中你最可能会修改到的常见变量。 **GRUB_DEFAULT** 变量指定默认的启动项,可以设置为数字值,比如 0 ,表示第一个菜单项,或者设置为 “saved” ,将指向上一次启动时选中的菜单项。 **GRUB\_TIMEOUT** 变量指定启动默认菜单项之前的停留时间。 **GRUB\_CMDLINE\_LINUX** 列出了要传递给所有 Linux 菜单项的内核命令行参数。
|
||||
|
||||
如果 **GRUB\_DISABLE\_RECOVERY** 变量设置为 **true** ,那么将不生成恢复模式菜单项。这些菜单项会以单用户模式启动发行版,这种模式下允许你利用命令行工具修复系统。 **GRUB_GFXMODE** 变量同样有用,它指定了菜单上文本显示的分辨率,它可以设置为你的显卡所支持的任何数值。
|
||||
|
||||
![](http://www.linuxvoice.com/wp-content/uploads/2015/10/grub2-cli-large.jpg)
|
||||
|
||||
*Grub 2 有个命令行模式,通过在 bootloader 菜单上按 C 进入。*
|
||||
|
||||
### 彻底的修复 ###
|
||||
|
||||
如果 `grub2-install` 命令不能正常运作,使得你无法引导进入 Linux ,你需要完整地重装以及重新配置 bootloader 。为此目的,需要用到强大的 **chroot** 功能将运行环境从 live CD 环境切换至我们想修复的 Linux 的安装位置。任何拥有 **chroot** 工具的 Linux live CD 都可以实现这个目的。不过需要确保 live 介质的系统架构和硬盘上系统的架构一致。因此当你希望 **chroot** 到 64 位系统,你必须使用 amd64 live 发行版。
|
||||
|
||||
启动进入 live 发行版之后,首先需要检查机器上的分区。使用 `fdisk -l` 列出磁盘上所有分区,记录你想修复的 Grub 2 系统所在的分区。
|
||||
|
||||
假设我们希望从安装在 `/dev/sda5` 中的发行版中恢复 bootloader 。启动终端使用如下命令挂载分区:
|
||||
|
||||
sudo mount /dev/sda5 /mnt
|
||||
|
||||
此时需要绑定(bind)Grub 2 bootloader 需要进入的目录,以便检测其它操作系统:
|
||||
|
||||
$ sudo mount --bind /dev /mnt/dev
|
||||
$ sudo mount --bind /dev/pts /mnt/dev/pts
|
||||
$ sudo mount --bind /proc /mnt/proc
|
||||
$ sudo mount --bind /sys /mnt/sys
|
||||
|
||||
此时可以离开 live 环境进入安装在 **/dev/sda5** 分区中的发行版了,通过 **chroot** :
|
||||
|
||||
$ sudo chroot /mnt /bin/bash
|
||||
|
||||
现在可以安装、检测、以及升级 Grub 了,跟之前一样,使用
|
||||
|
||||
sudo grub2-install /dev/sda
|
||||
|
||||
命令来重装 bootloader 。因为 **grub2-install** 命令不能创建**grub.cfg** 文件,需要手动创建,如下
|
||||
|
||||
sudo grub-mkconfig -o /boot/grub/grub.cfg
|
||||
|
||||
这样应该就可以了。现在你就有了 Grub 2 的一份全新拷贝,罗列了机器上所有的操作系统和发行版。在重启电脑之前,你需要依次退出 chroot 系统,卸载所有分区,如下所示:
|
||||
|
||||
$ exit
|
||||
$ sudo umount /mnt/sys
|
||||
$ sudo umount /mnt/proc
|
||||
$ sudo umount /mnt/dev/pts
|
||||
$ sudo umount /mnt/dev
|
||||
$ sudo umount /mnt
|
||||
|
||||
现在你可以安全地重启电脑了,而它应该会回退到 Grub 2 的控制之中,你已经修好了这个 bootloader。
|
||||
|
||||
### 添加自定义菜单项 ###
|
||||
|
||||
如果希望往 bootloader 菜单里添加菜单项,你需要在 **40_custom** 文件里添加一个启动段( boot stanza )。例如,你可以使用它展示一个菜单项来启动安装在可移动 USB 驱动里的 Linux 发行版。假设你的 USB 驱动器是 **sdb1** ,并且 vmlinuz 内核镜像和虚拟文件系统( initrd )都位于根 (/)目录下,在 **40_custom** 文件中添加以下内容:
|
||||
|
||||
menuentry “Linux on USB” {
|
||||
set root=(hd1,1)
|
||||
linux /vmlinuz root=/dev/sdb1 ro quiet splash
|
||||
initrd /initrd.img
|
||||
}
|
||||
|
||||
相比使用设备和分区名,使用它们的 UUID 可以获得更精确结果,比如
|
||||
|
||||
set root=UUID=54f22dd7-eabe
|
||||
|
||||
使用
|
||||
|
||||
sudo blkid
|
||||
|
||||
来获得所有已连接的驱动器和分区的 UUID 。你还可以为你磁盘上没被 os-prober 脚本找到的发行版添加菜单项,只要你知道该发行版的安装位置以及其内核和虚拟文件系统( initrd )的位置即可。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.linuxvoice.com/grub-2-heal-your-bootloader/
|
||||
|
||||
作者:[Mayank Sharma][a]
|
||||
译者:[soooogreen](https://github.com/soooogreen)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://www.linuxvoice.com/author/mayank/
|
@ -1,98 +0,0 @@
|
||||
Translating by icecoobe.
|
||||
|
||||
What’s the Best File System for My Linux Install?
|
||||
================================================================================
|
||||
![](https://www.maketecheasier.com/assets/uploads/2015/05/file-systems-feature-image.jpg)
|
||||
|
||||
File systems: they’re not the most exciting things in the world, but important nonetheless. In this article we’ll go over the popular choices for file systems on Linux – what they’re about, what they can do, and who they’re for.
|
||||
|
||||
### Ext4 ###
|
||||
|
||||
![file-systems-ext4](https://www.maketecheasier.com/assets/uploads/2015/05/file-systems-ext4.png)
|
||||
|
||||
If you’ve ever installed Linux before, chances are you’ve seen the “Ext4” during installation. There’s a good reason for that: it’s the file system of choice for just about every Linux distribution available right now. Sure, there are some that choose other options, but there’s no denying that Extended 4 is the file system of choice for almost all Linux users.
|
||||
|
||||
#### What can it do? ####
|
||||
|
||||
Extended 4 has all of the goodness that you’ve come to expect from past file system iterations (Ext2/Ext3) but with enhancements. There’s a lot to dig into, but here are the best parts of what Ext4 can do for you:
|
||||
|
||||
- file system journaling
|
||||
- journal checksums
|
||||
- multi-block file allocation
|
||||
- backwards compatibility support for Extended 2 and 3
|
||||
- persistent pre-allocation of free space
|
||||
- improved file system checking (over previous versions)
|
||||
- and of course, support for larger files
|
||||
|
||||
#### Who is it for? ####
|
||||
|
||||
Extended 4 is for those looking for a super-stable foundation to build upon, or for those looking for something that just works. This file system won’t snapshot your system; it doesn’t even have the greatest SSD support, but If your needs aren’t too extravagant, you’ll get along with it just fine.
|
||||
|
||||
### BtrFS ###
|
||||
|
||||
![file-systems-btrFS](https://www.maketecheasier.com/assets/uploads/2015/05/file-systems-btrFS-e1450065697580.png)
|
||||
|
||||
The B-tree file system (also known as butterFS) is a file system for Linux developed by Oracle. It’s a new file system and is in heavy development stages. The Linux community considers it unstable to use for some. The core principle of BtrFS is based around the principle of copy-on-write. **Copy on write** basically means that the system has one single copy of a bit of data before the data has been written. When the data has been written, a copy of it is made.
|
||||
|
||||
#### What can it do? ####
|
||||
|
||||
Besides supporting copy-on-write, BtrFS can do many other things – so many things, in fact, that it’d take forever to list everything. Here are the most notable features: The file system supports read-only snapshots, file cloning, subvolumes, transparent compression, offline file system check, in-place conversion from ext3 and 4 to Btrfs, online defragmentation, anew has support for RAID 0, RAID 1, RAID 5, RAID 6 and RAID 10.
|
||||
|
||||
#### Who is it for? ####
|
||||
|
||||
The developers of BtrFS have promised that this file system is the next-gen replacement for other file systems out there. That much is true, though it certainly is a work in progress. There are many killer features for advanced users and basic users alike (including great performance on SSDs). This file system is for those looking to get a little bit more out of their file system and who want to try the copy-on-write way of doing things.
|
||||
|
||||
### XFS ###
|
||||
|
||||
![file-systems-xfs](https://www.maketecheasier.com/assets/uploads/2015/05/file-systems-xfs.jpg)
|
||||
|
||||
Developed and created by Silicon Graphics, XFS is a high-end file system that specializes in speed and performance. XFS does extremely well when it comes to parallel input and output because of its focus on performance. The XFS file system can handle massive amounts of data, so much in fact that some users of XFS have close to 300+ terabytes of data.
|
||||
|
||||
#### What can it do? ####
|
||||
|
||||
XFS is a well-tested data storage file system created for high performance operations. Its features include:
|
||||
|
||||
- striped allocation of RAID arrays
|
||||
- file system journaling
|
||||
- variable block sizes
|
||||
- direct I/O
|
||||
- guaranteed-rate I/O
|
||||
- snapshots
|
||||
- online defragmentation
|
||||
- online resizing
|
||||
|
||||
#### Who is it for? ####
|
||||
|
||||
XFS is for those looking for a rock-solid file solution. The file system has been around since 1993 and has only gotten better and better with time. If you have a home server and you’re perplexed on where you should go with storage, consider XFS. A lot of the features the file system comes with (like snapshots) could aid in your file storage system. It’s not just for servers, though. If you’re a more advanced user and you’re interested in a lot of what was promised in BtrFS, check out XFS. It does a lot of the same stuff and doesn’t have stability issues.
|
||||
|
||||
### Reiser4 ###
|
||||
|
||||
![file-system-riser4](https://www.maketecheasier.com/assets/uploads/2015/05/file-system-riser4.gif)
|
||||
|
||||
Reiser4, the successor to ReiserFS, is a file system created and developed by Namesys. The creation of Reiser4 was backed by the Linspire project as well as DARPA. What makes Reiser4 special is its multitude of transaction models. There isn’t one single way data can be written; instead, there are many.
|
||||
|
||||
#### What can it do? ####
|
||||
|
||||
Reiser4 has the unique ability to use different transaction models. It can use the copy-on-write model (like BtrFS), write-anywhere, journaling, and the hybrid transaction model. It has a lot of improvements upon ReiserFS, including better file system journaling via wandering logs, better support for smaller files, and faster handling of directories. Reiser4 has a lot to offer. There are a lot more features to talk about, but suffice it to say it’s a huge improvement over ReiserFS with tons of added features.
|
||||
|
||||
#### Who is it for? ####
|
||||
|
||||
Resier4 is for those looking to stretch one file system across multiple use-cases. Maybe you want to set up one machine with copy-on-write, another with write-anywhere, and another with hybrid transaction, and you don’t want to use different types of file systems to accomplish this task. Reiser4 is perfect for this type of use-case.
|
||||
|
||||
### Conclusion ###
|
||||
|
||||
There are many file systems available on Linux. Each serves a unique purpose for unique users looking to solve different problems.This post focuses on the most popular choices for the platform. There is no doubt there are other choices out there for other use-cases.
|
||||
|
||||
What’s your favorite file system to use on Linux? Tell us why below!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.maketecheasier.com/best-file-system-linux/
|
||||
|
||||
作者:[Derrik Diener][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://www.maketecheasier.com/author/derrikdiener/
|
@ -1,126 +0,0 @@
|
||||
zpl1025
|
||||
Install Android On BQ Aquaris Ubuntu Phone In Linux
|
||||
================================================================================
|
||||
![How to install Android on Ubuntu Phone](http://itsfoss.itsfoss.netdna-cdn.com/wp-content/uploads/2015/11/Install-Android-on-Ubuntu-Phone.jpg)
|
||||
|
||||
If you happen to own the first Ubuntu phone and want to **replace Ubuntu with Android on the bq Aquaris e4.5**, this post is going to help you.
|
||||
|
||||
There can be plenty of reasons why you might want to remove Ubuntu and use the mainstream Android OS. One of the foremost reason is that the OS itself is at an early stage and intend to target developers and enthusiasts. Whatever may be your reason, installing Android on bq Aquaris is a piece of cake, thanks to the tools provided by bq.
|
||||
|
||||
Let’s see what to do we need to install Android on bq Aquaris.
|
||||
|
||||
### Prerequisite ###
|
||||
|
||||
- Working Internet connection to download Android factory image and install tools for flashing Android
|
||||
- USB data cable
|
||||
- A system running Linux
|
||||
|
||||
This tutorial is performed using Ubuntu 15.10. But the steps should be applicable to most other Linux distributions.
|
||||
|
||||
### Replace Ubuntu with Android in bq Aquaris e4.5 ###
|
||||
|
||||
#### Step 1: Download Android firmware ####
|
||||
|
||||
First step is to download the Android image for bq Aquaris e4.5. Good thing is that it is available from the bq’s support website. You can download the firmware, around 650 MB in size, from the link below:
|
||||
|
||||
- [Download Android for bq Aquaris e4.5][1]
|
||||
|
||||
Yes, you would get OTA updates with it. At present the firmware version is 2.0.1 which is based on Android Lolipop. Over time, there could be a new firmware based on Marshmallow and then the above link could be outdated.
|
||||
|
||||
I suggest to check the [bq support page and download][2] the latest firmware from there.
|
||||
|
||||
Once downloaded, extract it. In the extracted directory, look for **MT6582_Android_scatter.txt** file. We shall be using it later.
|
||||
|
||||
#### Step 2: Download flash tool ####
|
||||
|
||||
bq has provided its own flash tool, Herramienta MTK Flash Tool, for easier installation of Android or Ubuntu on the device. You can download the tool from the link below:
|
||||
|
||||
- [Download MTK Flash Tool][3]
|
||||
|
||||
Since the flash tool might be upgraded in future, you can always get the latest version of flash tool from the [bq support page][4].
|
||||
|
||||
Once downloaded extract the downloaded file. You should see an executable file named **flash_tool** in it. We shall be using it later.
|
||||
|
||||
#### Step 3: Remove conflicting packages (optional) ####
|
||||
|
||||
If you are using recent version of Ubuntu or Ubuntu based Linux distributions, you may encounter “BROM ERROR : S_UNDEFINED_ERROR (1001)” later in this tutorial.
|
||||
|
||||
To avoid this error, you’ll have to uninstall conflicting package. Use the commands below:
|
||||
|
||||
sudo apt-get remove modemmanager
|
||||
|
||||
Restart udev service with the command below:
|
||||
|
||||
sudo service udev restart
|
||||
|
||||
Just to check for any possible side effects on kernel module cdc_acm, run the command below:
|
||||
|
||||
lsmod | grep cdc_acm
|
||||
|
||||
If the output of the above command is an empty list, you’ll have to reinstall this kernel module:
|
||||
|
||||
sudo modprobe cdc_acm
|
||||
|
||||
#### Step 4: Prepare to flash Android ####
|
||||
|
||||
Go to the downloaded and extracted flash tool directory (in step 2). Use command line for this purpose because you’ll have to use the root privileges here.
|
||||
|
||||
Presuming that you saved it in the Downloads directory, use the command below to go to this directory (in case you do not know how to navigate between directories in command line).
|
||||
|
||||
cd ~/Downloads/SP_Flash*
|
||||
|
||||
After that use the command below to run the flash tool as root:
|
||||
|
||||
sudo ./flash_tool
|
||||
|
||||
You’ll see a window popped as the one below. Don’t bother about Download Agent field, it will be automatically filled. Just focus on Scatter-loading field.
|
||||
|
||||
![Replace Ubuntu with Android](http://itsfoss.itsfoss.netdna-cdn.com/wp-content/uploads/2015/11/Install-Android-bq-aquaris-Ubuntu-1.jpeg)
|
||||
|
||||
Remember we talked about **MT6582_Android_scatter.txt** in step 1? This text file is in the extracted directory of the Andriod firmware you downloaded in step 1. Click on Scatter-loading (in the above picture) and point to MT6582_Android_scatter.txt file.
|
||||
|
||||
When you do that, you’ll see several green lines like the one below:
|
||||
|
||||
![Install-Android-bq-aquaris-Ubuntu-2](http://itsfoss.itsfoss.netdna-cdn.com/wp-content/uploads/2015/11/Install-Android-bq-aquaris-Ubuntu-2.jpeg)
|
||||
|
||||
#### Step 5: Flashing Android ####
|
||||
|
||||
We are almost ready. Switch off your phone and connect it to your computer via a USB cable.
|
||||
|
||||
Select Firmware Upgrade from the dropdown and after that click on the big download button.
|
||||
|
||||
![flash Android with Ubuntu](http://itsfoss.itsfoss.netdna-cdn.com/wp-content/uploads/2015/11/Install-Android-bq-aquaris-Ubuntu.jpeg)
|
||||
|
||||
If everything is correct, you should see a flash status in the bottom of the tool:
|
||||
|
||||
![Replace Ubuntu with Android](http://itsfoss.itsfoss.netdna-cdn.com/wp-content/uploads/2015/11/Install-Android-bq-aquaris-Ubuntu-3.jpeg)
|
||||
|
||||
When the procedure is successfully completed, you’ll see a notification like this:
|
||||
|
||||
![Successfully flashed Android on bq qauaris Ubuntu Phone](http://itsfoss.itsfoss.netdna-cdn.com/wp-content/uploads/2015/11/Install-Android-bq-aquaris-Ubuntu-4.jpeg)
|
||||
|
||||
Unplug your phone and power it on. You should see a white screen with AQUARIS written in the middle and at bottom, “powered by Android” would be displayed. It might take upto 10 minutes before you could configure and start using Android.
|
||||
|
||||
Note: If something goes wrong in the process, Press power, volume up, volume down button together and boot in to fast boot mode. Turn off again and connect the cable again. Repeat the process of firmware upgrade. It should work.
|
||||
|
||||
### Conclusion ###
|
||||
|
||||
Thanks to the tools provided, it becomes easier to **flash Android on bq Ubuntu Phone**. Of course, you can use the same steps to replace Android with Ubuntu. All you need is to download Ubuntu firmware instead of Android.
|
||||
|
||||
I hope this tutorial helped you to replace Ubuntu with Android on your bq phone. If you have questions or suggestions, feel free to ask in the comment section below.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://itsfoss.com/install-android-ubuntu-phone/
|
||||
|
||||
作者:[Abhishek][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://itsfoss.com/author/abhishek/
|
||||
[1]:https://storage.googleapis.com/otas/2014/Smartphones/Aquaris_E4.5_L/2.0.1_20150623-1900_bq-FW.zip
|
||||
[2]:http://www.bq.com/gb/support/aquaris-e4-5
|
||||
[3]:https://storage.googleapis.com/otas/2014/Smartphones/Aquaris_E4.5/Ubuntu/Web%20version/Web%20version/SP_Flash_Tool_exe_linux_v5.1424.00.zip
|
||||
[4]:http://www.bq.com/gb/support/aquaris-e4-5-ubuntu-edition
|
@ -1,125 +0,0 @@
|
||||
Install Android On BQ Aquaris Ubuntu Phone In Linux
|
||||
================================================================================
|
||||
![How to install Android on Ubuntu Phone](http://itsfoss.itsfoss.netdna-cdn.com/wp-content/uploads/2015/11/Install-Android-on-Ubuntu-Phone.jpg)
|
||||
|
||||
If you happen to own the first Ubuntu phone and want to **replace Ubuntu with Android on the bq Aquaris e4.5**, this post is going to help you.
|
||||
|
||||
There can be plenty of reasons why you might want to remove Ubuntu and use the mainstream Android OS. One of the foremost reason is that the OS itself is at an early stage and intend to target developers and enthusiasts. Whatever may be your reason, installing Android on bq Aquaris is a piece of cake, thanks to the tools provided by bq.
|
||||
|
||||
Let’s see what to do we need to install Android on bq Aquaris.
|
||||
|
||||
### Prerequisite ###
|
||||
|
||||
- Working Internet connection to download Android factory image and install tools for flashing Android
|
||||
- USB data cable
|
||||
- A system running Linux
|
||||
|
||||
This tutorial is performed using Ubuntu 15.10. But the steps should be applicable to most other Linux distributions.
|
||||
|
||||
### Replace Ubuntu with Android in bq Aquaris e4.5 ###
|
||||
|
||||
#### Step 1: Download Android firmware ####
|
||||
|
||||
First step is to download the Android image for bq Aquaris e4.5. Good thing is that it is available from the bq’s support website. You can download the firmware, around 650 MB in size, from the link below:
|
||||
|
||||
- [Download Android for bq Aquaris e4.5][1]
|
||||
|
||||
Yes, you would get OTA updates with it. At present the firmware version is 2.0.1 which is based on Android Lolipop. Over time, there could be a new firmware based on Marshmallow and then the above link could be outdated.
|
||||
|
||||
I suggest to check the [bq support page][2] and download the latest firmware from there.
|
||||
|
||||
Once downloaded, extract it. In the extracted directory, look for **MT6582_Android_scatter.txt** file. We shall be using it later.
|
||||
|
||||
#### Step 2: Download flash tool ####
|
||||
|
||||
bq has provided its own flash tool, Herramienta MTK Flash Tool, for easier installation of Android or Ubuntu on the device. You can download the tool from the link below:
|
||||
|
||||
- [Download MTK Flash Tool][3]
|
||||
|
||||
Since the flash tool might be upgraded in future, you can always get the latest version of flash tool from the [bq support page][4].
|
||||
|
||||
Once downloaded extract the downloaded file. You should see an executable file named **flash_tool** in it. We shall be using it later.
|
||||
|
||||
#### Step 3: Remove conflicting packages (optional) ####
|
||||
|
||||
If you are using recent version of Ubuntu or Ubuntu based Linux distributions, you may encounter “BROM ERROR : S_UNDEFINED_ERROR (1001)” later in this tutorial.
|
||||
|
||||
To avoid this error, you’ll have to uninstall conflicting package. Use the commands below:
|
||||
|
||||
sudo apt-get remove modemmanager
|
||||
|
||||
Restart udev service with the command below:
|
||||
|
||||
sudo service udev restart
|
||||
|
||||
Just to check for any possible side effects on kernel module cdc_acm, run the command below:
|
||||
|
||||
lsmod | grep cdc_acm
|
||||
|
||||
If the output of the above command is an empty list, you’ll have to reinstall this kernel module:
|
||||
|
||||
sudo modprobe cdc_acm
|
||||
|
||||
#### Step 4: Prepare to flash Android ####
|
||||
|
||||
Go to the downloaded and extracted flash tool directory (in step 2). Use command line for this purpose because you’ll have to use the root privileges here.
|
||||
|
||||
Presuming that you saved it in the Downloads directory, use the command below to go to this directory (in case you do not know how to navigate between directories in command line).
|
||||
|
||||
cd ~/Downloads/SP_Flash*
|
||||
|
||||
After that use the command below to run the flash tool as root:
|
||||
|
||||
sudo ./flash_tool
|
||||
|
||||
You’ll see a window popped as the one below. Don’t bother about Download Agent field, it will be automatically filled. Just focus on Scatter-loading field.
|
||||
|
||||
![Replace Ubuntu with Android](http://itsfoss.itsfoss.netdna-cdn.com/wp-content/uploads/2015/11/Install-Android-bq-aquaris-Ubuntu-1.jpeg)
|
||||
|
||||
Remember we talked about **MT6582_Android_scatter.txt** in step 1? This text file is in the extracted directory of the Andriod firmware you downloaded in step 1. Click on Scatter-loading (in the above picture) and point to MT6582_Android_scatter.txt file.
|
||||
|
||||
When you do that, you’ll see several green lines like the one below:
|
||||
|
||||
![Install-Android-bq-aquaris-Ubuntu-2](http://itsfoss.itsfoss.netdna-cdn.com/wp-content/uploads/2015/11/Install-Android-bq-aquaris-Ubuntu-2.jpeg)
|
||||
|
||||
#### Step 5: Flashing Android ####
|
||||
|
||||
We are almost ready. Switch off your phone and connect it to your computer via a USB cable.
|
||||
|
||||
Select Firmware Upgrade from the dropdown and after that click on the big download button.
|
||||
|
||||
![flash Android with Ubuntu](http://itsfoss.itsfoss.netdna-cdn.com/wp-content/uploads/2015/11/Install-Android-bq-aquaris-Ubuntu.jpeg)
|
||||
|
||||
If everything is correct, you should see a flash status in the bottom of the tool:
|
||||
|
||||
![Replace Ubuntu with Android](http://itsfoss.itsfoss.netdna-cdn.com/wp-content/uploads/2015/11/Install-Android-bq-aquaris-Ubuntu-3.jpeg)
|
||||
|
||||
When the procedure is successfully completed, you’ll see a notification like this:
|
||||
|
||||
![Successfully flashed Android on bq qauaris Ubuntu Phone](http://itsfoss.itsfoss.netdna-cdn.com/wp-content/uploads/2015/11/Install-Android-bq-aquaris-Ubuntu-4.jpeg)
|
||||
|
||||
Unplug your phone and power it on. You should see a white screen with AQUARIS written in the middle and at bottom, “powered by Android” would be displayed. It might take upto 10 minutes before you could configure and start using Android.
|
||||
|
||||
Note: If something goes wrong in the process, Press power, volume up, volume down button together and boot in to fast boot mode. Turn off again and connect the cable again. Repeat the process of firmware upgrade. It should work.
|
||||
|
||||
### Conclusion ###
|
||||
|
||||
Thanks to the tools provided, it becomes easier to **flash Android on bq Ubuntu Phone**. Of course, you can use the same steps to replace Android with Ubuntu. All you need is to download Ubuntu firmware instead of Android.
|
||||
|
||||
I hope this tutorial helped you to replace Ubuntu with Android on your bq phone. If you have questions or suggestions, feel free to ask in the comment section below.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://itsfoss.com/install-android-ubuntu-phone/
|
||||
|
||||
作者:[Abhishek][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://itsfoss.com/author/abhishek/
|
||||
[1]:https://storage.googleapis.com/otas/2014/Smartphones/Aquaris_E4.5_L/2.0.1_20150623-1900_bq-FW.zip
|
||||
[2]:http://www.bq.com/gb/support/aquaris-e4-5
|
||||
[3]:https://storage.googleapis.com/otas/2014/Smartphones/Aquaris_E4.5/Ubuntu/Web%20version/Web%20version/SP_Flash_Tool_exe_linux_v5.1424.00.zip
|
||||
[4]:http://www.bq.com/gb/support/aquaris-e4-5-ubuntu-edition
|
@ -1,3 +1,4 @@
|
||||
#name1e5s Translating
|
||||
8 things to do after installing openSUSE Leap 42.1
|
||||
================================================================================
|
||||
![Credit: Metropolitan Transportation/Flicrk](http://images.techhive.com/images/article/2015/11/things-to-do-100626947-primary.idge.jpg)
|
||||
|
@ -1,3 +1,4 @@
|
||||
[Translating by cposture 16-01-14]
|
||||
* * *
|
||||
|
||||
# GCC-Inline-Assembly-HOWTO
|
||||
|
@ -1,277 +0,0 @@
|
||||
[Translating by cposture 15-12-31]
|
||||
Part 6 - LFCS: Assembling Partitions as RAID Devices – Creating & Managing System Backups
|
||||
================================================================================
|
||||
Recently, the Linux Foundation launched the LFCS (Linux Foundation Certified Sysadmin) certification, a shiny chance for system administrators everywhere to demonstrate, through a performance-based exam, that they are capable of performing overall operational support on Linux systems: system support, first-level diagnosing and monitoring, plus issue escalation, when required, to other support teams.
|
||||
|
||||
![Linux Foundation Certified Sysadmin – Part 6](http://www.tecmint.com/wp-content/uploads/2014/10/lfcs-Part-6.png)
|
||||
|
||||
Linux Foundation Certified Sysadmin – Part 6
|
||||
|
||||
The following video provides an introduction to The Linux Foundation Certification Program.
|
||||
|
||||
注:youtube 视频
|
||||
<iframe width="720" height="405" frameborder="0" allowfullscreen="allowfullscreen" src="//www.youtube.com/embed/Y29qZ71Kicg"></iframe>
|
||||
|
||||
This post is Part 6 of a 10-tutorial series, here in this part, we will explain How to Assemble Partitions as RAID Devices – Creating & Managing System Backups, that are required for the LFCS certification exam.
|
||||
|
||||
### Understanding RAID ###
|
||||
|
||||
The technology known as Redundant Array of Independent Disks (RAID) is a storage solution that combines multiple hard disks into a single logical unit to provide redundancy of data and/or improve performance in read / write operations to disk.
|
||||
|
||||
However, the actual fault-tolerance and disk I/O performance lean on how the hard disks are set up to form the disk array. Depending on the available devices and the fault tolerance / performance needs, different RAID levels are defined. You can refer to the RAID series here in Tecmint.com for a more detailed explanation on each RAID level.
|
||||
|
||||
- RAID Guide: [What is RAID, Concepts of RAID and RAID Levels Explained][1]
|
||||
|
||||
Our tool of choice for creating, assembling, managing, and monitoring our software RAIDs is called mdadm (short for multiple disks admin).
|
||||
|
||||
---------------- Debian and Derivatives ----------------
|
||||
# aptitude update && aptitude install mdadm
|
||||
|
||||
----------
|
||||
|
||||
---------------- Red Hat and CentOS based Systems ----------------
|
||||
# yum update && yum install mdadm
|
||||
|
||||
----------
|
||||
|
||||
---------------- On openSUSE ----------------
|
||||
# zypper refresh && zypper install mdadm #
|
||||
|
||||
#### Assembling Partitions as RAID Devices ####
|
||||
|
||||
The process of assembling existing partitions as RAID devices consists of the following steps.
|
||||
|
||||
**1. Create the array using mdadm**
|
||||
|
||||
If one of the partitions has been formatted previously, or has been a part of another RAID array previously, you will be prompted to confirm the creation of the new array. Assuming you have taken the necessary precautions to avoid losing important data that may have resided in them, you can safely type y and press Enter.
|
||||
|
||||
# mdadm --create --verbose /dev/md0 --level=stripe --raid-devices=2 /dev/sdb1 /dev/sdc1
|
||||
|
||||
![Creating RAID Array](http://www.tecmint.com/wp-content/uploads/2014/10/Creating-RAID-Array.png)
|
||||
|
||||
Creating RAID Array
|
||||
|
||||
**2. Check the array creation status**
|
||||
|
||||
After creating RAID array, you an check the status of the array using the following commands.
|
||||
|
||||
# cat /proc/mdstat
|
||||
or
|
||||
# mdadm --detail /dev/md0 [More detailed summary]
|
||||
|
||||
![Check RAID Array Status](http://www.tecmint.com/wp-content/uploads/2014/10/Check-RAID-Array-Status.png)
|
||||
|
||||
Check RAID Array Status
|
||||
|
||||
**3. Format the RAID Device**
|
||||
|
||||
Format the device with a filesystem as per your needs / requirements, as explained in [Part 4][2] of this series.
|
||||
|
||||
**4. Monitor RAID Array Service**
|
||||
|
||||
Instruct the monitoring service to “keep an eye” on the array. Add the output of mdadm –detail –scan to /etc/mdadm/mdadm.conf (Debian and derivatives) or /etc/mdadm.conf (CentOS / openSUSE), like so.
|
||||
|
||||
# mdadm --detail --scan
|
||||
|
||||
![Monitor RAID Array](http://www.tecmint.com/wp-content/uploads/2014/10/Monitor-RAID-Array.png)
|
||||
|
||||
Monitor RAID Array
|
||||
|
||||
# mdadm --assemble --scan [Assemble the array]
|
||||
|
||||
To ensure the service starts on system boot, run the following commands as root.
|
||||
|
||||
**Debian and Derivatives**
|
||||
|
||||
Debian and derivatives, though it should start running on boot by default.
|
||||
|
||||
# update-rc.d mdadm defaults
|
||||
|
||||
Edit the /etc/default/mdadm file and add the following line.
|
||||
|
||||
AUTOSTART=true
|
||||
|
||||
**On CentOS and openSUSE (systemd-based)**
|
||||
|
||||
# systemctl start mdmonitor
|
||||
# systemctl enable mdmonitor
|
||||
|
||||
**On CentOS and openSUSE (SysVinit-based)**
|
||||
|
||||
# service mdmonitor start
|
||||
# chkconfig mdmonitor on
|
||||
|
||||
**5. Check RAID Disk Failure**
|
||||
|
||||
In RAID levels that support redundancy, replace failed drives when needed. When a device in the disk array becomes faulty, a rebuild automatically starts only if there was a spare device added when we first created the array.
|
||||
|
||||
![Check RAID Faulty Disk](http://www.tecmint.com/wp-content/uploads/2014/10/Check-RAID-Faulty-Disk.png)
|
||||
|
||||
Check RAID Faulty Disk
|
||||
|
||||
Otherwise, we need to manually attach an extra physical drive to our system and run.
|
||||
|
||||
# mdadm /dev/md0 --add /dev/sdX1
|
||||
|
||||
Where /dev/md0 is the array that experienced the issue and /dev/sdX1 is the new device.
|
||||
|
||||
**6. Disassemble a working array**
|
||||
|
||||
You may have to do this if you need to create a new array using the devices – (Optional Step).
|
||||
|
||||
# mdadm --stop /dev/md0 # Stop the array
|
||||
# mdadm --remove /dev/md0 # Remove the RAID device
|
||||
# mdadm --zero-superblock /dev/sdX1 # Overwrite the existing md superblock with zeroes
|
||||
|
||||
**7. Set up mail alerts**
|
||||
|
||||
You can configure a valid email address or system account to send alerts to (make sure you have this line in mdadm.conf). – (Optional Step)
|
||||
|
||||
MAILADDR root
|
||||
|
||||
In this case, all alerts that the RAID monitoring daemon collects will be sent to the local root account’s mail box. One of such alerts looks like the following.
|
||||
|
||||
**Note**: This event is related to the example in STEP 5, where a device was marked as faulty and the spare device was automatically built into the array by mdadm. Thus, we “ran out” of healthy spare devices and we got the alert.
|
||||
|
||||
![RAID Monitoring Alerts](http://www.tecmint.com/wp-content/uploads/2014/10/RAID-Monitoring-Alerts.png)
|
||||
|
||||
RAID Monitoring Alerts
|
||||
|
||||
#### Understanding RAID Levels ####
|
||||
|
||||
**RAID 0**
|
||||
|
||||
The total array size is n times the size of the smallest partition, where n is the number of independent disks in the array (you will need at least two drives). Run the following command to assemble a RAID 0 array using partitions /dev/sdb1 and /dev/sdc1.
|
||||
|
||||
# mdadm --create --verbose /dev/md0 --level=stripe --raid-devices=2 /dev/sdb1 /dev/sdc1
|
||||
|
||||
Common uses: Setups that support real-time applications where performance is more important than fault-tolerance.
|
||||
|
||||
**RAID 1 (aka Mirroring)**
|
||||
|
||||
The total array size equals the size of the smallest partition (you will need at least two drives). Run the following command to assemble a RAID 1 array using partitions /dev/sdb1 and /dev/sdc1.
|
||||
|
||||
# mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 /dev/sdb1 /dev/sdc1
|
||||
|
||||
Common uses: Installation of the operating system or important subdirectories, such as /home.
|
||||
|
||||
**RAID 5 (aka drives with Parity)**
|
||||
|
||||
The total array size will be (n – 1) times the size of the smallest partition. The “lost” space in (n-1) is used for parity (redundancy) calculation (you will need at least three drives).
|
||||
|
||||
Note that you can specify a spare device (/dev/sde1 in this case) to replace a faulty part when an issue occurs. Run the following command to assemble a RAID 5 array using partitions /dev/sdb1, /dev/sdc1, /dev/sdd1, and /dev/sde1 as spare.
|
||||
|
||||
# mdadm --create --verbose /dev/md0 --level=5 --raid-devices=3 /dev/sdb1 /dev/sdc1 /dev/sdd1 --spare-devices=1 /dev/sde1
|
||||
|
||||
Common uses: Web and file servers.
|
||||
|
||||
**RAID 6 (aka drives with double Parity**
|
||||
|
||||
The total array size will be (n*s)-2*s, where n is the number of independent disks in the array and s is the size of the smallest disk. Note that you can specify a spare device (/dev/sdf1 in this case) to replace a faulty part when an issue occurs.
|
||||
|
||||
Run the following command to assemble a RAID 6 array using partitions /dev/sdb1, /dev/sdc1, /dev/sdd1, /dev/sde1, and /dev/sdf1 as spare.
|
||||
|
||||
# mdadm --create --verbose /dev/md0 --level=6 --raid-devices=4 /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde --spare-devices=1 /dev/sdf1
|
||||
|
||||
Common uses: File and backup servers with large capacity and high availability requirements.
|
||||
|
||||
**RAID 1+0 (aka stripe of mirrors)**
|
||||
|
||||
The total array size is computed based on the formulas for RAID 0 and RAID 1, since RAID 1+0 is a combination of both. First, calculate the size of each mirror and then the size of the stripe.
|
||||
|
||||
Note that you can specify a spare device (/dev/sdf1 in this case) to replace a faulty part when an issue occurs. Run the following command to assemble a RAID 1+0 array using partitions /dev/sdb1, /dev/sdc1, /dev/sdd1, /dev/sde1, and /dev/sdf1 as spare.
|
||||
|
||||
# mdadm --create --verbose /dev/md0 --level=10 --raid-devices=4 /dev/sd[b-e]1 --spare-devices=1 /dev/sdf1
|
||||
|
||||
Common uses: Database and application servers that require fast I/O operations.
|
||||
|
||||
#### Creating and Managing System Backups ####
|
||||
|
||||
It never hurts to remember that RAID with all its bounties IS NOT A REPLACEMENT FOR BACKUPS! Write it 1000 times on the chalkboard if you need to, but make sure you keep that idea in mind at all times. Before we begin, we must note that there is no one-size-fits-all solution for system backups, but here are some things that you do need to take into account while planning a backup strategy.
|
||||
|
||||
- What do you use your system for? (Desktop or server? If the latter case applies, what are the most critical services – whose configuration would be a real pain to lose?)
|
||||
- How often do you need to take backups of your system?
|
||||
- What is the data (e.g. files / directories / database dumps) that you want to backup? You may also want to consider if you really need to backup huge files (such as audio or video files).
|
||||
- Where (meaning physical place and media) will those backups be stored?
|
||||
|
||||
**Backing Up Your Data**
|
||||
|
||||
Method 1: Backup entire drives with dd command. You can either back up an entire hard disk or a partition by creating an exact image at any point in time. Note that this works best when the device is offline, meaning it’s not mounted and there are no processes accessing it for I/O operations.
|
||||
|
||||
The downside of this backup approach is that the image will have the same size as the disk or partition, even when the actual data occupies a small percentage of it. For example, if you want to image a partition of 20 GB that is only 10% full, the image file will still be 20 GB in size. In other words, it’s not only the actual data that gets backed up, but the entire partition itself. You may consider using this method if you need exact backups of your devices.
|
||||
|
||||
**Creating an image file out of an existing device**
|
||||
|
||||
# dd if=/dev/sda of=/system_images/sda.img
|
||||
OR
|
||||
--------------------- Alternatively, you can compress the image file ---------------------
|
||||
# dd if=/dev/sda | gzip -c > /system_images/sda.img.gz
|
||||
|
||||
**Restoring the backup from the image file**
|
||||
|
||||
# dd if=/system_images/sda.img of=/dev/sda
|
||||
OR
|
||||
|
||||
--------------------- Depending on your choice while creating the image ---------------------
|
||||
gzip -dc /system_images/sda.img.gz | dd of=/dev/sda
|
||||
|
||||
Method 2: Backup certain files / directories with tar command – already covered in [Part 3][3] of this series. You may consider using this method if you need to keep copies of specific files and directories (configuration files, users’ home directories, and so on).
|
||||
|
||||
Method 3: Synchronize files with rsync command. Rsync is a versatile remote (and local) file-copying tool. If you need to backup and synchronize your files to/from network drives, rsync is a go.
|
||||
|
||||
Whether you’re synchronizing two local directories or local < — > remote directories mounted on the local filesystem, the basic syntax is the same.
|
||||
Synchronizing two local directories or local < — > remote directories mounted on the local filesystem
|
||||
|
||||
# rsync -av source_directory destination directory
|
||||
|
||||
Where, -a recurse into subdirectories (if they exist), preserve symbolic links, timestamps, permissions, and original owner / group and -v verbose.
|
||||
|
||||
![rsync Synchronizing Files](http://www.tecmint.com/wp-content/uploads/2014/10/rsync-synchronizing-Files.png)
|
||||
|
||||
rsync Synchronizing Files
|
||||
|
||||
In addition, if you want to increase the security of the data transfer over the wire, you can use ssh over rsync.
|
||||
|
||||
**Synchronizing local → remote directories over ssh**
|
||||
|
||||
# rsync -avzhe ssh backups root@remote_host:/remote_directory/
|
||||
|
||||
This example will synchronize the backups directory on the local host with the contents of /root/remote_directory on the remote host.
|
||||
|
||||
Where the -h option shows file sizes in human-readable format, and the -e flag is used to indicate a ssh connection.
|
||||
|
||||
![rsync Synchronize Remote Files](http://www.tecmint.com/wp-content/uploads/2014/10/rsync-synchronize-Remote-Files.png)
|
||||
|
||||
rsync Synchronize Remote Files
|
||||
|
||||
Synchronizing remote → local directories over ssh.
|
||||
|
||||
In this case, switch the source and destination directories from the previous example.
|
||||
|
||||
# rsync -avzhe ssh root@remote_host:/remote_directory/ backups
|
||||
|
||||
Please note that these are only 3 examples (most frequent cases you’re likely to run into) of the use of rsync. For more examples and usages of rsync commands can be found at the following article.
|
||||
|
||||
- Read Also: [10 rsync Commands to Sync Files in Linux][4]
|
||||
|
||||
### Summary ###
|
||||
|
||||
As a sysadmin, you need to ensure that your systems perform as good as possible. If you’re well prepared, and if the integrity of your data is well supported by a storage technology such as RAID and regular system backups, you’ll be safe.
|
||||
|
||||
If you have questions, comments, or further ideas on how this article can be improved, feel free to speak out below. In addition, please consider sharing this series through your social network profiles.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.tecmint.com/creating-and-managing-raid-backups-in-linux/
|
||||
|
||||
作者:[Gabriel Cánepa][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/gacanepa/
|
||||
[1]:http://www.tecmint.com/understanding-raid-setup-in-linux/
|
||||
[2]:http://www.tecmint.com/create-partitions-and-filesystems-in-linux/
|
||||
[3]:http://www.tecmint.com/compress-files-and-finding-files-in-linux/
|
||||
[4]:http://www.tecmint.com/rsync-local-remote-file-synchronization-commands/
|
@ -0,0 +1,96 @@
|
||||
|
||||
我的Linux系统应该安装的最好的文件系统是什么?
|
||||
================================================================================
|
||||
![](https://www.maketecheasier.com/assets/uploads/2015/05/file-systems-feature-image.jpg)
|
||||
|
||||
文件系统: 它们不是世界上最激动人心的技术,但是仍然很重要。本文我们将细数那些流行的Linux文件系统 - 它们是什么,它们能够做什么,以及它们的目标用户。
|
||||
|
||||
### Ext4 ###
|
||||
|
||||
![file-systems-ext4](https://www.maketecheasier.com/assets/uploads/2015/05/file-systems-ext4.png)
|
||||
|
||||
如果你曾经安装过Linux,你可能在安装过程中看到过"Ext4"字样。关于这个有一个不错的理由: 它是当前每个可用Linux发行版所选择的文件系统。当然,还有其他的一些选择,但是不可否认的是,Ext4(Extended 4)几乎是所有Linux用户都会选择的文件系统。
|
||||
|
||||
#### 它能做什么? ####
|
||||
|
||||
Ext4拥有你预期的曾经的文件系统(Ext2/Ext3)的所有优点, 同时还带来了一些改进。还有很多内容可以发掘,这里列举出Ext4为你带来的最好的部分:
|
||||
|
||||
- 文件系统日志
|
||||
- 日志校验
|
||||
- 多重块文件的分配
|
||||
- 对Ext2 && Ext3向后兼容
|
||||
- 持续的预分配空闲空间
|
||||
- 改进的文件系统校验(相比于之前的版本)
|
||||
- 当然,同时支持更大的文件
|
||||
|
||||
#### 目标用户 ####
|
||||
|
||||
Ext4针对那些寻找超级可靠的构建环境或者那些仅仅需要可用环境的用户。这个文件系统不会对你的系统做快照;它甚至没有最好的SSD支持,但是如果你的要求不是太过严格的话,你会觉得它也还不错。
|
||||
|
||||
### BtrFS ###
|
||||
|
||||
![file-systems-btrFS](https://www.maketecheasier.com/assets/uploads/2015/05/file-systems-btrFS-e1450065697580.png)
|
||||
|
||||
B树(B-tree)文件系统 (也被认为是butterFS,黄油文件系统) 是Oracle为Linux研发的一款文件系统。它是一个全新的文件系统,而且正处于重度开发阶段。Linux社区认为其目前使用上还有些不稳定。BtrFS的核心原则是基于写时复制(copy-on-write). **写时复制**基本上意味着在写入数据前,这份数据的每一比特都有单独的一份副本。当数据写入完毕后,它相应的副本也随之生成。
|
||||
|
||||
#### 它能做什么 ####
|
||||
|
||||
除了支持写时复制之外,BtrFS也能够胜任许多其他的事务 - 事实上,如此多的事务支持以致于它能永久列出一切(数据)。这里列举最值得一提的特性:支持只读快照,文件克隆,子卷,透明压缩,离线文件系统校验,无缝地从ext3&&4转换到BtrFS,在线碎片整理,还支持RAID 0, RAID 1, RAID 5, RAID 6 and RAID 10。
|
||||
|
||||
#### 目标用户 ####
|
||||
|
||||
BtrFS的开发者门许诺过,该文件系统是当前其他文件系统的新一代替代者。非常正确,虽然目前其处于开发中。它有很多杀手级的特性面向高级用户,也包括基本用户 (包括SSDs上面的表现)。这个文件系统针对那些想要从文件系统中获取更多(特性),以及那些想尝试用写时复制机制做一些事情的用户。
|
||||
|
||||
### XFS ###
|
||||
|
||||
![file-systems-xfs](https://www.maketecheasier.com/assets/uploads/2015/05/file-systems-xfs.jpg)
|
||||
|
||||
由Silicon Graphics公司创造开发,XFS是一个高端文件系统,定位于速度和性能。对于性能方面的专注,使得在并行输入输出方面,XFS表现的尤其出色。XFS文件系统能够处理数量庞大的数据,事实上某些XFS用户的数据接近300+TB。
|
||||
|
||||
#### 它能做什么 ####
|
||||
|
||||
XFS是一个经历良好测试的数据存储文件系统,它是为了高性能操作而诞生的。其特性包括:
|
||||
|
||||
- RAID阵列的条纹(striped)模式分配
|
||||
- 文件系统日志
|
||||
- 多种块大小
|
||||
- 直接I/O
|
||||
- 指定速率(guaranteed-rate)I/O
|
||||
- 快照
|
||||
- 在线碎片整理
|
||||
- 在线调整大小
|
||||
|
||||
#### 目标用户 ####
|
||||
|
||||
XFS针对那些想要一个坚如磐石的文件系统方案的用户。它起源于1993年,并且随着时间的变迁它变得越来越好。如果你有一台家庭服务器,而且你苦恼于如何部署存储环境,那么可以考虑下XFS。它拥有的众多特性(比如快照)能够协助你的文件存储系统。尽管如此,它不局限于服务器端。如果你是一个相对高级一点的用户或者你对BtrFS所承诺的很多特性感兴趣的话,尝试一下XFS。它实现了很多与BtrFS相似的特性,并且没有稳定性方面的问题。
|
||||
|
||||
### Reiser4 ###
|
||||
|
||||
![file-system-riser4](https://www.maketecheasier.com/assets/uploads/2015/05/file-system-riser4.gif)
|
||||
|
||||
Reiser4,ReiserFS的继任者,由Namesys公司创造研发。它的诞生追溯到Linspire工程和DARPA。它与众不同的地方在于众多的事务模式。没有一个单一的方式来写入数据;取而代之的是,有很多方式(来写入)。
|
||||
|
||||
#### 它能做什么 ####
|
||||
|
||||
Reiser4拥有着使用多种不同事务模式的独特能力。它能够使用写时复制模式 (像BtrFS),任意位置写入(write-anywhere),日志,以及超级事务模式。它在ReiserFS的基础上做了许多的改进,包括更好的基于漫游日志的文件系统日志,对更小的文件较好的支持,以及更快速的目录处理。Reiser4提供了许多功能特性。还有更多的特性可以探讨,不过简单来讲,相比于ReiserFS它对众多新增特性做了非常大的改进。
|
||||
|
||||
#### 目标用户 ####
|
||||
|
||||
Resier4适合那些想要将一个文件系统应用到多中场景下的用户。可能你想在一台机器上使用copy-on-write机制,在另一台机器上使用write-anywhere机制,还会在另一台机器上使用超级事务,而你又不希望使用多种不同类型的文件系统来完成这项任务。Reiser4是适合这种情况的完美方案。
|
||||
|
||||
### 结论 ###
|
||||
|
||||
Linux上有许多可用的文件系统。每个文件系统都有其特定的用途,以便于特定用户解决不同的问题。本文的焦点集中在平台上文件系统的主流的选择。毫无疑问,其它的场景下还有一些别的选择。
|
||||
|
||||
你在Linux上最喜欢的文件系统是什么?在下面(的评论区)告诉我们吧!
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.maketecheasier.com/best-file-system-linux/
|
||||
|
||||
作者:[Derrik Diener][a]
|
||||
译者:[icecoobe](https://github.com/icecoobe)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://www.maketecheasier.com/author/derrikdiener/
|
@ -0,0 +1,125 @@
|
||||
在 Linux 上将 BQ Aquaris Ubuntu 手机刷成 Android 系统
|
||||
================================================================================
|
||||
![How to install Android on Ubuntu Phone](http://itsfoss.itsfoss.netdna-cdn.com/wp-content/uploads/2015/11/Install-Android-on-Ubuntu-Phone.jpg)
|
||||
|
||||
如果你正好拥有全球第一支运行 Ubuntu 的手机并且希望将 **BQ Aquaris E4.5 自带的 Ubuntu 系统换成 Android **,那这篇文章能帮你点小忙。
|
||||
|
||||
有一万种理由来解释为什么要将 Ubuntu 换成主流 Android OS。其中最主要的一个,就是这个系统本身仍然处于非常早期的阶段,针对的目标用户仍然是开发者和爱好者。不管你的理由是什么,要谢谢 bq 提供的工具,让我们能非常轻松地在 BQ Aquaris 上安装 Android OS。
|
||||
|
||||
下面让我们一起看下在 BQ Aquaris 上安装 Android 需要做哪些事情。
|
||||
|
||||
### 前提条件 ###
|
||||
|
||||
- 可用的因特网连接,用来下载 Android 出厂固件以及安装刷机工具。
|
||||
- USB 数据线
|
||||
- 运行 Linux 的电脑
|
||||
|
||||
本文是基于 Ubuntu 15.10 操作的。但是这些步骤应该也可以应用于其他大多数 Linux 发行版。
|
||||
|
||||
### 将 BQ Aquaris E4.5 上的 Ubuntu 换成 Android ###
|
||||
|
||||
#### 第一步:下载 Android 固件 ####
|
||||
|
||||
首先是下载可以在 BQ Aquaris E4.5 上运行的 Android 固件。幸运的是我们可以在 bq 的技术支持网站找到。可以从下面的链接直接下载,差不多 650 MB:
|
||||
|
||||
- [下载为 BQ Aquaris E4.5 制作的 Android][1]
|
||||
|
||||
是的,这个版本还支持 OTA 自动升级。目前,固件版本是 2.0.1,基于 Android Lolipop 开发。过一段时间,应该就会放出基于 Marshmallow 的新版本,上边的链接可能就无效了。
|
||||
|
||||
我建议去[ bq 的技术支持网站][2]下载最新的固件。
|
||||
|
||||
下载完成后解压。在解压后的目录里,找到一个名字是 **MT6582_Android_scatter.txt** 的文件。后面将要用到它。
|
||||
|
||||
#### 第二步:下载刷机工具 ####
|
||||
|
||||
bq 已经提供了自己的刷机工具,Herramienta MTK Flash Tool,可以轻松地给设备安装 Andriod 或者 Ubuntu 系统。你可以从下面的链接下载工具:
|
||||
|
||||
- [下载 MTK Flash Tool][3]
|
||||
|
||||
考虑到刷机工具在以后可能会升级,你总是可以从[bq 技术支持网站][4]上找到最新的版本。
|
||||
|
||||
下载完后解压。之后应该可以在目录里找到一个叫 **flash_tool** 的可执行文件。我们稍后会用到。
|
||||
|
||||
#### 第三步:移除冲突的软件包(可选) ####
|
||||
|
||||
如果你正在用最新版本的 Ubuntu 或 基于 Ubuntu 的 Linux 发行版,稍后可能会碰到 “BROM ERROR : S_UNDEFINED_ERROR (1001)” 错误。
|
||||
|
||||
要避免这个错误,你需要卸载有冲突的软件包。可以使用下面的命令:
|
||||
|
||||
sudo apt-get remove modemmanager
|
||||
|
||||
用下面的命令重启 udev 服务:
|
||||
|
||||
sudo service udev restart
|
||||
|
||||
检查一下内核模块 cdc_acm 可能存在的边际效应,运行下面的命令:
|
||||
|
||||
lsmod | grep cdc_acm
|
||||
|
||||
如果上面命令输出是空,你将需要重新加载一下这个内核模块:
|
||||
|
||||
sudo modprobe cdc_acm
|
||||
|
||||
#### 第四步:准备刷入 Android ####
|
||||
|
||||
切换到下载好并解压完成的刷机工具目录(第二步)。请使用命令行来完成,这是因为将要用到 root 权限。
|
||||
|
||||
假设你保存在下载目录里,使用下面的命令切换目录(为那些不懂如何在命令行下切换目录的朋友考虑)。
|
||||
|
||||
cd ~/Downloads/SP_Flash*
|
||||
|
||||
然后使用下面的命令以 root 权限启动刷机工具:
|
||||
|
||||
sudo ./flash_tool
|
||||
|
||||
然后你会看到一个像下面的窗口界面。不用在意 Download Agent 区域,它将会被自动填入。只要关心 Scatter-loading 区域。
|
||||
|
||||
![Replace Ubuntu with Android](http://itsfoss.itsfoss.netdna-cdn.com/wp-content/uploads/2015/11/Install-Android-bq-aquaris-Ubuntu-1.jpeg)
|
||||
|
||||
还记得之前第一步里提到的 **MT6582_Android_scatter.txt** 文件吗?这个文本文件就在你第一步中下载的 Android 固件解压后的目录里。点击 Scatter-loading(上图中)然后选中 MT6582_Android_scatter.txt 文件。
|
||||
|
||||
之后,你将看到类似下面图片里的一些绿色线条:
|
||||
|
||||
![Install-Android-bq-aquaris-Ubuntu-2](http://itsfoss.itsfoss.netdna-cdn.com/wp-content/uploads/2015/11/Install-Android-bq-aquaris-Ubuntu-2.jpeg)
|
||||
|
||||
#### 第五步:刷入 Android ####
|
||||
|
||||
已经差不多了。把你的手机关机,然后通过 USB 线连接到电脑上。
|
||||
|
||||
在下拉列表里选择 Firmware Upgrade,然后点击那个大的 Download 按钮。
|
||||
|
||||
![flash Android with Ubuntu](http://itsfoss.itsfoss.netdna-cdn.com/wp-content/uploads/2015/11/Install-Android-bq-aquaris-Ubuntu.jpeg)
|
||||
|
||||
如果一切顺利,你应该可以在工具下方的状态栏里看到刷机状态:
|
||||
|
||||
![Replace Ubuntu with Android](http://itsfoss.itsfoss.netdna-cdn.com/wp-content/uploads/2015/11/Install-Android-bq-aquaris-Ubuntu-3.jpeg)
|
||||
|
||||
当所有过程都完成后,你将看到一个类似这样的提示:
|
||||
|
||||
![Successfully flashed Android on bq qauaris Ubuntu Phone](http://itsfoss.itsfoss.netdna-cdn.com/wp-content/uploads/2015/11/Install-Android-bq-aquaris-Ubuntu-4.jpeg)
|
||||
|
||||
将手机从电脑上移除然后开机。你应该看到屏幕上显示白色并在中间和底部有 AQUARIS 文字,还应该有 “powered by Android” 字样。差不多需要差不多十分钟,你才可以设置和开始使用 Android。
|
||||
|
||||
注意:如果中间出了什么问题,同时按下电源、音量加、音量减按键可以进入 fast boot 模式。然后再次关机并连接电脑。重复升级固件的过程。应该可以。
|
||||
|
||||
### 总结 ###
|
||||
|
||||
要感谢厂商提供的工具,让我们可以轻松地 **在 bq Ubuntu 手机上刷 Android**。当然,你可以使用相同的步骤将 Android 替换回 Ubuntu。只是下载的时候选 Ubuntu 固件而不是 Android。
|
||||
|
||||
希望这篇文章可以帮你将你的 bq 手机上的 Ubuntu 刷成 Android。如果有什么问题或建议,可以在下面留言区里讨论。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://itsfoss.com/install-android-ubuntu-phone/
|
||||
|
||||
作者:[Abhishek][a]
|
||||
译者:[zpl1025](https://github.com/zpl1025)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://itsfoss.com/author/abhishek/
|
||||
[1]:https://storage.googleapis.com/otas/2014/Smartphones/Aquaris_E4.5_L/2.0.1_20150623-1900_bq-FW.zip
|
||||
[2]:http://www.bq.com/gb/support/aquaris-e4-5
|
||||
[3]:https://storage.googleapis.com/otas/2014/Smartphones/Aquaris_E4.5/Ubuntu/Web%20version/Web%20version/SP_Flash_Tool_exe_linux_v5.1424.00.zip
|
||||
[4]:http://www.bq.com/gb/support/aquaris-e4-5-ubuntu-edition
|
@ -1,171 +0,0 @@
|
||||
Linux 101:最有效地使用 Systemd
|
||||
================================================================================
|
||||
干嘛要这么做?
|
||||
|
||||
- 理解现代 Linux 发行版中的显著变化;
|
||||
- 看看 Systemd 是如何取代 SysVinit 的;
|
||||
- 处理好*单元* (unit)和新的 journal 日志。
|
||||
|
||||
吐槽邮件,人身攻击,死亡威胁——Lennart Poettering,Systemd 的作者,对收到这些东西早就习以为常了。这位 Red Hat 公司的员工最近在 Google+ 上怒斥 FOSS 社区([http://tinyurl.com/poorlennart][1])的本质,悲痛且失望地表示:“那真是个令人恶心的地方”。他着重指出 Linus Torvalds 在邮件列表上言辞刻薄的帖子,并谴责这位内核的领导者为在线讨论定下基调,并使得人身攻击及贬抑之辞成为常态。
|
||||
|
||||
但为何 Poettering 会遭受如此多的憎恨?为何就这么个搞搞开源软件的人要忍受这等愤怒?答案就在于他的软件的重要性。如今大多数发行版中,Systemd 是 Linux 内核发起的第一个程序,并且它还扮演多种角色。它会启动系统服务,处理用户登陆,每隔特定的时间执行一些任务,还有很多很多。它在不断地成长,并逐渐成为 Linux 的某种“基础系统”——提供系统启动和发行版维护所需的所有工具。
|
||||
|
||||
如今,在以下几点上 Systemd 颇具争议:它逃避了一些确立好的 Unix 传统,例如纯文本的日志文件;它被看成是个“大一统”的项目,试图接管一切;它还是我们这个操作系统的支柱的重要革新。然而大多数主流发行版已经接受了(或即将接受)它,因此它就保留了下来。而且它确实是有好处的:更快地启动,更简单地管理那些有依赖的服务程序,提供强大且安全的日志系统等。
|
||||
|
||||
因此在这篇教程中,我们将探索 Systemd 的特性,并向您展示如何最有效地利用这些特性。即便您此刻并不是这款软件的粉丝,读完本文后您至少可以更加了解和适应它。
|
||||
|
||||
![Image](http://www.linuxvoice.com/wp-content/uploads/2015/10/eating-large.jpg)
|
||||
|
||||
**这部没正经的动画片来自[http://tinyurl.com/m2e7mv8][2],它把 Systemd 塑造成一只狂暴的动物,吞噬它路过的一切。大多数批评者的言辞可不像这只公仔一样柔软。**
|
||||
|
||||
### 启动及服务 ###
|
||||
|
||||
大多数主流发行版要么已经采用 Systemd,要么即将在下个发布中采用(如 Debian 和 Ubuntu)。在本教程中,我们使用 Fedora 21——该发行版已经是 Systemd 的优秀实验场地——的一个预览版进行演示,但不论您用哪个发行版,要用到的命令和注意事项都应该是一样的。这是 Systemd 的一个加分点:它消除了不同发行版之间许多细微且琐碎的区别。
|
||||
|
||||
在终端中输入 **ps ax | grep systemd**,看到第一行,其中的数字 **1** 表示它的进程号是1,也就是说它是 Linux 内核发起的第一个程序。因此,内核一旦检测完硬件并组织好了内存,就会运行 **/usr/lib/systemd/systemd** 可执行程序,这个程序会按顺序依次发起其他程序。(在还没有 Systemd 的日子里,内核会去运行 **/sbin/init**,随后这个程序会在名为 SysVinit 的系统中运行其余的各种启动脚本。)
|
||||
|
||||
Systemd 的核心是一个叫*单元* (unit)的概念,它是一些存有关于服务(在运行在后台的程序),设备,挂载点,和操作系统其他方面信息的配置文件。Systemd 的其中一个目标就是简化这些事物之间的相互作用,因此如果你有程序需要在某个挂载点被创建或某个设备被接入后开始运行,Systemd 可以让这一切正常运作起来变得相当容易。(在没有 Systemd 的日子里,要使用脚本来把这些事情调配好,那可是相当丑陋的。)要列出您 Linux 系统上的所有单元,输入以下命令:
|
||||
|
||||
systemctl list-unit-files
|
||||
|
||||
现在,**systemctl** 是与 Systemd 交互的主要工具,它有不少选项。在单元列表中,您会注意到这儿有一些格式:被使能的单元显示为绿色,被禁用的显示为红色。标记为“static”的单元不能直接启用,它们是其他单元所依赖的对象。若要限制输出列表只包含服务,使用以下命令:
|
||||
|
||||
systemctl list-unit-files --type=service
|
||||
|
||||
注意,一个单元显示为“enabled”,并不等于对应的服务正在运行,而只能说明它可以被开启。要获得某个特定服务的信息,以 GDM (the Gnome Display Manager) 为例,输入以下命令:
|
||||
|
||||
systemctl status gdm.service
|
||||
|
||||
这条命令提供了许多有用的信息:一段人类可读的服务描述,单元配置文件的位置,启动的时间,进程号,以及它所从属的 CGroups (用以限制各组进程的资源开销)。
|
||||
|
||||
如果您去查看位于 **/usr/lib/systemd/system/gdm.service** 的单元配置文件,您可以看到多种选项,包括要被运行的二进制文件(“ExecStart”那一行),相冲突的其他单元(即不能同时进入运行的单元),以及需要在本单元执行前进入运行的单元(“After”那一行)。一些单元有附加的依赖选项,例如“Requires”(必要的依赖)和“Wants”(可选的依赖)。
|
||||
|
||||
此处另一个有趣的选项是:
|
||||
|
||||
Alias=display-manager.service
|
||||
|
||||
当您启动 **gdm.service** 后,您将可以通过 **systemctl status display-manager.service** 来查看它的状态。当您知道有*显示管理程序* (display manager)在运行并想对它做点什么,但您不关心那究竟是 GDM,KDM,XDM 还是什么别的显示管理程序时,这个选项会非常有用。
|
||||
|
||||
![Image](http://www.linuxvoice.com/wp-content/uploads/2015/10/status-large.jpg)
|
||||
|
||||
**使用 systemctl status 命令后面跟一个单元名,来查看对应的服务有什么情况。**
|
||||
|
||||
### “目标”锁定 ###
|
||||
|
||||
如果您在 **/usr/lib/systemd/system** 目录中输入 **ls** 命令,您将看到各种以 **.target** 结尾的文件。一个*启动目标* (target)是一种将多个单元聚合在一起以致于将它们同时启动的方式。例如,对大多数类 Unix 操作系统而言有一种“多用户”状态,意思是系统已被成功启动,后台服务正在运行,并且已准备好让一个或多个用户登陆并工作——至少在文本模式下。(其他状态包括用于进行管理工作的单用户状态,以及用于机器关机的重启状态。)
|
||||
|
||||
如果您打开 **multi-user.target** 文件一探究竟,您可能期待看到的是一个要被启动的单元列表。但您会发现这个文件内部几乎空空如也——其实,一个服务会通过 **WantedBy** 选项让自己成为启动目标的依赖。因此如果您去打开 **avahi-daemon.service**, **NetworkManager.service** 及其他 **.service** 文件看看,您将在 Install 段看到这一行:
|
||||
|
||||
WantedBy=multi-user.target
|
||||
|
||||
因此,切换到多用户启动目标会使能那些包含上述语句的单元。还有其他一些启动目标可用(例如 **emergency.target** 用于一个紧急情况使用的 shell,以及 **halt.target** 用于机器关机),您可以用以下方式轻松地在它们之间切换:
|
||||
|
||||
systemctl isolate emergency.target
|
||||
|
||||
在许多方面,这些都很像 SysVinit 中的*运行级* (runlevel),如文本模式的 **multi-user.target** 类似于第3运行级,**graphical.target** 类似于第5运行级,**reboot.target** 类似于第6运行级,诸如此类。
|
||||
|
||||
![Image](http://www.linuxvoice.com/wp-content/uploads/2015/10/unit-large.jpg)
|
||||
|
||||
**与传统的脚本相比,单元配置文件也许看起来很陌生,但并不难以理解。**
|
||||
|
||||
### 开启与停止 ###
|
||||
|
||||
现在您也许陷入了沉思:我们已经看了这么多,但仍没看到如何停止和开启服务!这其实是有原因的。从外部看,Systemd 也许很复杂,像野兽一般难以驾驭。因此在您开始摆弄它之间,有必要从宏观的角度看看它是如何工作的。实际用来管理服务的命令非常简单:
|
||||
|
||||
systemctl stop cups.service
|
||||
systemctl start cups.service
|
||||
|
||||
(若某个单元被禁用了,您可以先通过 **systemctl enable** 加该单元名的方式将其使能。这种做法会为该单元创建一个符号链接,并将其放置在当前启动目标的 .wants 目录下,这些 .wants 目录在**/etc/systemd/system** 文件夹中。)
|
||||
|
||||
还有两个有用的命令是 **systemctl restart** 和 **systemctl reload**,后面接单元名。后者要求单元重新加载它的配置文件。Systemd 的绝大部分都有良好的文档,因此您可以查看手册 (**man systemctl**) 了解每条命令的细节。
|
||||
|
||||
> ### 定时器单元:取代 Cron ###
|
||||
>
|
||||
> 除了系统初始化和服务管理,Systemd 还染指其他方面。在很大程度上,它能够完成 **cron** 的工作,而且可以说是以更灵活的方式(并带有更易读的语法)。**cron** 是一个以规定时间间隔执行任务的程序——例如清楚临时文件,刷新缓存等。
|
||||
>
|
||||
> 如果您再次进入 **/usr/lib/systemd/system** 目录,您会看到那儿有多个 **.timer** 文件。用 **less** 来查看这些文件,您会发现它们与 **.service** 和 **.target** 文件有着相似的结构,而区别在于 **[Timer]** 段。举个例子:
|
||||
>
|
||||
> [Timer]
|
||||
> OnBootSec=1h
|
||||
> OnUnitActiveSec=1w
|
||||
>
|
||||
> **OnBootSec** 选项告诉 Systemd 在系统启动一小时后启动这个单元。第二个选项的意思是:自那以后每周启动这个单元一次。关于定时器有大量选项您可以设置——输入 **man systemd.time** 查看完整列表。
|
||||
>
|
||||
> Systemd 的时间精度默认为一分钟。也就是说,它会在设定时刻的一分钟内运行单元,但不一定精确到那一秒。这么做是基于电源管理方面的原因,但如果您需要一个没有任何延时且精确到毫秒的定时器,您可以添加以下一行:
|
||||
>
|
||||
> AccuracySec=1us
|
||||
>
|
||||
> 另外, **WakeSystem** 选项(可以被设置为 true 或 false)决定了定时器是否可以唤醒处于休眠状态的机器。
|
||||
|
||||
![Image](http://www.linuxvoice.com/wp-content/uploads/2015/10/systemd_gui-large.jpg)
|
||||
|
||||
**存在一个 Systemd 的图形界面程序,即便它已有多年未被积极维护。**
|
||||
|
||||
### 日志文件:向 journald 问声好 ###
|
||||
|
||||
Systemd 的第二个主要部分是 journal 。这是个日志系统,类似于 syslog 但也有些显著区别。如果您是个 Unix 日志管理模式的 粉丝,准备好热血沸腾吧:这是个二进制日志,因此您不能使用常规的命令行文本处理工具来解析它。这个设计决定不出意料地在网上引起了激烈的争论,但它的确有些优点。例如,日志可以被更系统地组织,带有更多元数据,因此可以更容易地根据可执行文件名和进程号等过滤出信息。
|
||||
|
||||
要查看整个 journal,输入以下命令:
|
||||
|
||||
journalctl
|
||||
|
||||
像许多其他的 Systemd 命令一样,该命令将输出通过管道的方式引向 **less** 程序,因此您可以使用空格键向下滚动,“/”(斜杠)键查找,以及其他熟悉的快捷键。您也能在此看到少许颜色,像红色的警告及错误信息。
|
||||
|
||||
以上命令会输出很多信息。为了限制其只输出当前启动的消息,使用如下命令:
|
||||
|
||||
journalctl -b
|
||||
|
||||
这就是 Systemd 大放异彩的地方!您想查看自上次启动以来的全部消息吗?试试 **journalctl -b -1** 吧。再上一次的?用 **-2** 替换 **-1** 吧。那自某个具体时间,例如2014年10月24日16:38以来的呢?
|
||||
|
||||
journalctl -b --since=”2014-10-24 16:38”
|
||||
|
||||
即便您对二进制日志感到遗憾,那依然是个有用的特性,并且对许多系统管理员来说,构建类似的过滤器比起写正则表达式而言容易多了。
|
||||
|
||||
我们已经可以根据特定的时间来准确查找日志了,那可以根据特定程序吗?对单元而言,试试这个:
|
||||
|
||||
journalctl -u gdm.service
|
||||
|
||||
(注意:这是个查看 X server 产生的日志的好办法。)那根据特定的进程号?
|
||||
|
||||
journalctl _PID=890
|
||||
|
||||
您甚至可以请求只看某个可执行文件产生的消息:
|
||||
|
||||
journalctl /usr/bin/pulseaudio
|
||||
|
||||
若您想将输出的消息限制在某个优先级,可以使用 **-p** 选项。该选项参数为 0 的话只会显示紧急消息(也就是说,是时候向 **\$DEITY** 祈求保佑了),为 7 的话会显示所有消息,包括调试消息。请查看手册 (**man journalctl**) 获取更多关于优先级的信息。
|
||||
|
||||
值得指出的是,您也可以将多个选项结合在一起,若想查看在当前启动中由 GDM 服务输出的优先级数小于等于 3 的消息,请使用下述命令:
|
||||
|
||||
journalctl -u gdm.service -p 3 -b
|
||||
|
||||
最后,如果您仅仅想打开一个随 journal 持续更新的终端窗口,就像在没有 Systemd 时使用 tail 命令实现的那样,输入 **journalctl -f** 就好了。
|
||||
|
||||
![Image](http://www.linuxvoice.com/wp-content/uploads/2015/10/journal-large.jpg)
|
||||
|
||||
**二进制日志并不流行,但 journal 的确有它的优点,如非常方便的信息查找及过滤。**
|
||||
|
||||
> ### 没有 Systemd 的生活?###
|
||||
>
|
||||
> 如果您就是完全不能接收 Systemd,您仍然有一些主流发现版中的选择。尤其是 Slackware,作为历史最为悠久的发行版,目前还没有做出改变,但它的主要开发者并没有将其从未来规划中移除。一些不出名的发行版也在坚持使用 SysVinit 。
|
||||
>
|
||||
> 但这又将持续多久呢?Gnome 正越来越依赖于 Systemd,其他的主流桌面环境也会步其后尘。这也是引起 BSD 社区一阵恐慌的原因:Systemd 与 Linux 内核紧密相连,导致在某种程度上,桌面环境正变得越来越不可移植。一种折中的解决方案也许会以 Uselessd ([http://uselessd.darknedgy.net][3]) 的形式到来:一种裁剪版的 Systemd,纯粹专注于启动和监控进程,而不消耗整个基础系统。
|
||||
>
|
||||
> ![Image](http://www.linuxvoice.com/wp-content/uploads/2015/10/gentoo-large.jpg)
|
||||
>
|
||||
> 若您不喜欢 Systemd,可以尝试一下 Gentoo 发行版,它将 Systemd 作为初始化工具的一种选择,但并不强制用户使用 Systemd。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.linuxvoice.com/linux-101-get-the-most-out-of-systemd/
|
||||
|
||||
作者:[Mike Saunders][a]
|
||||
译者:[Ricky-Gong](https://github.com/Ricky-Gong)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.linuxvoice.com/author/mike/
|
||||
[1]:http://tinyurl.com/poorlennart
|
||||
[2]:http://tinyurl.com/m2e7mv8
|
||||
[3]:http://uselessd.darknedgy.net/
|
@ -1,91 +0,0 @@
|
||||
提高emacs生产力的最好插件是什么
|
||||
================================================================================
|
||||
一年前的这个时候, 我想要寻找一个最好的插件 [将VIM打造成一个成熟的全功能的IDE][1]. 有趣的是, 很多评论那篇文章的是关于Emacs集成大部分这些插件,已经是一个伟大的IDE了. 尽管我对Emacs的难以置信的多样化表示赞成, 它依旧不是可以开箱即用(安装好不安插件即可用)的高级编辑器. 还好, 其庞大的插件库可以解决这个问题. 但在过多的选项中, 有时很难清楚该如何入手. 因此现在, 让我试着收集一个虽然简短但是不可或缺的插件列表来让你使用Emacs时提高工作效率. 虽然我主要侧重于与编程相关的生产力,但是这些插件将对任何人或对任何使用方法都是有用的.
|
||||
|
||||
### 1. Ido-模式 ###
|
||||
|
||||
![](https://c2.staticflickr.com/6/5718/23311895573_c1fb34337c_c.jpg)
|
||||
|
||||
Ido 或许是对新手最有用的一个插件, Ido 表示交互式的去做.它取代大部分的用花哨的匹配字符提示的枯燥菜单 . 好比说, 它将取代正常的提示来打开一个拥有当前目录中的所有文件列表的文件. 任何字符串类型,Ido 将尝试匹配最合适的文件。它很容易想象你的行为,并迅速通过一个文件夹的所有文件命名相同的前缀来查找.
|
||||
|
||||
### 2. Smex ###
|
||||
|
||||
![](https://c2.staticflickr.com/2/1517/23310442314_2a22a60c34_c.jpg)
|
||||
|
||||
不算最著名的一个,但却是一个好选择来完成那些由Ido-mode开始的工作:Smex可以优雅的替代正常的“M-x”提示,也有由Ido-mode带来的很大的启发。通常输入的命令调用“M-x”之后它带来同样的互动搜索。它既简单又有效,是一个很好的节省那些额外的你通常需要1秒的短时间方式
|
||||
|
||||
### 3. Auto Complete ###
|
||||
|
||||
![](https://c2.staticflickr.com/6/5794/23643004900_3042f77952_c.jpg)
|
||||
|
||||
知道这个插件的存在之前,我花了我一半的时间在使用Emacs敲击"M-/"来完成代码上。现在,我有一个漂亮的弹出为我去做自动补全。无须多说,只是我们都需要它。
|
||||
|
||||
### 4. YASnippet ###
|
||||
|
||||
![](https://c2.staticflickr.com/2/1688/23830403072_0d8df6ef4c_b.jpg)
|
||||
|
||||
这是真正的程序员所需利器。总有一些代码,我们觉得我们在它们上面用掉了所有的时间。对我来说,用"var_dump(…);exit;"来调试PHP。经过一段时间一遍又一遍的输入"var_dump(…);exit;",我就想到我可以预先把其作为录制好的,方便的代码片段。YASnippets,很容易导入片段文件或者自己制做。之后,一个简单的按制表键可以将一小关键词扩展成一块预先写好的代码易于使用者浏览和修改。
|
||||
|
||||
|
||||
### 5. Org-mode ###
|
||||
|
||||
![](https://c2.staticflickr.com/6/5687/23570808789_d683c949e4.jpg)
|
||||
|
||||
免责声明,我最近才开始使用Org-mode。但它已经深深的吸引了我。从我看过数以百计的书面作品来说,Org-mode可以改变你的生活。它背后的想法很简单:它是一种模式,简化了笔记,同时保持一个纯文本格式,便于浏览列表的任务和各种数据,并执行操作,如按优先级过滤或到期日期,或设置一个复发日期 。然而,从这个简单的想法,你可以完成很多,但也容易被所有的选项弄的不堪重负。与其去看一个长长的解释,我敦促你去通过[可用教程][2],看很多视频,自己去看看Org-mode是多么强大。
|
||||
|
||||
|
||||
### 6. Helm ###
|
||||
|
||||
![](https://c2.staticflickr.com/2/1489/23310442334_5e6db22b79_c.jpg)
|
||||
|
||||
一些使用者喜欢它,但是其他人没有这么大的使用热情。我是后者的一部分。但在拥有这样一个庞大的追随者群体的情况下,是不可能避免提到它的。Helm旨在完全变换你的Emacs使用体验。简单描述,Helm是一个这样的框架,在Emacs下将帮助您快速找到一个文件或命令。根据您的输入,它将尝试使用词语自动完成指导你大脑的念头变为行动。起初感觉有点奇怪,但对一些人来说,Helm本身就是一个信仰。虽然我不是Helm的粉丝,我欣赏helm-occur这一个伟大的工具在一个大文档搜索字符串并且在一个单独的缓冲区显示所有,因此很容易导航。如果你正在寻找一个快速演示来了解Helm能做什么,我推荐这篇文章[3]。
|
||||
|
||||
|
||||
### 7. ace-jump-mode ###
|
||||
|
||||
![](https://c2.staticflickr.com/2/1710/23856168871_6df1faa565_c.jpg)
|
||||
|
||||
另一个插件有一大群追随者,我试图加入ace-jump-mode的粉丝群。拥有这个插件,你会体验到胜于鼠标的使用。简单的描述,通过触发ace-jump-mode您选择的快捷方式,你将被提示字符。输入一个字符,所有单词将会出现,独特的字母字符将突出显示。输入一个字母在屏幕上,和你的光标会直接跳转到词高亮显示。我不得不承认,这是让反射很难使用它,但是,一旦你拥有它,它会增加你的在一个文档里光标的移动速度。
|
||||
|
||||
|
||||
|
||||
### 8. find-file-in-project ###
|
||||
|
||||
![](https://c2.staticflickr.com/2/1492/23570808809_96ec8454a9_c.jpg)
|
||||
|
||||
如果你喜欢Sublime text和它非常方便的“Ctrl-p”模糊搜索打开在一个项目中的任何文件,你将会喜欢上find-file-in-project(或ffip)。通过声明您的版本控制的根文件夹设置后,您可以轻松地收集一个快速扫描的很酷的标题文本并根据您输入的名称匹配的通过代码库搜索文件。我喜欢把它绑定到键盘上面F6键。如果你不知道从你的顶层目录到最基本文件的复杂结构,它很简单,很方便。
|
||||
|
||||
|
||||
### 9. Flymake ###
|
||||
|
||||
![](https://c2.staticflickr.com/6/5708/23310442354_cbba657ed3.jpg)
|
||||
|
||||
IDE的爱好者,我认为语法检查器是IDE最强大的特性之一。它非常适合初学者和方便码累了的程序员。感谢Flymake,Emacs用户也可以享受语法检查器 。因为我工作很多需要PHP,Flymake不需要任何额外的配置。当我写代码的时候,它会自动检查我的代码和高亮任何一个包含一个问题的行。对于编译语言,Flymake将寻找一个Makefile,它将用来检查代码。绝对不可思议。
|
||||
|
||||
|
||||
|
||||
### 10. electric-pair ###
|
||||
|
||||
最后,但并非最不重要,在我看来,electric-pair是最简单但最强大的插件之一。它就自动关闭括号或打开括号。它期初看起来不是很好,但相信我。第一百次挣扎后发现匹配的括号,你会很高兴有一个插件,确保你所有的表达式都是平衡的。
|
||||
|
||||
|
||||
|
||||
总结一下,Emacs是一个奇妙的工具。这可不是一个令人惊哑的说法。试试这些插件和看着你的效率直线飙升。这当然不是详尽的列表。如果你想带来你的贡献,请在评论中这样做。我自己一直在寻找新的插件来体验Emacs,也在找寻新方法来体验Emacs。
|
||||
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://xmodulo.com/best-plugins-to-increase-productivity-on-emacs.html
|
||||
|
||||
作者:[Adrien Brochard][a]
|
||||
译者:[zky001](https://github.com/zky001)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://xmodulo.com/author/adrien
|
||||
[1]:http://xmodulo.com/turn-vim-full-fledged-ide.html
|
||||
[2]:http://orgmode.org/worg/org-tutorials/
|
||||
[3]:http://tuhdo.github.io/helm-intro.html
|
@ -1,235 +0,0 @@
|
||||
Grub 2:拯救你的 bootloader
|
||||
================================================================================
|
||||
**没什么事比 bootloader 坏掉更让气人的了。充分发挥 Grub 2 的作用,让 bootloader 安分工作吧。**
|
||||
|
||||
为什么这么说?
|
||||
|
||||
- Grub 2 是最受欢迎的 bootloader ,受用于几乎所有 Linux 发行版。
|
||||
- bootloader 是一个至关重要的软件,但是非常容易损坏。
|
||||
- Grub 2 是具有扩展性和灵活性一款引导加载程序,提供了大量可定制选项。
|
||||
|
||||
Grub 2 是一款精彩的功能强大的软件。它不是 bootloader 界一枝独秀,但却最受欢迎,几乎所有主要的桌面发行版都在使用它。 Grub 的工作有两个。首先,它用一个菜单展示计算机上所有已经安装的操作系统供你选择。然后,当你从启动菜单中选择了一个 Linux 操作系统, Grub 便加载这个 Linux 的内核。
|
||||
|
||||
你知道,如果使用 Linux ,你就离不开 bootloader 。然而它却是 Linux 发行版内部最鲜为人知的部分。在这个教程里,我们将带你熟悉 Grub 2 一些著名的特性,强化你相关技能,使你在 bootloader 跑飞的时候能够自行处理。
|
||||
|
||||
Grub 2 最重要的特色在于大量的 text 格式文件和两个脚本文件。首先需要了解的是 **/etc/default/grub** 。这是一个 text 文件,你可以在里面设置通用配置变量和 Grub 2 菜单(见标题为 “Common user settings(普通用户设置)” 的窗口)的其它特性。
|
||||
|
||||
Grub 2 另一个重要的特点在于 **/etc/grub.d** 文件夹。定义菜单入口的所有脚本都放置在这里。这些脚本的名称必须有两位的数字前缀。其目的是,在构建 Grub 2 菜单时定义脚本的执行顺序以及相应入口的顺序。文件 **00_header** 首先被读取,负责解析 **/etc/default/grub** 配置文件。然后是 Linux 内核的入口,位于 **10_linux** 文件中。这个脚本在默认的 **/boot** 分区为每个内核创建一个正规菜单入口和一个恢复菜单入口。
|
||||
|
||||
紧接着的是为第三方应用所用的脚本,如 **30_os-prober** 和 **40_custom** 。 **os-prober** 脚本为内核和其它分区里的操作系统创建入口。它能识别 Linux、 Windows、 BSD 以及 Mac OS X 的装置(译注,指 bootloader )。 如果你的硬盘设计比较独特,使得 **os-prober** 无法捕获已经安装的发行版,你可以在 **40_custom** 文件(见 “Add custom entries(添加定制入口)”窗口)中添加入口。
|
||||
|
||||
**Grub** 2 不需要你手动维护你的启动选项的配置文件:取而代之的是使用 **grub2-mkconfig** 命令产生 **/boot/grub/grub.cfg** 文件。这个功能会解析 **/etc/grub.d** 目录中的脚本以及 **/etc/default/grub** 设置文件来定义你的安装。
|
||||
|
||||
图形化引导修复
|
||||
|
||||
多亏了 Boot Repair 应用,只需要点击按钮,Grub 2 许许多多的问题都能轻易解决。这个小巧的应用有一个直观的用户界面,可以扫描并包含多种硬盘设计和分区方案,还能发现并正确识别里面的操作系统的装置(译注,指 bootloader )。这个应用可以以主引导记录 (MBR)形式存在于传统计算机里,也可以在新型 UEFI 计算机中以 GUID(译改,应为GUID)分区表布局方式工作。
|
||||
|
||||
Boot Repair 最简单的使用方式是在 Live Ubuntu 会话中安装。在机器上用一个坏的 bootloader 启动 Ubuntu Live 发行版,通过首次添加它的 PPA 版本库,安装 Boot Repair ,命令如下
|
||||
|
||||
sudo add-apt-repository ppa:yannubuntu/Boot Repair
|
||||
|
||||
然后刷新版本库列表,使用
|
||||
|
||||
sudo apt-get update
|
||||
|
||||
安装应用(译改,删了 before ),如下
|
||||
|
||||
sudo apt-get install -y Boot Repair
|
||||
|
||||
安装完毕立刻启动应用。在显示它的界面(由一对按键组成)之前将会扫描你的硬盘。根据工具的指示,只需按下 Recommended Repair(推荐修复)按钮,即可修复大部分坏掉的 bootloader 。修复 bootloader 之后,这个工具会输出一串短小的 URL ,你应该把它记录下来。这个 URL 包含了硬盘详尽的信息:分区信息以及 Grub 2 重要的文件(如 **/etc/default/grub** 和 **boot/grub/grub.cfg** )的内容。如果工具不能解决 bootloader 的问题,可以把你这个 URL 共享在你的发行版的论坛公告牌上,让其他人分析你的硬盘设计以便给你建议。
|
||||
|
||||
![](http://www.linuxvoice.com/wp-content/uploads/2015/10/boot-repair-large.jpg)
|
||||
|
||||
**Boot Repair 同样支持定制 Grub 2 的选项。**
|
||||
|
||||
#### Bootloader 急救 ####
|
||||
|
||||
Grub 2 引导问题会导致系统处于几种不同状态。屏幕(如你所想,本该显示 bootloader 菜单的地方)所展示的文本,指示系统的当前状态。如果系统中止于 **grub>** 提示符,表明 Grub 2 模块已经被加载,但是找不到 **grub.cfg** 文件。当前是全 Grub 2 命令shell,你可以通过多种方式解决此问题。如果你看到的是 **grub rescue>** 提示符,表明 bootloader 不能找到 Grub 2 模块或者找不到任何引导文件( boot files )。然而,如果你的屏幕只显示 ‘GRUB’ 一词,表明 bootloader 找不到通常位于主引导记录( Master Boot Record )里的最基本的信息。
|
||||
|
||||
你可以通过使用 live CD 或者在 Grub 2 shell中修正此类错误。如果你够幸运, bootloader 中止于 **grub>** 提示符,你将能获得 Grub 2 shell 的支配权,来帮助你排错。
|
||||
|
||||
接下来几个命令工作在 **grub>** 和 **grub rescue>** 提示符下。 **set pager=1** 命令产生分页器( pager ),防止文本在屏幕上被刷掉。你还可以使用 **ls** 命令列出 Grub 识别的分区,如下:
|
||||
|
||||
grub> ls
|
||||
(hd0) (hd0,msdos5) (hd0,msdos6) (hd1,msdos1)
|
||||
|
||||
如你所见,这个命令列出分区的同时一并列出了分区表计划。
|
||||
|
||||
你还可以在每个分区上面使用 **ls** 来查找根文件系统:
|
||||
|
||||
grub> ls (hd0,5)/
|
||||
lost+found/ var/ etc/ media/ bin/ initrd.gz
|
||||
boot/ dev/ home/ selinux/ srv/ tmp/ vmlinuz
|
||||
|
||||
你可以不写上分区名的 **msdos** 位。同样,如果你忘记尾斜杠( the trailing slash )只输入 **ls (hd0,5)** ,那你将获得分区的信息比如文件系统类型,总体大小和最后修改时间。如果你有多个分区,可以使用 **cat** 读取 **/etc/issue** 文件中的内容,来确定发行版,格式如 **cat (hd0,5)/etc/issue** 。
|
||||
|
||||
假设你在 **(hd0,5)** 中找到根文件系统,请确保它包含 /**boot/grub** 目录,以及你想引导进入的内核镜像,如 **vmlinuz-3.13.0-24-generic** 。此时输入以下命令:
|
||||
|
||||
grub> set root=(hd0,5)
|
||||
grub> linux /boot/vmlinuz-3.13.0-24-generic root=/dev/sda5
|
||||
grub> initrd /boot/initrd.img-3.13.0-24-generic
|
||||
|
||||
第一个命令把 Grub 指向我们想引导进入的发行版所在的分区。接着第二个命令告知 Grub 内核镜像在分区中的位置,以及根文件系统的位置。最后一行设置虚拟文件系统( initial ramdisk )文件的位置。你可以使用 tab 补全功能补全内核名字和虚拟文件系统( initrd: initial ramdisk )名字,节省时间和精力。
|
||||
|
||||
输入完毕,在下一个 **grub>** 提示符后输入 **boot** , Grub 将会引导进入指定的操作系统。
|
||||
|
||||
在 **grub rescue>** 提示符下,情况会有些许不同。因为 bootloader 未能够找到并加载任何必需的模块,你需要手动添加这些模块:
|
||||
|
||||
grub rescue> set root=(hd0,5)
|
||||
grub rescue> insmod (hd0,5)/boot/grub/normal.mod
|
||||
grub rescue> normal
|
||||
grub> insmod linux
|
||||
|
||||
如上所示,跟之前一样,使用 **ls** 命令列出所有分区之后,使用 **set** 命令标记起来。然后添加 **normal** 模块,此模块激活时将会恢复标准 **grub>** 模式。如果 linux 模块没加载,接下来的命令会进行添加。如果这个模块已经加载,你可以跟之前一样,把引导加载程序指向内核镜像和虚拟文件系统( initrd )文件,然后使用 **boot** 启动发行版,完美收官。
|
||||
|
||||
一旦成功启动发行版,别忘了为 Grub 重新产生新的配置文件,使用
|
||||
|
||||
grub-mkconfig -o /boot/grub/grub.cfg
|
||||
|
||||
命令。你还需要往 MBR 里安装一份 bootloader 的拷贝,使用
|
||||
|
||||
sudo grub2-install /dev/sda
|
||||
|
||||
命令。
|
||||
|
||||
![](http://www.linuxvoice.com/wp-content/uploads/2015/10/grub2-cfg-large.jpg)
|
||||
|
||||
**想要禁能 /etc/grub.d 目录下的脚本,你只需移除可执行位,比如使用 chmod -x /etc/grub.d/20_memtest86+ 就能将 ‘Memory Test’ 选项从菜单中移除。**
|
||||
|
||||
### Grub 2 和 UEFI ###
|
||||
|
||||
支持UEFI的机器(最近几年上市的机器大部分都是)添加了另一复杂的层次,用以调试坏掉的 **Grub 2**。恢复 **Grub 2** 的程序在 UEFI 机器上安装和在非 UEFI 机器上安装并没多大区别,只是新程序处理方式不一样,从而导致了很多种恢复结果。
|
||||
|
||||
对于基于 UEFI 的系统,不要在 MBR上安装任何东西。相反,你要在 EFI 系统分区( ESP )里安装 EFI bootloader,并且借助工具把它设置为 EFI 的默认启动程序,这个工具对于 Linux 用户是 **efibootmgr** ,对于 window 用户则是 **bcdedit** 。
|
||||
|
||||
照目前情况看,在安装任何与 Windows 8 兼容的主流桌面 Linux 发行版前, Grub 2 应该完成正确安装。然而,如果 bootloader 损坏,你可以使用 live 发行版进行机器修复。在启动 live 媒介之时,请确保是以 UEFI模式启动。计算机每个可移动驱动的启动菜单将会有两个选项: vanilla 选项和以 EFI 标记的选项。使用后者开放 **/sys/firmware/efi/** 文件中的 EFI 变量。
|
||||
|
||||
在 live 环境中,挂载教程前面所提的安装失败的装置(译注,指 bootloader )的根文件系统。除此之外,还需要挂载 ESP 分区。假设分区是 **/dev/sda1** ,你可以如下所示挂载
|
||||
|
||||
sudo mount /dev/sda1 /mnt/boot/efi
|
||||
|
||||
接着在 chroot 到安装完毕的发行版前之前,使用 **modprobe efivars** 加载 **efivars** 模块。
|
||||
|
||||
这个时候, Fedora 用户使用如下命令重新安装 bootloader
|
||||
|
||||
yum reinstall grub2-efi shim
|
||||
|
||||
在此之前,需要使用
|
||||
|
||||
grub2-mkconfig -o /boot/grub2/grub.cfg
|
||||
|
||||
来产生新的配置文件。 Ubuntu 用户则改用以下命令
|
||||
|
||||
apt-get install --reinstall grub-efi-amd64
|
||||
|
||||
一旦 bootloader 正确就位,退出 chroot ,取消挂载所有分区,重启让 Grub 2 菜单显示。
|
||||
|
||||
#### 伙计,我的 Grub 哪去了? ####
|
||||
|
||||
Grub 2 最好的特性是可以随时重新安装。因此,当其它像 Windows 之类的系统用自己的 bootloader 替换之,导致 Grub 2 丢失,你可以使用 live 发行版,寥寥数步即可重装 Grub 。假设你在 **/dev/sda5** 安装了一个发行版,若要重装 Grub ,你只需首先使用以下命令,为发行版创建一个挂载目录
|
||||
|
||||
sudo mkdir -p /mnt/distro
|
||||
|
||||
然后挂载分区,如下
|
||||
|
||||
mount /dev/sda5 /mnt/distro
|
||||
|
||||
接着就能重装 Grub 了,如下
|
||||
|
||||
grub2-install --root-directory=/mnt/distro /dev/sda
|
||||
|
||||
这个命令会改写 **/dev/sda** 设备上的 MBR 信息,指向当前 Linux 的装置(译注,指 bootloader ),并改写 Grub 2 部分文件如 **grubenv** 和 **device.map** 。
|
||||
|
||||
另一个问题常见于装有多个发行版的计算机上。安装了新的 Linux 发行版,它的 bootloader 应当要能捕获所有已经安装的发行版。一旦不能够,只要引导进入新安装的发行版,并运行
|
||||
|
||||
grub2-mkconfig
|
||||
|
||||
运行命令之前,请确保发行版的启动菜单中缺失的 root 分区已经完成挂载。如果你想添加的发行版有独立 **/root** 和 **/home** 分区,在运行 **grub2-mkconfig** 之前,只需挂载包含 /root 的分区。
|
||||
|
||||
虽然 Grub 2 能够捕获大部分发行版,但是在 Ubuntu 中尝试添加 Fedora 的装置(译注,指 bootloader )需要额外的一个步骤。如果你以默认设置安装了 Fedora ,则发行版的安装器(译注,同样指 bootloader )已经创建了 LVM 分区。此时你需要使用发行版的包管理系统,安装 **lvm2** 驱动,如下
|
||||
|
||||
sudo apt-get install lvm2
|
||||
|
||||
才能使得 Grub 2 的 **os-prober** 脚本能够找到并将 Fedora 添加进启动菜单。
|
||||
|
||||
### 普通用户设置 ###
|
||||
|
||||
Grub 2 有很多可配置变量。 **/etc/default/grub** 文件里有很多你最可能会修改到的普通变量。 **GRUB_DEFAULT** 变量指定默认的启动入口,可以设置为数字值,比如 0 ,表示第一个入口,或者设置为 “saved” ,将它从指向上一次启动时选中的选项。 **GRUB_TIMEOUT** 变量指定启动默认菜单入口之前的停留时间。 **GRUB_CMDLINE_LINUX** 为所有 Linux 菜单入口列出在内核命令行上传递的参数。
|
||||
|
||||
如果 **GRUB_DISABLE_RECOVERY** 变量设置为 **true** ,那么将不产生恢复模式菜单入口。这些入口以单用户模式启动发行版,这种模式下允许你利用命令行工具修复系统。 **GRUB_GFXMODE** 变量同样有用,它指定了菜单上文本显示的分辨率,它可以设置为你的显卡所支持的任何数值。
|
||||
|
||||
![](http://www.linuxvoice.com/wp-content/uploads/2015/10/grub2-cli-large.jpg)
|
||||
|
||||
** Grub 2 有其命令行,通过在 bootloader 菜单上按 C 调用。**
|
||||
|
||||
#### 彻底的修复 ####
|
||||
|
||||
如果 **grub2-install** 命令不能正常运作,使得你无法引导进入 Linux ,你需要完整地重装以及重新配置 bootloader 。为此目的,需要用到神圣的 **chroot** 应用将 live CD 环境切换至并运行我们想修复的 Linux 的安装环境。任何拥有 **chroot** 工具的 Linux live CD 都可以实现这个目的。不过需要确保 live 媒介的架构和硬盘上系统的架构一致。因此当你希望 **chroot** 到 64 位系统,你必须使用 amd64 live 发行版。
|
||||
|
||||
启动进入 live 发行版之后,首先需要检查机器上的分区。使用 **fdisk -l** 列出磁盘上所有分区,记录你想修复的 Grub 2 装置所在的分区。
|
||||
|
||||
假设我们希望从安装在 **/dev/sda5** 中的发行版中恢复 bootloader 。启动终端使用如下命令挂载分区:
|
||||
|
||||
sudo mount /dev/sda5 /mnt
|
||||
|
||||
此时需要绑定 Grub 2 bootloader 需要进入的目录,以便检测其它操作系统:
|
||||
|
||||
$ sudo mount --bind /dev /mnt/dev
|
||||
$ sudo mount --bind /dev/pts /mnt/dev/pts
|
||||
$ sudo mount --bind /proc /mnt/proc
|
||||
$ sudo mount --bind /sys /mnt/sys
|
||||
|
||||
此时可以离开 live 环境进入安装在 **/dev/sda5** 分区中的发行版了,通过 **chroot** :
|
||||
|
||||
$ sudo chroot /mnt /bin/bash
|
||||
|
||||
现在可以安装、检测、以及升级 Grub 了,跟之前一样,使用
|
||||
|
||||
sudo grub2-install /dev/sda
|
||||
|
||||
命令来重装 bootloader 。因为 **grub2-install** 命令不能 创建**grub.cfg** 文件,需要手动创建,如下
|
||||
|
||||
sudo grub-mkconfig -o /boot/grub/grub.cfg
|
||||
|
||||
这样应该就可以了。现在你就有了 Grub 2 的一份全新拷贝,罗列机器上所有的操作系统和发行版。在重启电脑之前,你需要依次退出 chroot 系统,卸载所有分区,如下所示:
|
||||
|
||||
$ exit
|
||||
$ sudo umount /mnt/sys
|
||||
$ sudo umount /mnt/proc
|
||||
$ sudo umount /mnt/dev/pts
|
||||
$ sudo umount /mnt/dev
|
||||
$ sudo umount /mnt
|
||||
|
||||
现在你可以安全地重启电脑了,而它应该会回退到 Grub 2 的控制之中,而你又控制着这个 bootloader 。
|
||||
|
||||
### 添加自定义入口 ###
|
||||
|
||||
如果希望往 bootloader 菜单里添加入口,你需要在 **40_custom** 文件里添加一个启动段( boot stanza )。例如,你可以使用它展示一个入口来启动安装在可移动 USB 驱动里的 Linux 发行版。假设你的 USB 驱动是 **sdb1** ,并且 vmlinuz 内核镜像和虚拟文件系统( initrd )都位于根 (/)目录下,在 **40_custom** 文件中添加以下内容:
|
||||
|
||||
menuentry “Linux on USB” {
|
||||
set root=(hd1,1)
|
||||
linux /vmlinuz root=/dev/sdb1 ro quiet splash
|
||||
initrd /initrd.img
|
||||
}
|
||||
|
||||
相比使用设备和分区名,使用它们的 UUID 可以获得更精确结果,比如
|
||||
|
||||
set root=UUID=54f22dd7-eabe
|
||||
|
||||
使用
|
||||
|
||||
sudo blkid
|
||||
|
||||
来获得所有已连接驱动和分区的 UUID 。你还可以为你磁盘上没被 os-prober 脚本捕获的发行版添加入口,只要你知道该发行版的安装位置以及其内核和虚拟文件系统( initrd )的定位即可。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.linuxvoice.com/grub-2-heal-your-bootloader/
|
||||
|
||||
作者:[Mayank Sharma][a]
|
||||
译者:[soooogreen](https://github.com/soooogreen)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://www.linuxvoice.com/author/mayank/
|
@ -0,0 +1,284 @@
|
||||
LFCS 系列第六讲:组装分区为RAID设备——创建和管理系统备份
|
||||
=========================================================
|
||||
Linux 基金会已经发起了一个全新的 LFCS(Linux Foundation Certified Sysadmin,Linux 基金会认证系统管理员)认证,旨在让来自世界各地的人有机会参加到 LFCS 测试,获得关于有能力在 Linux 系统中执行中间系统管理任务的认证。该认证包括:维护正在运行的系统和服务的能力、全面监控和分析的能力以及何时上游团队请求支持的决策能力。
|
||||
|
||||
![Linux Foundation Certified Sysadmin – Part 6](http://www.tecmint.com/wp-content/uploads/2014/10/lfcs-Part-6.png)
|
||||
|
||||
LFCS 系列第六讲
|
||||
|
||||
以下视频介绍了 Linux 基金会认证程序。
|
||||
|
||||
注:youtube 视频
|
||||
<iframe width="720" height="405" frameborder="0" allowfullscreen="allowfullscreen" src="//www.youtube.com/embed/Y29qZ71Kicg"></iframe>
|
||||
|
||||
本讲是《十套教程》系列中的第六讲,在这一讲里,我们将会解释如何组装分区为RAID设备——创建和管理系统备份。这些都是 LFCS 认证中的必备知识。
|
||||
|
||||
### 了解RAID ###
|
||||
|
||||
一种被称为独立磁盘冗余阵列(RAID)的技术是将多个硬盘组合成一个单独逻辑单元的存储解决方案,它提供了数据冗余功能并且改善硬盘的读写操作性能。
|
||||
|
||||
然而,实际的容错和磁盘I/O性能硬盘取决于如何将多个硬盘组装成磁盘阵列。根据可用的设备和容错/性能的需求,RAID被分为不同的级别,你可以在Tecmint.com上参考RAID系列文章以获得每个RAID级别更详细的解释。
|
||||
|
||||
- RAID Guide: [What is RAID, Concepts of RAID and RAID Levels Explained][1]
|
||||
|
||||
我们选择用于创建、组装、管理、监视软件RAID的工具,叫做mdadm(multiple disk admin的简写)。
|
||||
|
||||
```
|
||||
---------------- Debian and Derivatives ----------------
|
||||
# aptitude update && aptitude install mdadm
|
||||
```
|
||||
|
||||
```
|
||||
---------------- Red Hat and CentOS based Systems ----------------
|
||||
# yum update && yum install mdadm
|
||||
```
|
||||
|
||||
```
|
||||
---------------- On openSUSE ----------------
|
||||
# zypper refresh && zypper install mdadm #
|
||||
```
|
||||
|
||||
#### 组装分区作为RAID设备 ####
|
||||
|
||||
组装已有分区作为RAID设备的过程由以下步骤组成。
|
||||
|
||||
**1. 使用mdadm创建阵列**
|
||||
|
||||
如果先前其中一个分区被格式化,或者作为了另一个RAID阵列的一部分,你会被提示以确认创建一个新的阵列。假设你已经采取了必要的预防措施以避免丢失重要数据,那么可以安全地输入Y并且按下回车。
|
||||
|
||||
```
|
||||
# mdadm --create --verbose /dev/md0 --level=stripe --raid-devices=2 /dev/sdb1 /dev/sdc1
|
||||
```
|
||||
|
||||
![Creating RAID Array](http://www.tecmint.com/wp-content/uploads/2014/10/Creating-RAID-Array.png)
|
||||
|
||||
创建RAID阵列
|
||||
|
||||
**2. 检查阵列的创建状态**
|
||||
|
||||
在创建了RAID阵列之后,你可以检查使用以下命令检查阵列的状态。
|
||||
|
||||
|
||||
# cat /proc/mdstat
|
||||
or
|
||||
# mdadm --detail /dev/md0 [More detailed summary]
|
||||
|
||||
![Check RAID Array Status](http://www.tecmint.com/wp-content/uploads/2014/10/Check-RAID-Array-Status.png)
|
||||
|
||||
检查RAID阵列的状态
|
||||
|
||||
**3. 格式化RAID设备**
|
||||
|
||||
如本系列[Part 4][2]所介绍的,按照你的需求/要求采用某种文件系统格式化你的设备。
|
||||
|
||||
4. 监控RAID阵列服务
|
||||
|
||||
指示监控服务时刻监视你的RAID阵列。把```# mdadm --detail --scan```命令输出结果添加到/etc/mdadm/mdadm.conf(Debian和derivatives)或者/etc/mdadm.conf(Cent0S/openSUSE),如下。
|
||||
|
||||
# mdadm --detail --scan
|
||||
|
||||
|
||||
![Monitor RAID Array](http://www.tecmint.com/wp-content/uploads/2014/10/Monitor-RAID-Array.png)
|
||||
|
||||
监控RAID阵列
|
||||
|
||||
# mdadm --assemble --scan [Assemble the array]
|
||||
|
||||
为了确保服务能够开机启动,需要以root权限运行以下命令。
|
||||
|
||||
**Debian 和 Derivatives**
|
||||
|
||||
Debian 和 Derivatives能够通过下面步骤使服务默认开机启动
|
||||
|
||||
# update-rc.d mdadm defaults
|
||||
|
||||
在/etc/default/mdadm文件中添加下面这一行
|
||||
|
||||
AUTOSTART=true
|
||||
|
||||
|
||||
**CentOS 和 openSUSE(systemd-based)**
|
||||
|
||||
# systemctl start mdmonitor
|
||||
# systemctl enable mdmonitor
|
||||
|
||||
**CentOS 和 openSUSEi(SysVinit-based)**
|
||||
|
||||
# service mdmonitor start
|
||||
# chkconfig mdmonitor on
|
||||
|
||||
**5. 检查RAID磁盘故障**
|
||||
|
||||
在支持冗余的的RAID级别中,在需要时会替换故障的驱动器。当磁盘阵列中的设备出现故障时,仅当存在我们第一次创建阵列时预留的备用设备时,磁盘阵列会将自动启动重建。
|
||||
|
||||
![Check RAID Faulty Disk](http://www.tecmint.com/wp-content/uploads/2014/10/Check-RAID-Faulty-Disk.png)
|
||||
|
||||
检查RAID故障磁盘
|
||||
|
||||
否则,我们需要手动连接一个额外的物理驱动器到我们的系统,并且运行。
|
||||
|
||||
# mdadm /dev/md0 --add /dev/sdX1
|
||||
|
||||
/dev/md0是出现了问题的阵列,而/dev/sdx1是新添加的设备。
|
||||
|
||||
**6. 分解一个工作阵列**
|
||||
|
||||
如果你需要使用工作阵列的设备创建一个新的阵列,你可能不得不去分解已有工作阵列——(可选步骤)
|
||||
|
||||
# mdadm --stop /dev/md0 # Stop the array
|
||||
# mdadm --remove /dev/md0 # Remove the RAID device
|
||||
# mdadm --zero-superblock /dev/sdX1 # Overwrite the existing md superblock with zeroes
|
||||
|
||||
**7. 设置邮件通知**
|
||||
|
||||
你可以配置一个用于发送通知的有效邮件地址或者系统账号(确保在mdadm.conf文件中有下面这一行)。——(可选步骤)
|
||||
|
||||
MAILADDR root
|
||||
|
||||
在这种情况下,来自RAID后台监控程序所有的通知将会发送到你的本地root账号的邮件箱中。其中一个类似的通知如下。
|
||||
|
||||
说明:此次通知事件和第5步中的例子相关。一个设备被标志为错误并且一个空闲的设备自动地被mdadm加入到阵列。我们用完了所有"健康的"空闲设备,因此我们得到了通知。
|
||||
|
||||
![RAID Monitoring Alerts](http://www.tecmint.com/wp-content/uploads/2014/10/RAID-Monitoring-Alerts.png)
|
||||
|
||||
RAID监控通知
|
||||
|
||||
#### 了解RAID级别 ####
|
||||
|
||||
** RAID 0 **
|
||||
|
||||
阵列总大小是最小分区大小的n倍,n是阵列中独立磁盘的个数(你至少需要两个驱动器/磁盘)。运行下面命令,使用/dev/sdb1和/dev/sdc1分区组装一个RAID 0 阵列。
|
||||
|
||||
# mdadm --create --verbose /dev/md0 --level=stripe --raid-devices=2 /dev/sdb1 /dev/sdc1
|
||||
|
||||
常见用途:用于支持性能比容错更重要的实时应用程序的设置
|
||||
|
||||
**RAID 1 (又名镜像/Mirroring)**
|
||||
|
||||
阵列总大小等于最小分区大小(你至少需要两个驱动器/磁盘)。运行下面命令,使用/dev/sdb1和/dev/sdc1分区组装一个RAID 1 阵列。
|
||||
|
||||
# mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 /dev/sdb1 /dev/sdc1
|
||||
|
||||
常见用途:操作系统的安装或者重要的子文件夹,例如 /home
|
||||
|
||||
**RAID 5 (又名奇偶校验码盘/drives with Parity)**
|
||||
|
||||
阵列总大小将是最小分区大小的(n-1)倍。//用于奇偶校验(冗余)计算(你至少需要3个驱动器/磁盘)。
|
||||
|
||||
说明:你可以指定一个空闲设备(/dev/sde1)替换问题出现时的故障部分(分区)。运行下面命令,使用/dev/sdb1, /dev/sdc1, /dev/sdd1,/dev/sde1组装一个RAID 5 阵列,其中/dev/sde1作为空闲分区。
|
||||
|
||||
# mdadm --create --verbose /dev/md0 --level=5 --raid-devices=3 /dev/sdb1 /dev/sdc1 /dev/sdd1 --spare-devices=1 /dev/sde1
|
||||
|
||||
常见用途:Web和文件服务
|
||||
|
||||
**RAID 6 (又名双重奇偶校验码盘/drives with double Parity)**
|
||||
|
||||
阵列总大小为(n*s)-2*s,其中n为阵列中独立磁盘的个数,s为最小磁盘大小。
|
||||
|
||||
说明:你可以指定一个空闲分区(在这个例子为/dev/sdf1)替换问题出现时的故障部分(分区)。
|
||||
|
||||
运行下面命令,使用/dev/sdb1, /dev/sdc1, /dev/sdd1, /dev/sde1和/dev/sdf1组装RAID 6阵列,其中/dev/sdf1作为空闲分区。
|
||||
|
||||
# mdadm --create --verbose /dev/md0 --level=6 --raid-devices=4 /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde --spare-devices=1 /dev/sdf1
|
||||
|
||||
常见用途:大容量、高可用性要求的文件服务器和备份服务器。
|
||||
|
||||
**RAID 1+0 (又名镜像条带/stripe of mirrors)**
|
||||
|
||||
因为RAID 1+0是RAID 0 和 RAID 1的组合,所以阵列总大小是基于两者的公式计算的。首先,计算每一个镜像的大小,然后再计算条带的大小。
|
||||
|
||||
|
||||
# mdadm --create --verbose /dev/md0 --level=10 --raid-devices=4 /dev/sd[b-e]1 --spare-devices=1 /dev/sdf1
|
||||
|
||||
常见用途:需要快速IO操作的数据库和应用服务器
|
||||
|
||||
#### 创建和管理系统备份 ####
|
||||
|
||||
记住RAID其所有的价值不是在于备份的替换者是对你有益的!在黑板上写上1000次,如果你需要的话,但无论何时一定要记住它。在我们开始前,我们必须注意的是,没有一个放之四海皆准的针对所有系统备份的解决方案,但这里有一些东西,是你在规划一个备份策略时需要考虑的。
|
||||
|
||||
- 你的系统将用于什么?(桌面或者服务器?如果系统是应用于后者,那么最重要的服务是什么——//其配置?)
|
||||
- 你每隔多久备份你的系统?
|
||||
- 你需要备份的数据是什么(比如 文件/文件夹/数据库转储)?你还可以考虑是否需要备份大型文件(比如音频和视频文件)。
|
||||
- 这些备份将会存储在哪里(物理位置和媒体)?
|
||||
|
||||
**备份你的数据**
|
||||
|
||||
方法1:使用dd命令备份整个磁盘。你可以在任意时间点通过创建一个准确的镜像来备份一整个硬盘或者是分区。注意当设备是离线时,这种方法效果最好,也就是说它没有被挂载并且没有任何进程的I/O操作访问它。
|
||||
|
||||
这种备份方法的缺点是镜像将具有和磁盘或分区一样的大小,即使实际数据占用的是一个很小的比例。比如,如果你想要为只使用了10%的20GB的分区创建镜像,那么镜像文件将仍旧是20GB。换句话来讲,它不仅包含了备份的实际数据,而且也包含了整个分区。如果你想完整备份你的设备,那么你可以考虑使用这个方法。
|
||||
|
||||
**从现有的设备创建一个镜像文件**
|
||||
|
||||
# dd if=/dev/sda of=/system_images/sda.img
|
||||
或者
|
||||
--------------------- 可选地,你可以压缩镜像文件 -------------------
|
||||
# dd if=/dev/sda | gzip -c > /system_images/sda.img.gz
|
||||
|
||||
**从镜像文件恢复备份**
|
||||
|
||||
# dd if=/system_images/sda.img of=/dev/sda
|
||||
或者
|
||||
--------------------- 根据你创建镜像文件时的选择(译者注:比如压缩) ----------------
|
||||
# gzip -dc /system_images/sda.img.gz | dd of=/dev/sda
|
||||
|
||||
方法2:使用tar命令备份确定的文件/文件夹——已经在本系列[Part 3][3]中讲了。如果你想要备份指定的文件/文件夹(配置文件,用户主目录等等),你可以使用这种方法。
|
||||
|
||||
方法3:使用rsync命令同步文件。rsync是一种多功能远程(和本地)文件复制工具。如果你想要从网络设备备份或同步文件,rsync是一种选择。
|
||||
|
||||
|
||||
无论是你是正在同步两个本地文件夹还是本地 < — > 挂载在本地文件系统的远程文件夹,其基本语法是一样的。
|
||||
|
||||
# rsync -av source_directory destination directory
|
||||
|
||||
在这里,-a 递归遍历子目录(如果它们存在的话),维持符号链接、时间戳、权限以及原本的属主/属组,-v 显示详细过程。
|
||||
|
||||
![rsync Synchronizing Files](http://www.tecmint.com/wp-content/uploads/2014/10/rsync-synchronizing-Files.png)
|
||||
|
||||
rsync 同步文件
|
||||
|
||||
除此之外,如果你想增加在网络上传输数据的安全性,你可以通过rsync使用ssh协议。
|
||||
|
||||
**通过ssh同步本地 → 远程文件夹**
|
||||
|
||||
# rsync -avzhe ssh backups root@remote_host:/remote_directory/
|
||||
|
||||
这个示例,本地主机上的backups文件夹将与远程主机上的/root/remote_directory的内容同步。
|
||||
|
||||
在这里,-h 选项以人可读的格式显示文件的大小,-e 标志用于表示一个ssh连接。
|
||||
|
||||
![rsync Synchronize Remote Files](http://www.tecmint.com/wp-content/uploads/2014/10/rsync-synchronize-Remote-Files.png)
|
||||
|
||||
rsync 同步远程文件
|
||||
|
||||
**通过ssh同步远程 → 本地 文件夹**
|
||||
|
||||
在这种情况下,交换前面示例中的source和destination文件夹。
|
||||
|
||||
# rsync -avzhe ssh root@remote_host:/remote_directory/ backups
|
||||
|
||||
请注意这些只是rsync用法的三个示例而已(你可能遇到的最常见的情形)。对于更多有关rsync命令的示例和用法 ,你可以查看下面的文章。
|
||||
|
||||
- Read Also: [10 rsync Commands to Sync Files in Linux][4]
|
||||
|
||||
### Summary ###
|
||||
|
||||
作为一个系统管理员,你需要确保你的系统表现得尽可能好。如果你做好了充分准备,并且如果你的数据完整性能被诸如RAID和系统日常备份的存储技术支持,那你将是安全的。
|
||||
|
||||
如果你有有关完善这篇文章的问题、评论或者进一步的想法,可以在下面畅所欲言。除此之外,请考虑通过你的社交网络简介分享这系列文章。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.tecmint.com/creating-and-managing-raid-backups-in-linux/
|
||||
|
||||
作者:[Gabriel Cánepa][a]
|
||||
译者:[cpsoture](https://github.com/cposture)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.tecmint.com/author/gacanepa/
|
||||
[1]:http://www.tecmint.com/understanding-raid-setup-in-linux/
|
||||
[2]:http://www.tecmint.com/create-partitions-and-filesystems-in-linux/
|
||||
[3]:http://www.tecmint.com/compress-files-and-finding-files-in-linux/
|
||||
[4]:http://www.tecmint.com/rsync-local-remote-file-synchronization-commands/
|
||||
|
Loading…
Reference in New Issue
Block a user