Linux is great, but sometimes a guy's gotta play games. Here's how to set up a quicker Dual-Boot to get you back into windows.
Over six years ago, Linux became my primary operating system almost overnight. The 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 30 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 behaviour 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:
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 favourite 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:
#!/bin/sh
/sbin/lilo -R windows
/usr/bin/reboot
Now, back on the command line, make bootwin executable with the following command:
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:
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:
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.













6%
10%





















Comments
Post new comment