Linux: Whether your computer already boots pretty quickly or you're trying to eke some extra spee dout of your old computer, free command line tool E4rat will seriously decrease your boot time. Here's how to set it up.


As you may know, the files on your computer are usually spread all over the physical drive itself. When your computer looks for the files it needs to boot, it usually has to scan all over the drive to find them. This takes awhile, and contributes to a good percentage of your boot time. E4rat is a tool that will log which files you access in the first two minutes of booting, put them in order on your disk, and preload them so it can read the files much, much quicker.

The process of getting it up and running takes three steps: collecting information about your startup, reallocating the files, and then setting them to preload on each boot. Note that your disk needs to be formatted in Ext4 for this to work, and you don't want to do this on an SSD (as you're essentially defragmenting the drive)—this is for regular ol' magnetic drives only.


Step 1: Collect

After installing E4rat, reboot your computer and wait for the GRUB menu to pop up. When it does, highlight your Linux partition and hit the "e" key to edit the configuration. Search for the kernel line, which varies a bit on everyone's system, but should look something like this:

kernel /vmlinuz26 root=/dev/disk/by-uuid/bf1d191b-0f0d-4961-bd67-4d023a2e5873 ro

G/O Media may get a commission Subscribe and Get Your First Bag Free Promo Code AtlasCoffeeDay20

And add init=/sbin/e4rat-collect to the end of the line, so it reads:

kernel /vmlinuz26 root=/dev/disk/by-uuid/bf1d191b-0f0d-4961-bd67-4d023a2e5873 ro init=/sbin/e4rat-collect


Then hit Ctrl+X to continue booting. If you prefer, instead of doing this all from GRUB, you could edit your GRUB configuration file directly ( /boot/grub/grub.cfg for GRUB2 users) from your desktop, and add the init line there. Just make sure you remember to remove the init line after completing step 1.

What this does is run the E4rat collector for this boot only. The collector monitors everything that happens within the first two minutes of your startup. So, for the purposes of collecting the right files, act as you normally would when you boot. E.g., if the first thing you do when you boot up your computer is open your browser and mail client, do that after you finish booting here. It'll move those files too so those programs launch extra quickly. Once your two minutes are up, you can stop "acting". To double-check if it worked, check to see if a startup.log file exists in /var/lib/d4rat/startup.log . If it does, everything went according to plan and you can proceed to step 2.


Step 2: Reallocate

Next, reboot your computer and edit your Linux boot entry again by highlighting it and hitting "e". This time, add the word single to the end of your kernel line:

kernel /vmlinuz26 root=/dev/disk/by-uuid/bf1d191b-0f0d-4961-bd67-4d023a2e5873 ro single


It should reboot you into a command line (if you get a blue screen, pick the option to boot as normal) and you can log in using your username and password. Once there, run the following command:

sudo e4rat-realloc /var/lib/e4rat/startup.log

This will move all your startup-necessary files to the same area of the drive for quick access. It can take a little while, so just let it run. When you're done, reboot and finish up with step 3.


Step 3: Preload

The last step is to tell your machine to preload those files every time you boot. So edit your GRUB2 configuration file by running:

sudo nano /etc/default/grub

Find the GRUB_CMDLINE_LINUX_DEFAULT line and add this to it:

init=/sbin/e4rat-preload

Leave anything there that already existed after the init line. So, for example, mine looked like this:

GRUB_CMDLINE_LINUX_DEFAULT="init=/sbin/e4rat-preload quiet splash"

Save the file and close it. Then, head into a terminal and run sudo update-grub . Now, when you reboot, you should notice that you boot and start up your first few apps super quickly—I was up and running Firefox and Pidgin in nearly half the time on my netbook, and some users are even reporting boot times up to three times faster. Head to the link below to check it out, and let us know what kind of improvement you see in the comments.


E4rat is a free download for Linux only. Ubuntu users can grab a .deb file at the link below for easy installation; other users will probably have to compile from source.


E4rat | via One Thing Well

You can contact Whitson Gordon, the author of this post, at whitson@lifehacker.com. You can also find him on Twitter, Facebook, and lurking around our #tips page.



