Showing posts with label ubuntu. Show all posts
Showing posts with label ubuntu. Show all posts

Saturday, September 3, 2011

Optimizing Ubuntu 11.04 for SSD

I recently upgraded my Dell XPS and installed a Crucial m4 64Gb SSD. In the occasion of starting with a fresh new disk I also installed Ubuntu 11.04. Being nervous about having too many write actions on the disk (even though that shouldn't be a problem with today's SSDs) I decided to make some changes to the configuration to reduce the number of disk actions.

WARNING: Be careful when making these changes as they can result in stopping your machine from booting!

DISCLAIMER: I will NOT be responsible for any damages or an inaccessible machine! You do this at your own risk, no guarantee is given.


1. Create /tmp/ in a memory RAM-disk.

The /tmp/ directory on any linux installation is primarily used for - yes - temporary files. Programs frequently create and delete files they need for temporary caching, communicating between sub-processes and other various reasons. It is safe to move /tmp/ to ram since the OS will clean the /tmp/ directory upon boot anyway - we will save ourselves a bit of time during boot.

To make this change edit the file /etc/fstab as a root user:


john@doe:$> sudo emacs /etc/fstab


Add the following line without touching any other part of the file:


tmpfs /tmp tmpfs nodev,noexec,nosuid 0 0


Make sure there are the white spaces between the different words.


2. Mount volumes on SSD using the noatime option.

By default Ubuntu writes the last accessed time attribute to files. This means that for every file access Ubuntu writes to disk (read and write!). The noatime option forces Ubuntu to no longer write the last read/write access time to the file. Edit your fstab file by replacing relatime with noatime in fstab:


john@doe:$> sudo emacs /etc/fstab


N.B. You may find out that some applications like mail agents may no longer see that files have changed; in that case use relatime: it will force Ubuntu to write the last access time only during writes to the files and no longer during read.


3. Move Firefox cache to RAM

Firefox puts its cache in your home directory by default. By moving this cache to /tmp/ you can speed up Firefox and reduce disk writes.

Enter 'about:config' in the Firefox address bar (without the quotes). Right click and create a new string with value 'browser.cache.disk.parent_directory'. Set the value to '/tmp'.


4. Move Chromium cache to RAM

Chromium has the same problem - it's cache is in your home directory. This means a lot of reads/writes to your disk during surfing. Unfortunately it is not as easy as with Firefox to move the cache to a different directory. In the following steps I will outline how I solved this on my machine. At this point I assume /tmp is in memory and not on disk (see the first change).

Create a directory in /tmp/ for chromium's cache
(as a normal user)

john@doe:$> mkdir -p /tmp/chromium


Make a symbolic link from the users home dir to /tmp/chromium (check man ln to see the syntax and use of the command)
(as a normal user)


john@doe:$> rm ~/.cache/chromium/Default
john@doe:$> ln -s /tmp/chromium ~/.cache/chromium/Default


Now we are going to prepare the machine:

1) create the directory /media/cache (once)
2) on startup (boot) copy the cache in /media/cache to /tmp/
3) on shutdown copy the cache from /tmp/chromium to /media/cache/


john@doe:$> mkdir -p /media/cache


Now we are going to create a file in /etc/rc6.d that will be executed upon shutdown of the system. It is called K02chromium. The first letter K stands for Kill. The two digits that follow are used for determining the order in which the scripts in that directory are executed during shutdown. The higher number gives a higher priority. The text after that is free and can be anything.

Do the following as root (sudo -i)


john@doe:$> sudo -i

root@doe:$> emacs /etc/rc6.d/K02chromium


Insert the following snippet:

#!/bin/bash

# use rsync to synchronize the temp dir with the backup dir (/media/cache)
# options: a all, r recursive, P progress, o keep owner
# --delete removes any files from the destination that are no longer there
rsync -arPo --delete /tmp/chromium /media/cache/


As root make the file executable:

root@doe:$> chmod +x K02chromium


Modify the file /etc/rc.local. This file is executed upon boot. Insert the following lines before 'exit 0':


# To make sure on startup the cache is copied to /tmp add to /etc/rc.local the following
# use rsync to synchronize the backup dir (physical) with the temp dir (also physical - do not use link)

rsync -arPo --delete /media/cache/chromium /tmp/


Save the file and your done!


Wednesday, March 16, 2011

Flash on Chrome on Ubuntu 10.04

If you are like me and almost blindly click on 'Update Now' when system updates are available in Ubuntu, you may have run into the same problem I had with Chrome. I am running Ubuntu 10.04, 64-bit and use Chrome as my primary browser (from Synaptic). After the automatic updates of a few weeks ago flash stopped working and Chrome would ask me everytime 'Flash is out of date - Run this time only or Update'. But the update it was linking to on the Adobe website wouldn't work for whatever reason.

Luckily the ubuntuforums.org came to the rescue. Using a Firefox plugin called Flash-Aid you can update the Flash player semi-automatically. This plugin is published on the Mozilla website.

To install this plugin do the following:

1. Start Firefox (since it is a plugin for Firefox, this won't work in Chrome)
2. Go to: Flash-Aid
3. Follow the instructions
4. After the execution of the script restart your browser(s) and Bob's your uncle!

Monday, February 9, 2009

Converting avi to DVD format

In this blogpost I would like to explain how an existing avi file (in XVID or DIVX format) can be converted to DVD format, ready to be burned to disc. This for people who still have an old DVD player which cannot read DIVX and XVID movies.

First thing to do is to convert the XVID film into a format usable for DVD playback. The DVD standard typically uses MPEG-2 for video and AAC for audio. It is possible other formats are also supported, but I stuck to these formats.

The conversion to MPEG-2 can be done with ffmpeg an open source tool that is able to convert a lot of video files. The command line is as follows:

$>ffmpeg -i film.avi -target pal-dvd film.mpg

This will convert the file film.avi into film.mpg with the standard DVD format (resolution and framerate) for PAL televisions. For NTSC (USA) it is enough to change the 'pal' part into 'ntsc'.
After the file has been converted, it can be massaged to be put on a DVD disc. For this we need to create the directory structure that consists of the directories AUDIO_TS and VIDEO_TS. The directory AUDIO_TS is typically empty on a DVD, but the VIDEO_TS directory contains the files of type VOB and IFO that contain the video and audio in chunks of 1 GB. For creating this directory layout and the correct files, dvdauthor is a good tool. Dvdauthor requires an xml file that contains a description of the structure of the dvd layout. It is very powerful and allows for a lot of customization. In this example I keep it simple with one single file that has 4 chapters:

<dvdauthor dest="DVD">
 <vmgm />
  <titleset>
   <titles>
    <pgc>
     <vob file="film.mpg" chapters="0,15:00,30:00,45:00,1:00:00"/>
   </pgc>
  </titles>
 </titleset>
</dvdauthor>

Save this file as film.xml to the same directory as where film.mpg resides. With dvdauthor now the layout will be created as follows:

$>dvdauthor -x film.xml

This command will create a directory DVD with inside the directories AUDIO_TS and VIDEO_TS. The VIDEO_TS directory will contain the VOB files that contain the video and audio. This structure can then be burned to disc using tools like K3B.

PS: both tools can be installed in Ubuntu using:
$>sudo apt-get install ffmpeg dvdauthor

PS2: There are other tools with which you can accomplish the same job:

Tuesday, November 11, 2008

Make Linux Harder - Better - Faster

Courtesy of LinuxHaxor, a good set of links on how to improve your Linux / Ubuntu installation.

Sunday, November 2, 2008

Ubuntu 64-bit, Opera and flash

Finally flash seems to become something normal on Linux, and supported by most distributions. At the moment Adobe only has a flash-player for 32-bit Linux, but luckily it can also be used in a 64-bit installation using nspluginwrapper. Installing flash for Firefox is simple in Ubuntu: open Synaptic, search for flashplugin-nonfree and install it. This installs the flash-plugin, as well as nspluginwrapper for 64-bit installations. For Opera, it is a bit more work: download the plugin from the Adobe website and put it in the plugins directory. Here follow the instructions to get flash working in Opera 64-bit.

1. Go to the Adobe flashplayer download website and select the .tar.gz for Linux option. This will download the archive; we are only interested in extracting one single file. (Do not download the .deb!)

2. Extract the files from the archive.
$> tar -zxf install_flash_player_10_linux.tar.gz

3. At this point we have to copy the plugin file to the correct directory where Opera can find it.
$> cd install_flash_player_10_linux
$> sudo cp libflashplayer.so /usr/lib/opera/plugins

4. Start opera and go to YouTube where you can test your newly installed flashplayer.

You can now safely delete the directory where you extracted the archive (install_flash_player_10_linux/).

Ubuntu and Dell XPS m1530

Since a month I am the happy and proud owner of a Dell XPS m1530 laptop. Its configuration is the following:

* Processor: Intel Core 2 Duo T9300 (2.5 GHz, 6 MB L2 cache)
* Graphics: nVidia GeForce Go 8600M GT with 256 MB video memory
* Screen: 15.4-inch widescreen, 1680 x 1050 CCFL with 2.0 megapixel webcam
* RAM: 4 GB (2 x 2GB) 667 MHz DDR2
* Harddisk: 400 GB SATA 5400 RPM (Samsung)
* Wireless: Intel 4965 AGN WiFi
* Bluetooth: Dell TrueMobile 355
* Fingerprint reader
* DVD+/-RW slot-load drive
* 90W AC adapter, standard 9-cell battery

Installing Ubuntu is a breeze, all hardware is recognized and configured automatically. However, you have to set up a kernel boot parameter to avoid the cursor from going crazy. This is a well known problem, and easy to fix. For this fix, and other tips on configuration and installation of Ubuntu, I found an excellent wiki. Of course you shouldn't forget to check out Ubuntu Forums.