Friday, September 28, 2007

Dual Boot XP and Ubuntu 7.04 with NTDLR

My current System partion after the dual boot configuration. Tools You Needed and Handy at all situations. Windows Installation CD (For safety) Ubuntu Installation CD GRUB rescue CD http://supergrub.forjamari.linex.org/ Linux Rescue CD http://www.sysresccd.org/Main_Page USB drive. My System Configuration Dell Precision M90 Dual Processor 100GB hardisk. Partitioning There current partition have 62.72 MB Fat16 this came up with the System where Dell stores its utils. 44.01GB of NTFS and this is Boot Active Partition where all windows files go and it is named C:\ 49.15 GB of NTFS which is empty and named D:\ If you need to format or shrink the partition from windows at initial in any other way you can do it from MMC and select disk partitioning. Just type MMC on the run mode. The whole point here is how to install UBUNTU on windows without affect the current MBR configuration. We wont disturb the windows MBR at any point of time. Now we will boot the system with the linux Rescue CD. Press enter at the end of the prompts and type startx This will take you to the Graphical screen. Select the Disk partition Utility and re-partition your D:\ drive with two linux partitions. we will shrink it D:\ with 24.67 GB of NTFS 22.7GB with ext3 1.76 GB with linux-swap Save the workspace and quit and come out of the os by halt or shutdown. Thats it with partitioning for now. :-) Now Boot the System with the linux install CD. just do all the step until partition Select Manual option give the partition names we partitioned earlier. Like the ext3 and linux-swap. use the ext3 as your root partition. OK ubuntu will complaint now that its not formated check the format option there so that UBUNTU will format the root partition again. At the end of partition select the Advance option. This is the most confusing part in Ubuntu 7.04 it was not there in 6.10 or previous versions. When you click advance it will give a value (hda0) . Actualy it is the place where you going to install your GRUB if you dont change the parameter your an deep trouble it will install in the MBR and wipe out windows MBR no more windows again until u fix the MBR using the Windows Resucue CD the command is MBRFIX it will wipe out the GRUB additions. Back to the GRUB install in the advance option you have to tell UBUNTU you are going to install the GRUB on your LINUX partition that is /dev/sda6 in my case. In previous version we could tell just like that now in the 7.04 we have to tell it as this way. (hda0,5) That means you are going to install the GRUB on your first hard Disk = hda0 and your 5th partition that is 5. Now complete the installation. Before your reboot you can go to the console and type in this dd if=/dev/sda6 of=/media/device/linux.bin bs=512 os=2 this will create a linux.bin file in your USB drive /media/device is my usb drive mount path. If your lucky and did't do anything wrong after your reboot you should be able to get into your windows. If your are not able to Windows but able to get into your Ubunut that means. You have wiped out your MBR. OR Your boot partition is not active instead your Linux partition is active. If it is MBR problem use windows rescue cd to fix it. If the boot partition is not active use the Linux rescue CD and activate the Windows partition active boot. Now get into windows and change the boot.ini in C:\ drive you have make the hidden and system files visible. You can do that from the folder options. now edit it the boot.ini with C:\linux.bin "Linux" as your last lin and save This is how we tell NTDLR to boot the linux using its GRUB. At this point you have another option if you did't have a usb drive or you forget to issue the dd command you have tool called bootpart What it will do is it will create the linux.bin file and add it to the boo.ini no manual editing the file cool, bad part about is it will add a url and some text when you load. Free advertisement. blaaaaaaa. Now reboot the system and see the two option XP and Linux select Linux if its loading and booting your successful in your effort. If not you may have to do one more thing to do. Your GRUB installation is curropted. You have to re-install the GRUB. This where your Super GRUB comes in help. boot again with SuperGrub type C your at the grub prompt now issue this. find /boot/grup/stage1 this will tell you where your grub is installed. it will give (hda0,5) Now try to boot your grub with the boot option from the SuperGrub and give it the place where your GRUB is installed, we found it earlier using the find command. if it errors out like no executable or end line corupted, You have to re-install the GRUB not a big thing. type root (hda0,5) setup (hda0,5) quit Make sure you have a space between root and (, otherwise it will tell command not found. now Your GRUB is re-installed. boot the GRUB again with partition loader. This time it should work.

Wednesday, September 26, 2007

For Each Loop

Iterating over a collection is uglier than it needs to be. Consider the following method, which takes a collection of timer tasks and cancels them:

void cancelAll(Collection c) {
   for (Iterator i = c.iterator(); i.hasNext(); )
       i.next().cancel();
}

The iterator is just clutter. Furthermore, it is an opportunity for error. The iterator variable occurs three times in each loop: that is two chances to get it wrong. The for-each construct gets rid of the clutter and the opportunity for error. Here is how the example looks with the for-each construct:

void cancelAll(Collection c) {
   for (TimerTask t : c)
       t.cancel();
}

When you see the colon (:) read it as “in.” The loop above reads as “for each TimerTask t in c.” As you can see, the for-each construct combines beautifully with generics. It preserves all of the type safety, while removing the remaining clutter. Because you don't have to declare the iterator, you don't have to provide a generic declaration for it. (The compiler does this for you behind your back, but you need not concern yourself with it.)

Monday, September 24, 2007

simpsonized