Do not use, republish, in whole or in part, without the consent of the Author. TheTAZZone policy is that Authors retain the rights to the work they submit and/or post…we do not sell, publish, transmit, or have the right to give permission for such…TheTAZZone merely retains the right to use, retain, and publish submitted work within it’s Network

I did not write this article, i merely read it and thought it would be a good idea to bring it over here. The article was written by Matthew Newton of pcworld.com and can be found here:
http://www.pcworld.com/howto/article/0, … 200,00.asp


This month, the Free Agent goes under the hood to make booting into Windows simpler. Because sometimes, you just gotta game.

Matthew Newton, PC World
Friday, October 22, 2004

Six years ago this month Linux became my primary operating system; it happened almost overnight. The startup company I had been working for imploded. I was at home, working on my resume, when my Windows PC crashed for the umpteenth time. I knew a bit of Unix (when I first started using the Internet, my only means of access was a Unix shell account) and was not at all intimidated by the idea of installing something Unix-y on my PC. I took the plunge and never looked back.

My main box has been a dual-booter for six years now. When it powers up, the first screen following the BIOS message asks me to choose between Linux and Windows. If there is no response after thirty seconds, Linux is chosen by default, and a short while later, Linux has booted and is waiting for me.

But the way the boot process works presents a problem when I want to play Myst IV: Revelation and go to bed four hours late. When it’s Myst time, I tell Linux to reboot. I wait for it to shut down. The system restarts. I wait for the boot loader screen. I select Windows. Then I wait for Windows to boot. I have to do all this sitting and waiting because I have to be present at that key moment when I have to select Windows instead of Linux. But I’d really rather be fetching a tasty beverage from the fridge.

What I need is one button on my Linux desktop that starts the reboot-with-Windows process and needs no further action from me until Windows is up and running. Sound useful? Let me show you the magic spell.

Hacking Your Boot Loader

On most Linux boxes, the boot loader is a tiny bit of code called LILO (for LInux LOader). You can alter LILO’s behavior for its next boot very simply, using its -R command-line option. For instance, on my Mandrake box, the following command tells the system to boot into Windows next time without any additional prompting:

Code: Select all
lilo -R windows

That command must be issued when you’re logged in as the root user.

It’s only a couple more steps to write a shell script that fires off that command and also causes the machine to reboot. First, open your text editor of choice. If you don’t have a favorite editor, press Alt-F2 and enter gedit if you’re a Gnome user, kedit if you’re a KDE user. Now, create a text file called “bootwin” and put these lines in it:

Code: Select all
/sbin/lilo -R windows

Now, back on the command line, make bootwin executable with the following command:

Code: Select all
chmod u+x bootwin

If you’re logged in as root, issuing ./bootwin will run the script. The problem is, only the root user can tell the boot loader to do something different on the next boot, so when you are logged in with your normal user account, the bootwin script will conk out. (On my Mandrake box, the LILO command fails but the reboot command succeeds, so the machine reboots into Linux. Nuts.)

The solution is to somehow make your script run as a root user. There are many ways to do this. Here’s one:

Code: Select all
su -c ./bootwin

You’ll be prompted for the root password, and then the script will execute as if the root user (or the “superuser”–hence “su”) launched it. Even better, if you have the sudo command installed and configured on your box, you can simply issue:

Code: Select all
sudo bootwin

With the proper sudo setup, you won’t even be prompted for a password. Bootwin will simply run with root privileges, despite the fact that an ordinary user launched it.

Fine-Tuning Your Script

There are three potential problems with the bootwin script at this stage. First, our LILO command assumes that your Windows partition is named “windows” in LILO’s configuration. That might not be the case. To find out what LILO calls your Windows partition, enter this command as root to reveal LILO’s configuration file:

Code: Select all
cat /etc/lilo.conf

You’re looking for two lines that look something like this:

Code: Select all

In this case, LILO thinks my Windows partition is called “dos,” so I need to replace “windows” with “dos” in my bootwin script. Easy enough.

A second potential problem is that in your particular flavor of Linux the LILO and reboot commands may live elsewhere than at the paths in the script. As root, you can use which lilo and which reboot to find out the full path to these commands. If you find, for instance, that on your system reboot lives under /sbin instead of /usr/bin, then alter the final line of bootwin to point at /sbin/reboot instead of /usr/bin/reboot.

When Things Get Grubby

Now then, there’s one more potential problem, and it’s a doozy. It could be that your Linux box isn’t booting with LILO. There’s another popular boot loader called GRUB (for GRand Unified Bootloader). It lurks, for example, on my box that runs Fedora Core. I’ve long been convinced that it was impossible to craft a bootwin script on a machine with GRUB, because GRUB has no equivalent to the LILO command-line option for automating the next boot choice.

But when Myst IV arrived (is my obsession clear yet?), I decided to give it a shot again. To make a long story short, there was nothing out there on the Web (at least, nothing that Google turned up) about how to make this magic happen. So I’m going to change that right now. Here’s a version of bootwin that works on my Fedora Core system, where GRUB is the boot loader:

Code: Select all
/sbin/grub --device-map=/boot/grub/device.map --batch <<FOO
savedefault --default=3 --once

Similar caveats apply here as before: The GRUB and reboot commands may live in different directories on your machine. The script needs to run as root. And you’ll need to check to see where your Windows partition is referenced in the file /etc/grub.conf. Issuing the following command as root will yield the contents of that file:

Code: Select all
cat /etc/grub.conf

You’re looking for an entry that looks like this:

Code: Select all
title Windows 2000 SP4
rootnoverify (hd0,0)
chainloader +1

In my grub.conf, this was the fourth entry. GRUB counts entries starting with zero, so the first entry is 0, the second entry is 1, and this, my fourth entry, is 3. That’s why there’s a 3 on the “savedefault” line in my bootwin script. You’ll need to change that digit to match the number for your own Windows partition entry.

If you’ve stuck with me this long, then you’ve got a script that will reboot your system into Windows. Now, how to make the script easy to access? Why not add a button to your system panel? In Gnome 2.6, right-click the panel and select Add to Panel, Launcher. In KDE 3.2, right-click the panel and select Add, Special Button, Non-KDE Application. Gnome users, look to the “Command” field; KDE users, find the “Execute” field. Enter the following command there, replacing “/path/to” with the full path of the directory where you’ve put your bootwin script:

Code: Select all
su -c /path/to/bootwin

In both Gnome and KDE, select an icon for your button and be sure to select the “Run in terminal” check box before closing the dialog box. Voilà!

If a button doesn’t interest you, you can instead move the script to a directory in your command path (/usr/local/bin is one good possibility) so that you can press Alt-F2 (in either Gnome or KDE), type bootwin, and be off to the races. (Or, in my case, to the Myst IV realms of Tomahna, Serenia, Spire, and Haven.)

About to Switch to Ubuntu?

The Community release of Mandrake 10.1 has been out for about a month. Mandrake Community releases are roughly akin to an open beta: The idea is that by spreading the Community release far and wide, Mandrake can supplement its own QA efforts and shake out any obscure (or not-so-obscure) bugs turned up by a wide user base before a new version gets pressed to CD.

I hope that there’s a good deal of difference between the Community release of Mandrake 10.1 and the forthcoming Official release: The Community release has given my trusty IBM Thinkpad (which ran 10.0 without issues) nothing but trouble. It’s been so frustrating, I’m considering replacing it with a brand new flavor of Linux.

Ubuntu Linux is a new distribution out of Britain. It’s based on Debian, pledges to always offer a cost-free version (as does Mandrake), and is the first distribution to sport the Gnome 2.8 desktop environment. Yes, folks, this may in fact be the user-friendly, Gnome-based distribution I’ve been hunting for so long. I’ve got a prerelease version of Ubuntu running on a test machine here at PC World HQ, and it’s awfully slick.

The only thing that gives me pause is Ubuntu’s inability to play or encode MP3 files. Fedora Core has the same problem, as I’ve mentioned before, and I hate having to muck around under the hood just to enable support for such a popular file format. I’ve been using Fedora since last spring, and I still can’t get MP3 previewing to work in Nautilus, the Gnome file manager. (In Nautilus, when you hover your cursor over an MP3 file, it’s supposed to start playing and continue until you move the cursor again.) That’s nonsense, and I don’t want to be stuck in the same boat with Ubuntu. So once again, I’m looking for solutions. Stay tuned.

By admin

Former Freehand Freelance Graphic Illustrator... been online since 2004 ( late starter ), blogging since 2005, presently writing a suspense-thriller e-book that began as a screenplay.