Thursday, September 17, 2009

Default boot in dual boot systems

Most of us have dual boot on PCs/laptops. One for linux OS and the other for Windows OS.

The default boot would be linux OS. I.e. While the system is switched on and no selection on OS to boot is made, the boot done would be the linux OS.

And if anyone wants to work on Windows and he/she forgot to make the selection, the system might end-up in booting the linux OS.

Some people may mostly work on windows and they have linux for their least purpose. For them it would be better if the default boot is Windows.

So how to change it?

Simple! The dual boot is done by the GRUB (GRand Unified Bootloader). A change in GRUB is needed to employ this change. To do the change in GRUB first boot the linux OS on the system. Open the file "/boot/grub/menu.lst". At line 14 of file "/boot/grub/menu.lst", change the entry number of the "default" entry with the number corresponding to the entry for Windows OS. The entry list can be seen at the end of the file "/boot/grub/menu.lst".

An Example:

Before modification, the file "/boot/grub/menu.lst" was:

default 0
...
...
...
title Ubuntu 8.10, kernel 2.6.27-11-generic
uuid 17d035fe-5a14-49b6-887e-1a3ccd553e32
kernel /vmlinuz-2.6.27-11-generic root=UUID=7d85ba3f-2c1d-4f1e-b30d-6d1df00ac7a3 ro quiet splash
initrd /initrd.img-2.6.27-11-generic
quiet

title Ubuntu 8.10, kernel 2.6.27-11-generic (recovery mode)
uuid 17d035fe-5a14-49b6-887e-1a3ccd553e32
kernel /vmlinuz-2.6.27-11-generic root=UUID=7d85ba3f-2c1d-4f1e-b30d-6d1df00ac7a3 ro single
initrd /initrd.img-2.6.27-11-generic

title Ubuntu 8.10, kernel 2.6.27-7-generic
uuid 17d035fe-5a14-49b6-887e-1a3ccd553e32
kernel /vmlinuz-2.6.27-7-generic root=UUID=7d85ba3f-2c1d-4f1e-b30d-6d1df00ac7a3 ro quiet splash
initrd /initrd.img-2.6.27-7-generic
quiet

title Ubuntu 8.10, kernel 2.6.27-7-generic (recovery mode)
uuid 17d035fe-5a14-49b6-887e-1a3ccd553e32
kernel /vmlinuz-2.6.27-7-generic root=UUID=7d85ba3f-2c1d-4f1e-b30d-6d1df00ac7a3 ro single
initrd /initrd.img-2.6.27-7-generic

title Ubuntu 8.10, memtest86+
uuid 17d035fe-5a14-49b6-887e-1a3ccd553e32
kernel /memtest86+.bin
quiet

### END DEBIAN AUTOMAGIC KERNELS LIST

# This entry automatically added by the Debian installer for a non-linux OS
# on /dev/sda1
title Microsoft Windows XP Professional
root (hd0,0)
savedefault
makeactive
chainloader +1

Here the entry number of "default" entry is '0'. The entry number '0' corresponds to first entry (i.e. Ubuntu 8.10, kernel 2.6.27-11-generic) of the OS list at the bottom of the file "/boot/grub/menu.lst". So by default the linux OS Ubuntu will get booted.

Now to change the default boot to Windows OS, the entry number of "default" entry should be changed to '5'. The entry number '5' corresponds to the fifth entry (i.e. Microsoft Windows XP Professional") of the OS list at the bottom of the file "/boot/grub/menu.lst".

After modification, the file "/boot/grub/menu.lst" is as follows:

default 5
...
...
...
title Ubuntu 8.10, kernel 2.6.27-11-generic
uuid 17d035fe-5a14-49b6-887e-1a3ccd553e32
kernel /vmlinuz-2.6.27-11-generic root=UUID=7d85ba3f-2c1d-4f1e-b30d-6d1df00ac7a3 ro quiet splash
initrd /initrd.img-2.6.27-11-generic
quiet

title Ubuntu 8.10, kernel 2.6.27-11-generic (recovery mode)
uuid 17d035fe-5a14-49b6-887e-1a3ccd553e32
kernel /vmlinuz-2.6.27-11-generic root=UUID=7d85ba3f-2c1d-4f1e-b30d-6d1df00ac7a3 ro single
initrd /initrd.img-2.6.27-11-generic

title Ubuntu 8.10, kernel 2.6.27-7-generic
uuid 17d035fe-5a14-49b6-887e-1a3ccd553e32
kernel /vmlinuz-2.6.27-7-generic root=UUID=7d85ba3f-2c1d-4f1e-b30d-6d1df00ac7a3 ro quiet splash
initrd /initrd.img-2.6.27-7-generic
quiet

title Ubuntu 8.10, kernel 2.6.27-7-generic (recovery mode)
uuid 17d035fe-5a14-49b6-887e-1a3ccd553e32
kernel /vmlinuz-2.6.27-7-generic root=UUID=7d85ba3f-2c1d-4f1e-b30d-6d1df00ac7a3 ro single
initrd /initrd.img-2.6.27-7-generic

title Ubuntu 8.10, memtest86+
uuid 17d035fe-5a14-49b6-887e-1a3ccd553e32
kernel /memtest86+.bin
quiet

### END DEBIAN AUTOMAGIC KERNELS LIST

# This entry automatically added by the Debian installer for a non-linux OS
# on /dev/sda1
title Microsoft Windows XP Professional
root (hd0,0)
savedefault
makeactive
chainloader +1

Now the default boot is Windows OS.

GCC build on Windows

GCC relies on POSIX (Portable Operating System Interface) functionality which is not available in Windows natively. Hence for building GCC on windows, a linux-like environment for Windows is used. The linux-like environment for windows is brought via:

  1. cygwin (or)
  2. MinGW (Minimalist GNU for Windows)

Both cygwin and MinGW output windows executable ('.exe' file). But the executable built on cygwin has the cygwin DLL dependency (I.e. The GCC compiler executable to run, the required cygwin DLLs should be made available to the executable). Whereas the executable built on MinGW has no such dependency.