98rat_如何使用E4rat將Linux PC的啟動時間縮短一半
98rat
Linux is pretty quick to boot on modern computers, but why not pare it down some more? If you’re hurting from a lack of SSD or just want to boot faster, E4rat will easily shave down your boot time.
Linux可以在現代計算機上快速啟動,但是為什麼不減少它呢? 如果您因缺少SSD而受到傷害或者只是想更快地啟動,E4rat可以輕鬆縮短啟動時間。
Note:this article was written for Ubuntu 11.04 so it’s very possible that it doesn’t work anymore.
注意:本文是針對Ubuntu 11.04編寫的,因此很可能不再起作用。
E4rat和您Linux PC (E4rat and Your Linux PC)
E4rat is a utility that’s designed to cut your Linux boot time drastically. Essentially you show it what you do when you start your computer normally, and it analyzes the files you access and use. Then, it’ll move them to the beginning of your hard disk so that it takes less time to find them during boot.
E4rat是一個實用程式,旨在極大地減少Linux的啟動時間。 從本質上講,它向您顯示了正常啟動計算機時的操作,並分析了您訪問和使用的檔案。 然後,它將它們移動到硬碟的開頭,以便在啟動過程中找到它們所需的時間更少。
E4rat is designed to work with Ext4 partitions only. If you’re using another file system, this isn’t for you. There are reports of it working with LVM but your mileage may vary, so be careful if you have sensitive data.
E4rat僅設計用於Ext4分割槽。 如果您使用的是其他檔案系統,則不適合您。 有報告稱它可以與LVM一起使用,但是您的里程可能會有所不同,因此,如果您有敏感資料,請小心。
Furthermore, if you have an SSD, you should stay away from this. Because E4rat moves files for a better seek time, SSD uses won’t see any benefit as their “seek” time is unaffected by this. By moving files and performing extended writes, you may even end up damaging your already-blazing-fast drive.
此外,如果您有SSD,則應遠離此位置。 由於E4rat可以以更好的查詢時間移動檔案,因此SSD使用不會帶來任何好處,因為它們的“查詢”時間不受此影響。 通過移動檔案並執行擴充套件寫入,您甚至可能損壞已經非常快的驅動器。
在Ubuntu上安裝E4rat (Installing E4rat on Ubuntu)
E4rat is available as a .deb package for Ubuntu users. If you’re running another Linux distro you’ll have to compile E4rat from source, but things should work fine and you can still largely follow this guide. The only real exception is for people who use Debian – take a look at this note before you continue. For our step-by-step guide, we’ll assume you’re running Ubuntu Natty (11.04).
E4rat可作為.deb軟體包供Ubuntu使用者使用。 如果您正在執行另一個Linux發行版,則必須從原始碼編譯E4rat,但是一切正常,您仍然可以很大程度上遵循本指南。 唯一真正的例外是使用Debian的使用者–在繼續之前請先閱讀本說明。 對於我們的分步指南,我們假設您正在執行Ubuntu Natty(11.04)。
Head over to E4rat’s Sourceforge page here.
轉至此處的E4rat的Sourceforge頁面。
Click on the latest version, then download the file that’s appropriate for your architecture.
單擊最新版本,然後下載適合您的體系結構的檔案。
I’m running a 64-bit installation of Ubuntu Natty, so I chose the “amd64” version.
我正在執行Ubuntu Natty的64位安裝,因此我選擇了“ amd64”版本。
Now, if you try to install it right now, you’ll get an error because Ubuntu’s default “ureadahead” package conflicts with E4rat.
現在,如果您嘗試立即安裝它,則會收到錯誤訊息,因為Ubuntu的預設“ ureadahead”軟體包與E4rat衝突。
Ureadahead is similar in concept, but doesn’t work as well as E4rat, so let’s get rid of it. Open up a terminal and enter the following command.
Ureadahead在概念上相似,但效果不如E4rat,所以讓我們擺脫它。 開啟一個終端並輸入以下命令。
sudo dpkg –purge ureadahead ubuntu-minimal
sudo dpkg –最小清除尿素頭
Enter your password and let it do its thing. Next, let’s make sure the proper dependencies for E4rat are present.
輸入您的密碼,然後做它的事情。 接下來,讓我們確保存在E4rat的正確依賴項。
sudo apt-get install libblkid1 e2fslibs
sudo apt-get install libblkid1 e2fslibs
You should have them already installed by default, but if not, this command will install/upgrade to the latest version.
預設情況下,您應該已經安裝了它們,但是如果沒有,則此命令將安裝/升級到最新版本。
Now when you double-click the .deb file you downloaded, you won’t see that error and you can just click the Install button.
現在,當您雙擊下載的.deb檔案時,您將不會看到該錯誤,只需單擊“安裝”按鈕即可。
I happened to get an error at this point, but you can just click on ignore if you get it. Once everything’s done, restart your computer, but stay at the Grub menu.
我此時碰巧遇到了一個錯誤,但是如果您發現錯誤,則可以單擊“忽略”。 完成所有操作後,請重新啟動計算機,但請保留在Grub選單中。
收集資料 (Gathering Data)
With E4rat installed, we need to make sure it gathers its data properly. To do this, we can edit the parameters for our next boot. Make sure you’re in the Grub menu.
安裝了E4rat之後,我們需要確保它正確收集了資料。 為此,我們可以編輯下一次引導的引數。 確保您在Grub選單中。
Highlight the option you normally use to boot into Linux and hit the “e” key. Look for the line that starts with:
突出顯示通常用於啟動Linux的選項,然後按“ e”鍵。 查詢以以下內容開頭的行:
linux /boot/vmlinuz…
linux / boot / vmlinuz…
It’s the second-to-last line in the above pic (click on the image to see a larger version). This line is what tells the Linux kernel to load. At the end of this line, add the following:
這是上圖的倒數第二行(單擊影象檢視大圖)。 這行告訴Linux核心載入。 在此行的末尾,新增以下內容:
init=/sbin/e4rat-collect
init = / sbin / e4rat-collect
Then, just hit Ctrl+X to continue booting. This tells E4rat’s collect program to start running after boot. Let your computer do its thing, and log in. For the next two minutes you should do what you normally do when once you log in. For me, that entails loading up both Chrome and Firefox, opening terminal and running Screen/Byobu, and getting Nautilus and Shutter opened so I can check my files and take screenshots.
然後,只需按Ctrl + X即可繼續啟動。 這告訴E4rat的收集程式在啟動後開始執行。 讓您的計算機完成其工作,然後登入。在接下來的兩分鐘內,您應該執行登入後通常的操作。對我來說,這需要載入Chrome和Firefox,開啟終端並執行Screen / Byobu ,以及開啟Nautilus和Shutter,以便檢查檔案並截圖。
As you can see, those first two minutes are pretty crucial. I clicked on everything within that two minute window that E4rat uses, but not everything loaded until several minutes later. That’s okay, though, so long as you start the application loading, you’ll be fine.
如您所見,前兩分鐘非常關鍵。 我單擊了E4rat使用的兩分鐘視窗內的所有內容,但直到幾分鐘後才載入所有內容。 沒關係,但是,只要您開始載入應用程式,就可以了。
Let’s check to make sure the proper log file was created. Open up terminal.
讓我們檢查以確保建立了正確的日誌檔案。 開啟終端。
ls /var/lib/e4rat/
ls / var / lib / e4rat /
You should see a file a displayed that’s named “startup.log”. If this file isn’t created, you’ll need to restart the process.
您應該看到顯示的檔名為“ startup.log”。 如果未建立此檔案,則需要重新啟動該過程。
移動啟動檔案 (Moving the Startup Files)
Once you verify that the log file is there, restart your computer and stop at the Grub screen. Choose your booting option and hit “e” once again.
確認日誌檔案存在後,重新啟動計算機並在Grub螢幕上停止。 選擇啟動選項,然後再次點選“ e”。
This time, we’re going to add some thing different to the end of that same line:
這次,我們將在同一行的末尾新增一些不同的內容:
single
單
Hit Ctrl+X to boot, but this time, we’re heading into the command-line straight-away. My machine took a little while, and then gave me a screen with several option. If this happens to you, just choose the option for “Resume normal boot.”
按Ctrl + X引導,但是這次,我們直接進入命令列。 我的機器花了一段時間,然後給了我一個帶有多個選項的螢幕。 如果您遇到這種情況,只需選擇“恢復正常啟動”選項即可。
Then, if you don’t get to a command-prompt, hit Ctrl+Alt+F1. You should now see a login prompt.
然後,如果沒有出現命令提示符,請按Ctrl + Alt + F1。 現在,您應該會看到一個登入提示。
Enter your username and password, and then enter the following command:
輸入您的使用者名稱和密碼,然後輸入以下命令:
sudo e4rat-realloc /var/lib/e4rat/startup.log
須藤e4rat-realloc /var/lib/e4rat/startup.log
Enter your password, and E4rat will start moving files on your hard drive.
輸入密碼,E4rat將開始在硬碟驅動器上移動檔案。
This may take quite a while depending on how cluttered your disk is. Just watch the hard drive light blink and wait patiently for things to finish.
這可能需要花費相當長的時間,具體取決於磁碟的混亂程度。 只需看著硬碟驅動器指示燈閃爍並耐心等待事情完成即可。
The official website recommends that you run the command a couple more times until nothing else can be moved. My computer gave me that message right away, so your mileage may vary.
官方網站建議您多次執行該命令,直到無法移動其他內容為止。 我的計算機立即向我傳送了該訊息,因此您的里程可能會有所不同。
Now, let’s restart our machine with
現在,讓我們重啟機器
sudo shutdown -r now
sudo shutdown -r現在
and log in normally to complete the last phase.
並正常登入以完成最後一個階段。
配置Grub在每次引導時執行E4rat (Configuring Grub to Run E4rat On Every Boot)
Open up a terminal and enter:
開啟一個終端並輸入:
gksu gedit /etc/default/grub
gksu gedit / etc / default / grub
Ubuntu’s Text Editor should pop open. Look for the line that starts with “GRUB_CMDLINE_LINUX_DEFAULT=”
Ubuntu的文字編輯器應該彈出開啟。 查詢以“ GRUB_CMDLINE_LINUX_DEFAULT =”開頭的行
We’re going to add a line inside of the those quotes and before whatever options are there.
我們將在這些引號內以及任何選項之前新增一行。
init=/sbin/e4rat-preload
init = / sbin / e4rat-preload
Your file should look similar to this:
您的檔案應類似於以下內容:
Hit the save button and close Gedit. Now, return to the terminal and run one last command:
點選儲存按鈕,然後關閉Gedit。 現在,返回到終端並執行最後一個命令:
sudo update-grub
須藤更新
Configuring Grub this way (and NOT by editing /boot/grub/grub.cfg) will make sure that this lasts between updates, although you may have to redo this if you upgrade between releases in the future. By then, however, you’ll probably want to redo this entire process so that the right files are in the right places.
以這種方式配置Grub(而不是通過編輯/boot/grub/grub.cfg進行配置)將確保這種情況在更新之間持續存在,但是如果將來在不同的發行版之間進行升級,則可能必須重做一次。 但是,到那時,您可能需要重做整個過程,以便將正確的檔案放在正確的位置。
The next time you reboot, you’ll notice a sizeable time difference in booting and in opening the apps that your normally head straight to. My netbook’s boot time is now about 10 seconds!
下次重新啟動時,您會注意到在啟動和開啟通常直接進入的應用程式時存在很大的時差。 我的上網本的啟動時間現在約為10秒!
Know of any other tricks to shave precious seconds off of your boot time? Share what you know in the comments!
知道其他任何技巧可以節省寶貴的啟動時間嗎? 在評論中分享您所知道的!
翻譯自: https://www.howtogeek.com/69753/how-to-cut-your-linux-pcs-boot-time-in-half-with-e4rat/
98rat