Dual-bootable; more doable

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 operat­ing system almost overnight. The com­pany 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 install­ing 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.

Recommended

Keep up with the latest tech news, reviews and previews by subscribing to the Good Gear Guide newsletter.

Matthew Newton

PC World

Comments

Comments are now closed.

Most Popular Reviews

Follow Us

Best Deals on GoodGearGuide

Shopping.com

Latest News Articles

Resources

GGG Evaluation Team

Kathy Cassidy

STYLISTIC Q702

First impression on unpacking the Q702 test unit was the solid feel and clean, minimalist styling.

Anthony Grifoni

STYLISTIC Q572

For work use, Microsoft Word and Excel programs pre-installed on the device are adequate for preparing short documents.

Steph Mundell

LIFEBOOK UH574

The Fujitsu LifeBook UH574 allowed for great mobility without being obnoxiously heavy or clunky. Its twelve hours of battery life did not disappoint.

Andrew Mitsi

STYLISTIC Q702

The screen was particularly good. It is bright and visible from most angles, however heat is an issue, particularly around the Windows button on the front, and on the back where the battery housing is located.

Simon Harriott

STYLISTIC Q702

My first impression after unboxing the Q702 is that it is a nice looking unit. Styling is somewhat minimalist but very effective. The tablet part, once detached, has a nice weight, and no buttons or switches are located in awkward or intrusive positions.

Latest Jobs

Don’t have an account? Sign up here

Don't have an account? Sign up now

Forgot password?