Techie Tips N Tricks

Thursday, January 27, 2011

Update Ubuntu: 8.10 to 10.04

Wanted to install Android SDK, but it required LucidLynx (10.04) or later on Ubuntu Linux. Checked out my version, realized that it was Ubuntu 8.10 (Intrepid Ibex), and it was no longer supported (EOL Release).

Decided to take the upgrade route to 10.04 LTS rather than a fresh clean installation, as I did not want to lose my existing configuration. Besides, I just wanted to give it a try, as I thought upgrading would not be that simple :) Its still Linux, right! :D

Am noting down, what I had to do to get my system updated (steps, issues & tricks which worked for me); hope it helps someone else too.

Do be informed that:
  1. If you choose to upgrade Ubuntu to the latest version, you need to take all the interim releases and update your system one by one till the latest release release. So it was a long way to go for me.
  2. Depending on your net connectivity & bandwidth, it can take anywhere between 1 hour and 5 hours for each upgrade.
  3. It is always recommended to backup your current installation before attempting these upgrades (however, I did not have the time for this)
  4. Latest release available is 10.10; however, I have decided to upgrade the system only till 10.04 LTS (which has got Long Term Support).

Upgrades Required: 8.10 (Intrepid Ibex) > 9.04 (Jaunty Jackalope) > 9.10 (Karmic Koala) > 10.04 (Lucid Lynx)

Upgrade 1: 8.10 (Intrepid Ibex) > 9.04 (Jaunty Jackalope)

Wanted to take the command line route.

Followed the instructions word by word given here; faced no issues.

Summary below
1. Edit /etc/apt/sources.list (Content as shown in the link above)
2. sudo aptitude update && sudo aptitude safe-upgrade
3. sudo do-release-upgrade
4. lsb_release -a

Showed 9.04

Alternatively, you could also follow instructions on this page.

Upgrade 2: 9.04 (Jaunty Jackalope) > 9.10 (Karmic Koala)

Went for Update Manager this time. Followed the instructions given here; lucky this time as well - no issues faced.

And finally,
benoy@palazhi:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 9.10
Release: 9.10
Codename: karmic

Upgrade 3: 9.10 (Karmic Koala) > 10.04 (Lucid Lynx)

Update Manager again. The instructions were available here; but did have a few hiccups (issue & solution detailed below).


On clicking, "Check" & "Install Updates" buttons in the 'Update Manager'; the system showed the following error:

W: GPG error: http://archive.ubuntu.com karmic Release: Unknown error executing gpgv
W: GPG error: http://archive.ubuntu.com karmic-updates Release: Unknown error executing gpgv
W: GPG error: http://archive.ubuntu.com karmic-security Release: Unknown error executing gpgv


Came across this:
Tried the following steps:

benoy@palazhi:~$ sudo -s -H
benoy@palazhi:~$ apt-get clean
benoy@palazhi:~$ rm /var/lib/apt/lists/*
benoy@palazhi:~$ rm /var/lib/apt/lists/partial/*
benoy@palazhi:~$ apt-get clean
benoy@palazhi:~$ apt-get update


This did not work as expected; but it showed that error had got something to do with libreadline.so

Then came across this. Tried the following steps:
benoy@palazhi:~$ su
benoy@palazhi:~$ mkdir tempbenoy@palazhi:~$ mv /usr/local/lib/libreadline* tempbenoy@palazhi:~$ ldconfigbenoy@palazhi:~$ apt-get update

This did work for me. Once the error was resolved, followed the steps detailed here.

Finally,
benoy@palazhi:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 10.04.1 LTS
Release: 10.04
Codename: lucid

End of Upgrade! :)

Saturday, May 15, 2010

Blogger widget "Search this blog" not working

It seems the blogger widget "Search this blog" does not return any results; so many users have reported the issue to google, but this one is yet to be fixed. Meanwhile, you can try this one from Blogger Templates Designs. It works, you can find it in the sidebar of my other blog.

Sunday, April 4, 2010

Priority Inversion & Priority Inheritance

Came across the interesting concept of "Priority Inversion" & "Priority Inheritance" while going through the QNX documentation. Shall try to explain the concepts in simpler terms.

Usually in an OS, the scheulder would preempt a low priority job to give a high priority job a chance to run. However, in certain situtions it can be found that a high priority job is kept waiting for a low priority job to complete. This is referred to as "Priority inversion". The following example gives a better picture.

Lets consider two jobs Job A and Job C, such that Job A has higher priority among the two. The jobs are sharing a resource controlled by a lock, and lets say that presently Job A is waiting for Job C to unlock the resource. Note that upon unlocking, in the very first opportunity, the scheduler would preempt Job C and give the slot to Job A. Now lets introduce a third job - Job B, which has higher priority than Job C but lower priority than Job A. If Job B becomes ready to run which Job C was executing, the OS would preempt Job C in favor of Job B and Job C will not be able to run until Job B is complete (despite the point that the highest priority job Job A is waiting for Job C to unlock a shared resource). Thus, we see that a high priority job (Job A) is getting delayed (indirectly) because of a lower priority job (Job B). This scenario is referred to as "Priority Inversion".

In an RTOS, it is critical that this does not happen. One solution to this challenge, is referred to as "Priority Inheritance".

When the concept of priority inheritance is introduced to the above scenario, Job C would inherit the priorty of Job A for the duration Job A was waiting for Job C to unlock the shared resource. Thus, when the new JoB B is introduced, the scheduler sees that Job C is of higher priority than Job B and Job C would not be preempted in favor of Job B. Once Job C is executed, it releases the lock on the shared resources, immediately after which the system would preempt Job C in favor of Job A, and the priority of Job C would be restored to its original priority level (i.e. lower than that of Job B). Upon completion of Job A, the system would then run Job B and then finally Job C.

Sunday, December 6, 2009

Thursday, November 26, 2009

Schedule an one time job in linux - the "at" command & "sudo" time out option

Wanted to download and build from source the new Chromium OS, when I came across a huge list of packages as pre-requisites for Chromium OS. The download over the internet being free after 2:00 AM in the night, it had to be scheduled around that time.

There is an "autodownload.sh" script which will download & install the files (detailed at the end of this post). This script had to be scheduled for execution at 2:10 AM.

To schedule the job
benoy@palazhi:~$ sudo at -f autodownload.sh -v 2:10 AM
[sudo] password for benoy: [enter the password]
Fri Nov 27 02:10:00 2009

warning: commands will be executed using /bin/sh
job 15 at Fri Nov 27 02:10:00 2009

[NOTE]
1. The "at" command is preceeded by the "sudo" command since the script "autodownload.sh" requires root privileges to execute and install the packages.
2. The file name (name of the script file which is to be executed at a scheduled time) is given with "-f" option.
3. The time at which the script has to be executed is given with "-v" option.
4. The output shows that a job, with ID 15, has been scheduled for execution at 02:10:00 hours on Nov 27, 2009.
5. For scheduling periodic jobs, you can create a "crontab" using a "crontab" command with "-e" option.
[/NOTE]

To see the scheduled jobs
benoy@palazhi:~$ sudo atq
15 Fri Nov 27 02:10:00 2009 a root

[NOTE]
1. The "atq" command lists the scheduled jobs.
2. It is preceeded by the "sudo" here as the earlier job was added as job to be executed by the root.
[/NOTE]

To delete the scheduled job
benoy@palazhi:~$ sudo atrm 15
benoy@palazhi:~$ sudo atq
benoy@palazhi:~$

[NOTE]
1. The "atrm" command cancels the job with the ID mentioned in the command line (15 in this case).
2. The "atrm" command is preceeded by the "sudo" command as the earlier job was added as job to be executed by the root.
[/NOTE]

Now lets see the autodownload.sh script

benoy@palazhi:~$ cat autodownload.sh
#!/bin/sh
rm -f temp
echo "Deleted temp.log..." >> temp.log
echo "Start downloading..." >> temp.log

while read package
do
sudo apt-get install -y --install-recommends $package >> temp.log 2>>temp.log
done < packages.txt

echo "Halting the system....." >> temp.log
halt -p

[NOTE]
1. The while loop reads from the file "packages.txt", line by line, to a user defined variable "package".
2. The "sudo apt-get install..." line has "$package" to get the name of the package (which is read from the file packages.txt).
3. The "apt-get" command is preceeded by a "sudo" command as it involves package installation which requires root privilege.
4. The "-y" option to "apt-get" provides an automatic "yes" to the "apt-get" prompts.
5. The "--install-recommends" options ensures that recommended packages are also installed.
6. The errors are as well appended to "temp.log" file (note "2>>temp.log" at the end of the "sudo apt-get..." command.
7. The "halt -p" command shuts down the system after completing the download & installations.
[/NOTE]

We now have another issue at hand. The sudo command will time out in 5 or 15 minutes, so at 2:10 AM, when the "sudo apt-get..." command will be executed, the system will require the root password again (which will defy the very purpose of scheduling this download). The way around is to give a high or an indefinite value for time out.

To change the sudo timeout
benoy@palazhi:~$ sudo visudo

The system opens the "/etc/sudoers" file; add the following line:
Defaults:benoy timestamp_timeout=-1

[NOTE]
1. Change "benoy" to your user name.
2. A negative value for timestamp_timeout means indefinite timeout, i.e till you logout or exit from the terminal.
3. A positive value will ensure that the sudo session remains active for that many minutes.
4. Do a "sudo -K" to forcefully end a sudo indefinite session.
[/NOTE]

Now, have a file "packages.txt"; which will list the packages that are to be downloaded. Let us keep it very simple; each line of the file will have the name of one package that is to be dowloaded.

benoy@palazhi:~$ cat packages.txt
subversion
pkg-config
python
perl
g++
g++-multilib
bison
flex
gperf
libnss3-dev
libgtk2.0-dev
libnspr4-0d
libasound2-dev
libnspr4-dev
msttcorefonts
libgconf2-dev
libcairo2-dev libdbus-1-dev

Saturday, November 21, 2009

godbc (Go & ODBC)

Got the basic structure up; made my first submission today.

http://github.com/BenoyRNair/godbc

Sunday, November 15, 2009

More on VIM syntax highlighting

To force a syntax scheme of one language on files in other languages or those with no file extension.

In vim editor, key in:
:setf [language _name]

For example, to force a perl syntax on a *.go file; in the vim editor, key in:
:setf perl

To have this behavior by default, modify the filetype.vim file.

benoy@palazhi:~$ find / -name 'filetype.vim' 2>/dev/null
/usr/share/vim/vim71/filetype.vim

benoy@palazhi:~$ sudo vim /usr/share/vim/vim71/filetype.vim
[sudo] password for benoy:

After typing the password, include the following line in the file:

" Go project file
au BufNewFile,BufRead *.go setf perl

This will ensure that all *.go files are shown with perl syntax color highlighting by default in vim.

[NOTE]
Ensure that there is no space between the strings "BufNewFile", "," & "BufRead" in the above line.
[/NOTE]

Of course, it is better to have the Go syntax itself on while opening *.go files, instead of the perl syntax scheme. For that do the following:

1. Download go.vim (http://code.google.com/p/go/source/browse/misc/vim/go.vim?r=release)

2. Save it to the ftplugin directory
benoy@palazhi:~$ find / -name 'ftplugin' 2>/dev/null
/usr/share/vim/vim71/ftplugin

3. Add the following lines to .vimrc file

" Syntax highlighting for *.go
autocmd BufNewFile,BufRead *.go source /usr/share/vim/vim71/ftplugin/go.vim

[NOTE]
Ensure that there is no space between the strings "BufNewFile", "," & "BufRead" in the above line.

To locate the vimrc file:
benoy@palazhi:~$ find / -name 'vimrc' 2>/dev/null
/usr/share/vim/vimrc /etc/vim/vimrc
[/NOTE]

Now, *.go files will be shown in the Go syntax scheme by default in the vim editor.

Followers