Handy grub rescue USB

This post is aimed at everyone who has a USB stick that’s over 3 MB in size. If you do not have such a thing, skip to the grub rescue prompt stuff where you’ll have some information on how to boot into your usual kernel from one.

Grub error.

The worst thing that can happen to you, especially when you’re playing around with your partitions or upgrading. And sometimes, you don’t even get to goto the grub rescue prompt when your MBR gets corrupted. So you end up searching through your cd/dvd pouch for a live cd and realise – damn! I gave it all out to my friends. I recently figured you can have a handy USB stick  to avoid this. There a a couple of ways to do it, one is just to have a partition which has the data of a “live” pen-drive, which can be created from any existing live cd around. The instructions can be found here, believe there is an application installed in ubuntu which does exactly this as well, but then this means you’ll have to sacrifice a significant amount of your disk space for just contingency situations. There is another method, which involves you creating a small partition of about 3-5 MB on your USB stick. Which IMHO is not a lot of space in the modern day USB sticks. So, here goes the method:

1) Choose your favourite partition editing method and resize and existing partition to 5 MB smaller. I usually use “partitioneditior” or “GParted”.

2) Create a new ext3 or ext4 partition using the 5MB generated above.

3) Mount the new partition, lets say its in /mnt/usb

4) Goto a shell, and

mkdir -p /mnt/usb/boot/grub
cp /usr/lib/grub/i386-pc/* /mnt/usb/boot/grub/
echo ‘(hdY) /dev/sdX ‘ /mnt/usb/boot/grub/device.map
sudo grub-install –root-directory=/mnt/usb /dev/sdX

Note, the X and Y above should be the device letter/number for the USB stick.
That’s it. Next time you boot with this USB stick, you’ll get a grub prompt which you can use to boot from.

From the grub prompt, booting is in 3 steps.

1) Specify the root partition
2) Specify the kernel image
3) Specify the corresponding initrd.
And boot.

So, the commands for those are:

root (hdX,Y)

[If you just have one hard disk, X is probably 0, and Y is the root partition. Don’t worry if you’re not sure, there is tab completion and the next step will make things clear]

kernel (hdX,Y)/boot/vmlinuz-foo-bar [Where foo bar can be tab completed to the latest kernel that you have]
initrd (hdX,Y)/boot/initrd-foor-bar [Again, -foo-bar should correspond to the kernel chosen above]

If you’re unable to tab complete and locate the kernel, you’ve chosen the wrong values for X and Y. Try with something else, one hint is the partition type will be some ext*.

Now, just type boot. And you’ll be booted into your above specified kernel. You can then run grub install and restore things back to normal working conditions :)

So, at the cost of 5 MB ( You’ll only need 3 if you think 5 is too much) on your USB stick, and some ten minutes of your time, you have a way to boot when your grub fails – yes, no more running around in search of a live cd. And oh, netbook users – you don’t really have a choice do you? ;)

Moc – The terminal music player for all your needs.

For terminal junkies, music players often come as a small trouble, you never
find a good ncurses based player that’ll offer all the functionality of a GUI
based music player ( of course the GUI player is amarok! ).

To name a few, global shortcuts is almost always  absent, and more importantly,
the concept of a play queue is absent in many. I recently found that MOC
supports queuing, and well, an easy way to control it using krunner. So yAy!

Here’s a small description of MOC and a quick-use cheat-sheet:

From terminal, the command “mocp” fires up the ncurses interface(and starts the
server), its themeable, can generate, save and load playlists and provides a
directory/file listing to enable the same. It also starts playing files from a
directory if you simply navigate to the directory and play the first file.
Read more here.

Now, that’s pretty much the functionality of many terminal based players. What
makes MOC awesome is that it supports queuing.
Plus, I find the interface very _usable_. What more, its key mapping can be
completely customized.

Commands within MOC are really intuitive, you can simply open it and start
using it, press h to display the current key mapping if you are unable to figure
something.

Now, for the seamless “global” control: I realised, instead of having to
navigate to the mocp window or fire up a new shell to control the player, you
can control it with krunner. So, just Alt+F2, and use the following commands for
controls:
mocp followed by

-q –enqueue Add the files given on command line to the queue.
-p –play Start playing from the first item on the playlist.
-l –playit Play files given on command line without modifying the
playlist.
-s –stop Stop playing.
-f –next Play next song.
-r –previous Play previous song.
-x –exit Shutdown the server.
-G –toggle-pause Toggle between play/pause.
-v –volume (+/-)LEVEL Adjust PCM volume.
-k –seek N Seek by N seconds (can be negative).
-j –jump N{%,s} Jump to some position of the current track.
-o –on <controls> Turn on a control (shuffle, autonext, repeat).
-u –off <controls> Turn off a control (shuffle, autonext, repeat).
-t –toggle <controls> Toggle a control (shuffle, autonext, repeat).

I don’t about anyone else, but I found this pretty cool, I don’t have to shift
to a new shell and still be able to do everything that I can with the player
interface.
That’s it for now, signing off.

Grub – What will you do with the black screen of failure?

Grub errors – One of the most common/frustrating errors an average Linux user faces. What’s more frustrating is that there are so many threads in so many forums on this issue that its simply impossible to try out all of them, and the probability of hitting the right one is quite low.

So, here’s a method that I use, something that hasn’t failed me till date.

Step 1 : Procure a debian based live cd (essentially something which uses grub) { This BTW is a tip to all Linux users, ALWAYS have a live CD with you, don’t go around in a wild goose chase for it just when you have problems, Murphy always beats you to it. }
And boot into it.

Step 2: Type the following commands, I’m not going to explain in detail what these do, they are pretty simple commands anyway.

sudo mkdir /mnt/root
sudo mount /dev/sdXY /mnt/root [ here sdXY is your root partition, my case it was sda2 ]
sudo mount -t proc none /mnt/root/proc [Hint: Use tab completion here, you’ll know if you’re using the right sdXY]
sudo mount -o bind /dev /mnt/root/dev
sudo chroot /mnt/root /bin/bash

Step 3: Now, type ls, you’ll see a familiar list of files. Yes, you’re in a root shell of your hard disk. Now, you can do any changes you need to do from “your” bash.

Step 4: [The Fix]

EDIT: Seems, things are a lot easier when you deal with grub-pc these days. Your life is much easier. All you have to do is to:

sudo grub-install /dev/sdX [The same X that you had used above]

And you’re done :)

If even that fails for you, the one below might work. Atleast it did for me the last time I tried it.

More commands to be executed:

grub

You should be in the grub prompt now.

If it says command not found, you’re in for more work.
The issue is you’re in a newer version of grub, which is grub-pc.
So in order for this fix to work,

aptitude install grub-legacy
grub

and proceed. [Note: the install will probably remove grub and grub-pc, don’t worry]

So, now you’re in grub prompt,

find /boot/grub/stage1

This will give you a list of root partitions in (hdX,Y) format, choose one of them.

root (hdX,Y)
setup (hdX)

This should give you a success result.

If not, make sure you’ve typed the commands in right order and have chosen the right values of X and Y.

{ And how to choose the right values of the (hdX,Y)? If your root partition is at say /dev/sda2, it is (hd0,1) }

Now, more stuff to be taken care of, the issue with grub setup is at times it changes your device map. So make sure you edit the /boot/grub/ment.lst file to have the right values of the root partition and the kernel images, especially if you had grub-pc installed.

Now, exit from the chroot shell, sudo umount /mnt/root and reboot.

You’ll no longer see the grub failure screen or the grub rescue prompt :)

A long update – SoC wrap up!

So, things have moved a lot since I last posted. I guess its really time I updated my blog about the cool features which KStars has now :)

For over a month now, I had been working with implementing the “Execute Session” feature and the OAL compliant XML logs. A quick intro to the new stuff:

1. Add Observer:

This is the UI for adding an Observer into KStars, so that when you are going somewhere observing, and you need your name on the logs, you can simply add your name here and use it in the logs.

2. Define Equipment:

This is the place where you can add a list of your Telescopes, Eyepieces, Barlow/Shapley lenses and the filters. For the user’s convenience, we generate a meaningful name string that can be used to identify the object and it has an unique identifier as its id field (which again is auto generated). Here, you can add, delete or edit the list of equipments that you possess. All these will be useful and can be used for the OAL logs. Here’s how the Define Equipment window looks :

defineEquipment

3. The OAL compliant XML logs:

The first question I can think of is why the complicated OAL logs? The answer is as follows:

Lets say, a professional/(advanced) amateur astronomer goes for an observation session and plans to maintain a log of what he saw, the things he would need are:

A. Equipment details:
+ Eyepiece – make, focal length, apparent FOV
+ Telescope – make, focal length, aperture, optical-type (i.e. Newt
/ Cass / Apo / Achromat), mounting-type (i.e. Eq / Dob / Alt-Az)
+ Filters – make, size, type
+ Camera – make, type

B. Location details:
+ Observing site name
+ Lat + Lon + TZ
+ Some generic sky quality description

C. Observing session details:
+ Observing Site
+ List of Equipment
+ That night’s weather conditions explained
+ Seeing / Transparency
+ List of Target objects
+ List of associated logs

D. Logs of his observations:
+ The object details
+ Comments on the object

So, basically one could make his/her observations “scientific” enough, and there are shareable across the world and across different software as well!

Okay, so we’ve got the OAL compliant logs, but how does a user easily and comfortably write the logs?
The answer to that is the Execute UI, here’s what it does:

As it opens, you could add the details of the observation session, the date, time, weather conditions, the site of observations, etc.
A quick preview:

execute_session

Now, time for the real buisness, you start observing, so you select the “Step 2: Observations” link. This takes the objects from your Session List in the Observation planner, sorts the objects by their scheduled observation times, centers the skymap onto the first object and keeps things ready for you to log the observation once you have observed the object. You can even slew your telescope to the current object directly. So, this is what it looks like:

execute_observations_1

After this, you goto the next page and enter the equipment details used for the current observation, which kstars remembers until you change them, this is what this looks like:

execute_observations_2

Then you move on to the next target, so click on the next target and it moves to the next target, centers it on the skymap and you can repeat the procedure comfortably. The best thing about this is that, when you are moving to the next target here, the selection changes in the Observation Planner as well, so you can see the image, altitude vs time and stuff without any effort :)

But what if you forgot to include an object in the session plan? Just click on the “add new object to list” and you can easily add objects into the logs. Even better, it automatically adds the object to your session plan as well. It is this simple:

execute_addObject

And after you’re done observing all the objects, you can refine the session details if you’d like to, say for adding a few extra comments on the weather and finally click on End Session. This would open a file dialog where you can save tge logs to a place of your choice.

Now, apart from these, the Observation planner has a new interesting feature as well, from the wishlist, you can select objects and add a list of objects that are visible tonight to the session plan. A really quick way of planning a session if you’re in a big hurry :)

Now, with all these, I guess my SoC has finally come to an end. I hope people would find these useful and enjoy KStars!
Until my next post, signing off :)

Pretty UI and Images from Google Image search!

Hola!

Time for more updates from soc, this is primarly a big ui change that I’ve made, now things look much less cluttered. So the changes made are

1. Getting rid of the “Show in ImageViewer” , “Get Image” buttons :

Instead of using buttons for these features,  I created an eventfilter and if you click on the empty image in the preview region, it’ll automatically fetch the right image, and if the image is present already it shows it in the ImageViewer. Now thats two buttons less.

2. Using a right-click popup menu, instead of the Large number of buttons present in the Observation Planner. This makes the UI look much more usable, and much less cluttered.

3. Saving and deleting individual images:

In the previous version of the observation planner, you had the option only to save all the images or delete all of them, now this doesn’t quite make the user happy, and hence, there is an option to individually save and delete images for a selected object.

4. And, probably one really useful feature, the Observation planner can get you images from a google image search of the object’s name. This google search feature, fires up a new window, which asyncronously keeps downloading images from the web, and puts a tiny image thumbnail next to it. There is a preview box, for a larger thumbnail. And the cool part is that, you can even edit or crop the image downloaded from within KStars! This also makes it possible for the user to get the images for objects in the solar system, as the DSS/SDSS images are not available for these directly in a search by RA/Dec.

5. And the popup menu provides the user with an option to get the DSS image instead of the default SDSS image in case thats needed.

6.  Also, the core backends of the OAL compliant target lists are ready!

Well time for screenshots now :

1. The New UI of the Observing List :

prettyui

2. The Google Image search in action :

googleimage

3. The Popup menu:

popup

So now, the observation planner looks more useful right?

And good news is, in a day or two, the changes will be merged from my branch into the trunk!

Cheers. Until next post, signing off.

More updates from SoC

Well, its been really long since I posted about the work I’d done so far.

The first thing that I’d like to mention is, I’ve made it possible to filter objects by their magnitude in the What’s Up Tonight Dialog, now this makes life much easier if you have a big catalog and you just would like to know about the objects that you can see with the naked eye or with the telescope. And there is even a slider there for comfortably setting the magnitude. Now the What’s Up Tonight Dialog looks like :

wut

The other new features are :

1. You can view the bigger version of the DSS/SDSS image previews in a separate imageviewer. This enables you to see finer details better, which might prove helpful for star “hopping”.

2. You can now, save the images of all objects in the session list just by a single click, and they’re nearly saved for usage in during the observation session.

3. Okay, so now, you’re worried of your disk space and you decide to clean up all the stored images, now KStars allows you to do that again by the click of a single button.

So, now the Observation Planner looks like

ol

And, look below to see the imageviewer in action :

iv

:D yeah, Astronomy is cool indeed!

And, currently I’m working on creating Observation Logs in XML format, with features like export to OAL(Open Astronomy Log) schema – compliant logs. What has been done till now is that, we can export target lists in the COMAST schema’s format, which means we can exchange stuff amongst other desktop planetarium software! To view one sample list, visit this link.

.

SDSS images!

I finally got the SDSS images support up in the Observation Planner. Now the planner does a search for the SDSS images and displays the DSS image if the requested RA/Dec is out of the SDSS footprint. Though the current implementaion is a sneaky little trick, no one could find/offer a better and shorter method for doing it. Plus it works!

But you might ask whats so special about these SDSS images, well take a look yourself :)

sdss4

sdss3

sdss5

Yes Ladies and Gentlemen they are in colour! Now isn’t that cool?

Plus this completes the Previews section of my SoC proposal ;-) (Now thats cooler right? :D )

Follow

Get every new post delivered to your Inbox.