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.
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 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.
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.
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).
Head over to E4rat’s Sourceforge page here.
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.
Now, if you try to install it right now, you’ll get an error because Ubuntu’s default “ureadahead” package conflicts with 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.
sudo dpkg –purge ureadahead ubuntu-minimal
Enter your password and let it do its thing. Next, let’s make sure the proper dependencies for E4rat are present.
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.
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.
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.
Highlight the option you normally use to boot into Linux and hit the “e” key. Look for the line that starts with:
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:
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.
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.
Let’s check to make sure the proper log file was created. Open up terminal.
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.
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.
This time, we’re going to add some thing different to the end of that same line:
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.”
Then, if you don’t get to a command-prompt, hit Ctrl+Alt+F1. You should now see a login prompt.
Enter your username and password, and then enter the following command:
sudo e4rat-realloc /var/lib/e4rat/startup.log
Enter your password, and E4rat will start moving files on your hard drive.
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
and log in normally to complete the last phase.
Configuring Grub to Run E4rat On Every Boot
Open up a terminal and enter:
gksu gedit /etc/default/grub
Ubuntu’s Text Editor should pop open. Look for the line that starts with “GRUB_CMDLINE_LINUX_DEFAULT=”
We’re going to add a line inside of the those quotes and before whatever options are there.
Your file should look similar to this:
Hit the save button and close Gedit. Now, return to the terminal and run one last command:
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.
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!
Know of any other tricks to shave precious seconds off of your boot time? Share what you know in the comments!
- Published 08/5/11