Skip to content

Fix for slow boot times in Ubuntu

2009/10/16

This has happened a few times now. A new version of Ubuntu comes out. I install [X|K]?[U|u]buntu (Kubuntu, presently.) All is well, for a time. Sometimes weeks, sometimes months. Then, one day after several rounds of aptitude full-update, and adding, removing, and reinstalling software, boot times start to increase. Over the course of about a week or so, they get so bad I start planning to banish Ubuntu from my life forever. Then, I remember – I’ve had this problem before, and fixed it…it was something about a readahead file somewhere… I profiled my boot and…AHH I wish I had written down my fix somewhere!

This was the week. Fortunately, remembering that it had something to do with ‘readahead’ was sufficient, I didn’t have to screw with installing boot profilers, and going through the dog & pony show of trying to re-discover the fix.

find / -name readahead 2>/dev/null

That was the magic command that saved me, this time.

$ sudo find / -name readahead 2>/dev/null
/usr/share/doc/readahead
/etc/init.d/readahead
/etc/readahead

So, readahead is installed… http://ubuntuforums.org/showthread.php?t=565651 that post gives a little explanation. It’s reading a bunch of files, loading them into memory…

In the /etc/readahead directory there are two files, boot and desktop. My /etc/readahead/boot file is 22K. Not huge, mind you but

$ wc -l /etc/readahead/boot tells me it contains 710 lines. The /etc/readahead/desktop file is only 281 lines and comes in at a meager 10K.

All this is to say, it seems like there is a point of diminishing returns with readahead – that list can get so long that your boot takes FORRRRREEEEEEEEVVVVVVVVVERRRRRRRRRR! No thanks.

$ sudo cp /etc/readahead/boot /etc/readahead/boot.bak
$ sudo bash -c ":> /etc/readahead/boot"

To break down that command: ‘sudo bash -c’ says as the superuser, execute bash. The -c flag means ‘instead of an interactive shell, run the following command.’ The colon is a newline character, the indirection operator > directs the output from the whatever is the left into whatever is on the right (in this case, that pesky readahead/boot file.)

After this command, the /etc/readahead/boot file is nice & clean, and not lagging our boot process. The first boot takes a bit of time, because the readahead file is rebuilt, but subsequent boots should be just as snappy as the day the system was freshly installed!

Advertisements

From → Linux, Ubuntu

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: