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.

Join the newsletter!

Or

Sign up to gain exclusive access to email subscriptions, event invitations, competitions, giveaways, and much more.

Membership is free, and your security and privacy remain protected. View our privacy policy before signing up.

Error: Please check your email address.
Keep up with the latest tech news, reviews and previews by subscribing to the Good Gear Guide newsletter.

Matthew Newton

PC World
Show Comments

Brand Post

Most Popular Reviews

Latest Articles

Resources

PCW Evaluation Team

Luke Hill

MSI GT75 TITAN

I need power and lots of it. As a Front End Web developer anything less just won’t cut it which is why the MSI GT75 is an outstanding laptop for me. It’s a sleek and futuristic looking, high quality, beast that has a touch of sci-fi flare about it.

Emily Tyson

MSI GE63 Raider

If you’re looking to invest in your next work horse laptop for work or home use, you can’t go wrong with the MSI GE63.

Laura Johnston

MSI GS65 Stealth Thin

If you can afford the price tag, it is well worth the money. It out performs any other laptop I have tried for gaming, and the transportable design and incredible display also make it ideal for work.

Andrew Teoh

Brother MFC-L9570CDW Multifunction Printer

Touch screen visibility and operation was great and easy to navigate. Each menu and sub-menu was in an understandable order and category

Louise Coady

Brother MFC-L9570CDW Multifunction Printer

The printer was convenient, produced clear and vibrant images and was very easy to use

Edwina Hargreaves

WD My Cloud Home

I would recommend this device for families and small businesses who want one safe place to store all their important digital content and a way to easily share it with friends, family, business partners, or customers.

Featured Content

Product Launch Showcase

Don’t have an account? Sign up here

Don't have an account? Sign up now

Forgot password?