Finally Get Ubuntu 12.04 Installed

After I replaced my old hard drive with 1TB seagate hard disk from MSY, I tried to install dual boot of Windows XP and Ubuntu with 50GB and 30GB partitions respectively, but never got success. Everytime I got Ubuntu installed, Grub2 always complained about unrecognised partition and unable to boot, I had to remove the Linux MBR to allow Windows to boot. The reason being that somehow my BIOS is unable to read the boot partition created by Linux, some people on the Internet saying that some system’s BIOS has limitations if the boot partition is too far from the beginning of the disk. I never found a solution to fix this issue.

My old hard disk has bad sectors, that’s why I have to replace it as Windows kept failing due to corrupted system files. I gave a bet and managed to re-partition the whole disk and allocate 30GB to install Ubuntu. I was lucky that the first 100GB of disk space can be re-claimed, however the rest of 220GB Ubuntu is unable to format due to bad sector. Anyway, as long as I can get Ubuntu going, I don’t worry much about the loss of this 220GB space, this hard disk was planned to be throw away anyway.

Now I have two system running on separate hard disk. Windows XP is running on the new hard disk and Ubuntu 12.04 is on the old disk. They are running very happy with each other so far. Here are some screenshots for Ubuntu:

Dash Home:

Ubuntu Software Centre:

CompizConfig Settings Manager:

Windows switching:

Workspace switcher:

I am still struggling with installing PPStream to watch videos online, but so far it is quite good, very fast start up and shut down and compiz is awesome, although with some bugs that sometimes kill itself.

Next step is to get my webcam working with Skype. Wish me luck.

How to Clear Ubuntu Grub Loader

I was trying to install Ubuntu 12 on my existing Windows XP installation on a separate partition, using the image downloaded and burned onto a CD-RW. However, after the installation completed and my PC rebooted, I got an error after the POST screen:

no parition found
grub rescue >

The screen stayed there and I can’t reach the point to choose which OS to boot from. Looks like the new version of Grub has trouble finding the correct partitions on my hard drive. I have installed previous version of Ubuntu without problems under the exact same partition structure on my disk.

I have tried installing it twice, one with single partition and another one with “/” and swap partition, however none of them were working.

I had no choice but needed to remove the Ubuntu’s boot loader from MBR and bring back my Windows XP, otherwise my system will not be useful at all, as I can’t boot into Windows anymore.

To remove the Ubuntu boot loader, I have to boot back into Windows installation CD and using the Recovery Console to fix the boot issue.

After system recovery console is loaded

C:\WINDOWS> cd ..
C:\> fixboot C:

Now my Windows is back, I need to find out what caused the issue and will try to install it again.

Ubuntu Server Cron Job Not Working

I have Ubuntu 11.04 installed to serve my own server to host my blogs and subversion repository. I had the history of losing my whole server’s data when my VPS host company did some terrible things. So I decide to setup a cron job to backup my SVN repository on daily basis by simply using svnadmin.

I used command:

crontab -e

and then enter:

5 8 * * *          /bin/bash /home/user1/Dropbox/backups/scripts/ > /tmp/cron.log

to the end of file and save it. However, the cron job never runs and the log file was never created. I tried on root user as well and also without any luck.

In the end I have found out this is actually a bug on the Ubuntu system ( not sure other distros though ) from Ubuntu Help:

When adding a new entry to a blank crontab, forgetting to add a newline
 at the end is a common source for the job not running. If the last line
 in the crontab does not end with a newline, no errors will be reported
 at edit or runtime, but that line will never run. 

See man crontab for more information.
This has already been suggested as a bug.

So what I did was to add a few new lines to the end of “crontab -e” output and then restart the cron server:

service cron restart

Now my cron job works perfectly. I have my backup runs everyday and it uploads to dropbox automatically, I don’t need to worry about lose data anymore.

Add User to Sudo List in Ubuntu

To add a user to your system’s sudo user list, do the following in Ubuntu:

Type visudo on your command line, of course you will need root access to do this.
Find the section that looks like this:

# User privilege specification
root ALL=(ALL) ALL

Add your user straight after the above code like this:

# User privilege specification
root ALL=(ALL) ALL
newuser ALL=(ALL) ALL

This is the most basic way to add your new user to the sudo list.

Happy Ubuntuing….

Migrated from MySQL to SQLite

I bought a new VPS from HostMist a few weeks back and installed Ubuntu with 128M RAM. After running Apache and MySQL for a while, I realised that 128M is simply not enough. So I decided to give Lighttpd and SQLite a try.

Installation is very smooth in Ubuntu for both and configure Lighttpd is easy enough. However, it does take me sometime to figure out how to migrate the data from MySQL to SQLite. I will explain what I did in this post.

Firstly you will need to install a PDO plugin for SQLite to run under WordPress. It should be straightforword enough and no explanations would be needed.

Secondly you will need to migrate your existing data in MySQL into SQlite, unless you just started your new blog. I have found a little shell script to convert exported MySQL schema to SQLite syntax at JBipNet, it is very useful:

if [ "x$1" == "x" ]; then
  echo "Usage: $0 "

cat $1 |
grep -v ' KEY "' |
grep -v ' UNIQUE KEY "' |
grep -v ' PRIMARY KEY ' |
sed '/^SET/d' |
sed 's/ unsigned / /g' |
sed 's/ auto_increment/ primary key autoincrement/g' |
sed 's/ smallint([0-9]*) / integer /g' |
sed 's/ tinyint([0-9]*) / integer /g' |
sed 's/ int([0-9]*) / integer /g' |
sed 's/ character set [^ ]* / /g' |
sed 's/ enum([^)]*) / varchar(255) /g' |
sed 's/ on update [^,]*//g' |
sed 's/\\r\\n/\\n/g' |
sed 's/\\"/"/g' |
perl -e 'local $/;$_=;s/,\n\)/\n\)/gs;print "begin;\n";print;print "commit;\n"' |
perl -pe '
if (/^(INSERT.+?)\(/) {
' > $1.sql
cat $1.sql | sqlite3 $1.db > $1.err
ERRORS=cat $1.err | wc -l
if [ $ERRORS == 0 ]; then
  echo "Conversion completed without error. Output file: $1.db"
  rm $1.sql
  rm $1.err
  echo "There were errors during conversion.  Please review $1.err and $1.sql for details."

I simply copy the code to my local directory named “”, dump the MySQL database with:

mysqldump -u {user} -p --compatible=ansi --skip-opt {database} {tablelist} > MyBlog

You will need to make sure that your SQLite database file has the same name as the new dumped MySQL file, in my case is MyBlog.sqlite. Now simply run the script saved before:

sh MyBlog

The script will create and overwrite the original MyBlog.sqlite file and you are ready.