Category Archives: Kernel

Speeding up my Ubuntu 12.04

My laptop will turn two (years old) soon. Some people would find this computer young enough for their task but they are not me. Actually, it started to feel ancient on my hands a few months ago ;-) Do not mistake! I like it, I like its design, it is slim and light (well… it can be lighter) and it was surprisingly efficient when I bought it… two years ago.

Nowadays, there are amazing ultrabooks everywhere: Samsung series 9, Asus Zenbook, Dell XPS 13, HP Spectre/Folio, Vizio thin+light… They are so thin and so light and so beautiful and so… everything! And comparing those beasts with my puppet would be unfair, isn’t it? I think that my Acer 3820T would lose all possible benchmarks.

Anyway, last week I decided to keep this one and upgrade some components instead of buying a newer one because I don’t want to spend more than 1,000 euros on a laptop that I like and I’m not going to waste several hundred of euros in one that I don’t and that it’s not really what I want.

So, I made a list of upgradeable components and checked that I would bring a second childhood to my laptop just replacing its HDD and 9-cells battery for and SSD unit and a lighter and slimmer battery. This time i’m not in RAM and processor races; both of them are not squeezed enough yet.

AcerTimelineX

SSD Units recommendations

Once decided that I will upgrade my hard disk for a flash memory based one (when my cash flow accepts this operation), I started to find references from former SSD-Ubuntu users. And I found some interesting recommendations:
  • The first one is to disable the swap partition. Their arguments were that disk swapping requires a lot of read and write operations and this could reduce SSD lifetime. I DO NOT RECOMMEND this at all but, configuring your system to consume more RAM before swapping to disk[1] would be a good idea.
    NOTE: Remember! it is possible to configure modern Linux systems to use a file as swap area[2].
  • The second one is to enable TRIM. I had no idea of what TRIM meant before reading its Wikipedia page[3] and a question on AskUbuntu[4] about it. Actually, it looked something very specific on SSD units and I don’t recommend to enable it on current HDD.
  • The last one is about migrating all logs and temporal files into main memory. It ‘s something tricky because you need to know what you are doing. I mean, you need to know what these files can tell you and, later, ask yourself some questions like: Is it smart to lose all your log data every time you turn off your computer to increase the whole system performance? Wouldn’t it be smarter to switch off all your logging? At the end, you won’t keep this information for so much time! As always, nothing is just black or white so, let me explain what I’ve done.

Moving temporary files and logs to main memory

Moving temporary files into main memory is not so risky as moving log data. You need to understand that if you don’t keep your temporary files on disk you can lose your unsaved information in case of power failures or similar but that’s all.
Moving log data into main memory is slightly different. Some programs or services highly rely on their log data (for example, the Apache server is not able to start if it doesn’t have its log folder) and the operating system wouldn’t boot properly if you don’t keep this information safe and sound.
At the end, I decided to switch logs to main memory by default and create a safe_log folder to store these required logs (like the Apache ones) explicitly modifying their responsible software configuration.
To move all these files to the main memory follow these steps:

STEP 1: Add these lines to /etc/fstab

tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0
tmpfs /var/log tmpfs defaults,noatime,mode=1777 0 0
tmpfs /var/tmp tmpfs defaults,noatime,mode=1777 0 0

STEP 2: Stop the rsyslog daemon

$> sudo service rsyslog stop

STEP 3: Delete your temporary/log files

$> sudo rm -rf /tmp/*
$> sudo rm -rf /var/log/*
$> sudo rm -rf /var/tmp/*

STEP 4: Mount your filesystems

$> sudo mount -a

STEP 5: Start the rsyslog daemon (or just reboot)

$> sudo service rsyslog start

NOTE: There was a project called Ramlog that provided a similar functionality with some useful extras like syncing log files into disk before shutting down and so on but it doesn’t seem to have any activity since early 2010.

Creating a new folder for your “safe logs” would be as easier as creating that folder as super user, giving permissions to system users to write on it and updating configurations to place applications logs there.

Results and warnings

First of all, be careful! I made all those changes after five years or more of working exclusively with Linux distributions at home and managing several Linux servers on different work positions. Do not follow these steps without understanding what they mean. Questions are welcomed on the comment section!
Second, and not less important, I’ve improved my laptop performance further than I expected with those changes. At the moment, I will slow down my SSD units deliberations and see how much I can tune this computer without breaking it. I will keep you up to date ;-)
-

[1] Swappiness Wikipedia article: link
[2] Useful information about swap (includes how to configure swap files): link
[3] TRIM article on the Wikipedia: link
[4] Question on AskUbuntu regarding TRIM: link