ubuntu恢复系统
Don’t try to convince yourself otherwise: along with all the good stuff, you’re going to have bad days with Linux.
否则,请不要试图说服自己:与所有好的东西一起,您将在Linux上度过糟糕的日子。
You (or the users you support) are going to mistype commands and permanently destroy documents.您(或您支持的用户)将输错命令并永久销毁文档。 You’re going to experience that sinking feeling when you realize that some really important piece of hardware or software has just gone and failed. That’s gratitude after everything you did for it all those years.当您意识到某些非常重要的硬件或软件已经失效并失败时,您将体验到那种下沉的感觉。 这些年来,您所做的一切都是对您的感谢。
Being properly backed up means that you can walk away from a non-functioning OS or computer and rebuild it all somewhere else. But that’s always going to be Plan B. Plan A is to recover.
正确备份意味着您可以离开运行不正常的操作系统或计算机,然后在其他任何地方重建它们。 但这始终是计划B。计划A是要恢复。
在Ubuntu上使用恢复模式 (Using recovery mode on Ubuntu)
Linux not letting you log in normally (perhaps the boot process unexpectedly stops before displaying the login screen, for instance)? You’ll want some basic system administration tools.
Linux是否不允许您正常登录(例如,引导过程在显示登录屏幕之前意外停止了?)? 您将需要一些基本的系统管理工具。
But wait: if Linux won’t load, how are you going to launch those tools? Well, even if Linux won’t load all the way to a normal command prompt, often it’ll get you to the GRUB menu. From there you can use the up and down arrow keys and then Enter to select a Linux kernel running in recovery mode which, as you’ll soon see, will open up a whole bag of tricks.
但是请稍等:如果Linux无法加载,您将如何启动这些工具? 好吧,即使Linux不会一路加载到正常的命令提示符下,它通常也会带您进入GRUB菜单。 从那里,您可以使用向上和向下箭头键,然后按Enter选择运行在恢复模式下的Linux内核,您很快就会看到,它将打开一整套窍门。
As you can see from the figure below, once Ubuntu is loaded in recovery mode, you’ll be shown a menu of tools that address some common boot-time problems. It’s worth trying each one that seems like it might address your root problem. “Clean”, for instance, will remove unused files if you suspect the trouble stems from a full disk. “dpkg” will attempt to fix any broken apt-based software packages that might be gumming things up. (The “dpkg” tool might require that you first enable networking.)
从下图可以看出,以恢复模式加载Ubuntu后,将显示一个工具菜单,该工具可以解决一些常见的启动时问题。 值得尝试似乎可以解决您的根本问题的每一个。 例如,如果您怀疑问题是由于磁盘已满,“干净”将删除未使用的文件。 “ dpkg”将尝试修复任何破坏了apt的软件包,这些软件包可能会使事情陷入困境。 (“ dpkg”工具可能要求您首先启用网络。)
The “root” option will open a root command line shell session for you where you’ll have Bash at your disposal. In general, using a simple shell session for recovery rather than a full GUI desktop makes a lot of sense, because the fewer complicated services you’ve got running, the more likely it is that you’ll be able to at least get your system running. Once youdomanage to get a working command prompt, you can start poking around to see if you can identify and fix the problem.
“ root”选项将为您打开一个根命令行shell会话,您将在其中使用Bash。 通常,使用简单的shell会话进行恢复而不是使用完整的GUI桌面很有用,因为您运行的复杂服务越少,至少能够获得系统的可能性就越大。运行。 一旦你设法得到一个工作命令提示符下,你就可以开始闲逛,看看你是否能够识别并解决问题。
But at the very least, you’ll look mighty cool doing it.
但是至少,这样做会看起来非常酷。
But whatarethose tools? Got an Ubuntu machine running? Go take a look for yourself. The code running the menu must already exist somewhere within an Ubuntu file system. Use “locate” to find it.
但那些是什么工具? 有Ubuntu计算机在运行吗? 你自己去看看 运行菜单的代码必须已经存在于Ubuntu文件系统中的某个位置。 使用“定位”找到它。
locate recovery-mode/lib/recovery-mode/lib/recovery-mode/l10n.sh/lib/recovery-mode/options/lib/recovery-mode/recovery-menu/lib/recovery-mode/options/apt-snapshots/lib/recovery-mode/options/clean/lib/recovery-mode/options/dpkg/lib/recovery-mode/options/failsafeX/lib/recovery-mode/options/fsck/lib/recovery-mode/options/grub/lib/recovery-mode/options/network/lib/recovery-mode/options/root/lib/recovery-mode/options/system-summary
Note that the “l10n.sh” script sets appropriate environment variables for the menu. If you navigate over to the /lib/recovery-mode/ directory you’ll see that the “recovery-menu” file is the script that displays the menu interface that you saw above. The /lib/recovery-mode/options/ directory contains files for executing each of the menu items…like “fsck” that will check and, if possible, fix any broken file systems.
请注意,“ l10n.sh”脚本为菜单设置了适当的环境变量。 如果导航到/ lib / recovery-mode /目录,您将看到“ recovery-menu”文件是显示您在上面看到的菜单界面的脚本。 / lib / recovery-mode / options /目录包含用于执行每个菜单项的文件,例如“ fsck”,它将检查并(如果可能)修复损坏的文件系统。
Since, based on previous chapters in the book, you’re now an accomplished Bash scripting expert, why not take a look at each of the scripts in the options/ directory to see if you can figure out how they work. Here are the contents of the “fsck” script to get you going. Note the way the script is nicely documented (using the “#” character) to help you understand what’s going on.
由于根据您本书的前几章,您现在是一名精通Bash脚本的专家,所以为什么不看看options /目录中的每个脚本来看看您是否可以了解它们的工作原理。 以下是“ fsck”脚本的内容,可助您一臂之力。 请注意,脚本的记录方式(使用“#”字符)可以很好地帮助您了解正在发生的事情。
cat /lib/recovery-mode/options/fsck#!/bin/sh. /lib/recovery-mode/l10n.sh <1>if [ "$1" = "test" ]; thenecho $(eval_gettext "Check all file systems")exit 0fi# Actual code is in recovery-menu itself <2>exit 0
Here are a couple of things you can try on your own:
您可以尝试以下几项:
Manually run the “clean” script on a Debian/Ubuntu machine. What happened?在Debian / Ubuntu机器上手动运行“ clean”脚本。 发生了什么?
Then trycarefullyediting the /lib/recovery-mode/recovery-menu script (make a backup copy first). Perhaps just change something simple, like the menu title or one of the script descriptions. Then reboot your machine and, from the GRUB menu, go into Recovery Mode to see what it looks like.
然后尝试仔细编辑/ lib / recovery-mode / recovery-menu脚本(首先制作备份副本)。 也许只需更改一些简单的内容,例如菜单标题或脚本描述之一。 然后重新启动计算机,然后从GRUB菜单进入“恢复模式”以查看其外观。
With some variations and exceptions, you should be able to put those examples to good use elsewhere.
有了一些变体和例外,您应该能够在其他地方充分利用这些示例。
This article is adapted from chapter 6 (Emergency tools: build a system recovery device) of myManning “Linux in Action” book. There’s lots more fun where this came from, including a hybrid course called Linux in Motion that’s made up of more than two hours of video and around 40% of the text ofLinux in Action. Who knows…you might also enjoy myLearn Amazon Web Services in a Month of Lunches.
本文改编自Manning的《 Linux in Action》一书的第6章(紧急工具:构建系统恢复设备)。这有很多有趣的地方,包括一个名为Linux in Motion的混合课程,该课程由两个多小时的视频和大约40%的Linux in Action文本组成。谁知道……您可能还会在一个月的午餐中享受我的Learn Amazon Web Services。
翻译自: /news/the-ubuntu-recovery-menu-demystifying-linux-system-recovery/
ubuntu恢复系统