Thursday, December 17, 2009

GRUB2, TestDisk, LiveUSB Creator and learning your way through issue resolution

Hi again,

Other than through active reading and studying, I would say that most of my (limited) Linux skills were attained through issue resolution, and the research involved in that process.

This has been the case lately, as I faced some issues with GRUB2 and LiveUSB Creator. I had issues with both, not because they were not working as expected, but because of my ignorance and misuse of them.

Basically, GRUB2 is quite different from GRUB. The old easy way in which GRUB could be configured is no longer there. The old /boot/grub/menu.lst file that we could easily tweak is gone, now apparently substituted by /etc/grub/grub.cfg. However, as I quickly realised, GRUB2 is a whole different game.

Essentially, my desktop PC is a triple boot setup. I use two internal hard drives with 250 and 500GB respectively. The 500GB disk contains Ubuntu Studio 9.04 and Ubuntu 9.04 Jaunty Jackalope. The 250 GB, which was installed last, holds Ubuntu 9.10 Karmic. Because of that order, it is GRUB2 who´s in charge of the boot menu.

Initially, my setup was fine, but as I started to get Kernel upgrades into Ubuntu 9.04, I wasn´t seeing them updated on my boot menu. As a result, I was bound to boot into old versions of the Kernel. Not that this was a dissaster by any means, but I wanted to keep my system up to date. In addition, since my boot menu shows three OS entries, I didn´t want it to show obsolete entries, as it is complex enough already. Here´s how I got my way around these problems:

/boot/grub/grub.cfg is a read only file. It is not meant to be manually edited. As a result, just run sudo update-grub to get it up to date and include all OS entries available. This action got my grub menu up to speed, and so I could now boot into the latest Kernel entries for all three OS. However, as you can imagine, there were many entries for all obsolete kernel upgrades, so I needed to clean up my menu. In order to do so, I temporarily granted write priviledges to grub.cfg and commented out those entries I didn´t want to see. Note that that type of entries will get back in there next time you run update-grub. In addition, please remember to set grub.cfg file to read only again after you tweak it.

Then I had another problem just a couple days ago. I got myself an 8GB USB pen drive and wanted to set it up with a Live installation. I used the great Live USB creator application which can be found under Ubuntu System > Administration menu. The problem was that I had two USB drives hooked to my desktop at the time. My mini USB drive, and a 1TB drive I use for my own storage.

The application selected my 1TB drive, and I didn´t realise until it was too late. It prompted me to accept a drive format before it started the process, and I accepted. Dumb ass, I know. Anyways, the drive was quick formatted (luckily it was nothing too serious), but I was faced with losing 180GB of data. Movies, music, my own recordings, documents, etc. I was devastated. Initially it was shocking, I thought there was no way to recover my data.

Luckily, after some minutes, hope sunk in again and I started searching for data recovery tools under Ubuntu. I found people highly regarded TestDisk. I downloaded it and started playing around with it. It took me a few minutes to get to understanding it, and as I wasn´t sure what kind of damage my 1TB drive had, I wasn´t sure what exactly I had to do. Eventually, I cleared my partition table and added a FAT one, which allowed me to browse the drive again using TestDisk. I then copied all of the drive info to my internal drive (Lucky that I had enough space!). Once the copy was successful, I formated my 1TB drive and then copied all info back to it.

Phew! That was close! After I recovered the whole thing, the smile on my face was biiiiiiiig...

So yeah, it was scary for a while, but I ended up learning a lot in both cases. Hope you can use the solutions I found yourself!


  1. The two main frameworks for developing graphical applications are those of GNOME and KDE. These projects are based on the GTK+ and Qt widget toolkits, respectively, which can also be used independently of the larger framework.

  2. hi, i really need that you explain me better this topic beacause i want to understand everything.