Tuesday, July 05, 2011

Making your Linux computer silent

These are some notes I made back before Solid State Disks were popular. If I were doing this today, I'd get an Intel Atom processor with SSD disks, and no fans. These tips might still be relevant for desktop computers.

While you may not realize it, your computer is capable of being silent, or at least quieter. I collect some tips here which might help in reaching this goal.
  • Buy a good power supply. A lot of the noise comes from power supply fans and other fans in the system. While the CPU fan is usually rather silent, some power supply fans are very noisy. If you want to make your existing fan quieter, a good way is to blow the dust out. Dust stuck in the fans makes noise. You could use a bicycle pump to force air through the fan after switching off the computer. Your mileage may vary. CPU heatsink fans have the tendancy to get very dirty, and dirt gets accumulated in the heatsink fins. I've found cleaning these fins to make quite a dramatic change in the amount of noise from the heatsink fan.
  • Use noflushd: It is a user level daemon that prevents disk writes from spinning disks back up.
  • Don't use journaling filesystems. Ext3, reiserfs, xfs, jfs are all journaling filesystems and commit data to disk without going through any cache. While journaling filesystems are cooler and have much better recovery and consistency: if you have a noisy disk: they will make it spin almost continuously. Turn off journaling with ext3, or change the filesystem if you can. Here is a quick way to convert an ext3 partition to ext2. This will work even if it is the / filesystem, though nothing is guaranteed. First, turn off all the services possible, and try to get almost no processes running. Then edit /etc/fstab so that the ext3 filesystems are changed to ext2. Next, run the command
    vi /etc/fstab  # <- change /dev/sdaXX from ext3 to ext2
    mount -o remount,ro /dev/sdaXX
    tune2fs -O ^has_journal /dev/sdaXX
    mount -t ext2 -o remount,rw /dev/sdaXX
    After these commands, you might want to reboot, and see if the filesystem is now ext2. It worked for my iMac, where I could not reboot to another Linux distribution. Again, your mileage may vary.
  • Turn off as many services as you can. If you don't need mysql running all the time, switch it off. A lot of services want to write logs, and you can either change their configuration to disable log writing, or look at the next step.
  • If you have directories in which frequent writes are required, consider mounting them as a tmpfs. This is a new filesystem in Linux which keeps data on RAM, and not on disk. This means that if the machine goes down, your data is lost. To avoid losing data, you might want to copy the data out to real disk when switching off the machine. This is a great way to write log files, or put images from the webcam that you take every second or so. After all, when you have the most recent image, you might not be so interested in the older photos. If your kernel is too old, you might want to use the ramdisk module, but tmpfs is a better choice if you have it.