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!

Error: Please check your email address.
Rocket to Success - Your 10 Tips for Smarter ERP System Selection
Keep up with the latest tech news, reviews and previews by subscribing to the Good Gear Guide newsletter.

Matthew Newton

PC World
Show Comments

Cool Tech

SanDisk MicroSDXC™ for Nintendo® Switch™

Learn more >

Breitling Superocean Heritage Chronographe 44

Learn more >

Toys for Boys

Family Friendly

Panasonic 4K UHD Blu-Ray Player and Full HD Recorder with Netflix - UBT1GL-K

Learn more >

Stocking Stuffer

Razer DeathAdder Expert Ergonomic Gaming Mouse

Learn more >

Christmas Gift Guide

Click for more ›

Most Popular Reviews

Latest Articles

Resources

PCW Evaluation Team

Walid Mikhael

Brother QL-820NWB Professional Label Printer

It’s easy to set up, it’s compact and quiet when printing and to top if off, the print quality is excellent. This is hands down the best printer I’ve used for printing labels.

Ben Ramsden

Sharp PN-40TC1 Huddle Board

Brainstorming, innovation, problem solving, and negotiation have all become much more productive and valuable if people can easily collaborate in real time with minimal friction.

Sarah Ieroianni

Brother QL-820NWB Professional Label Printer

The print quality also does not disappoint, it’s clear, bold, doesn’t smudge and the text is perfectly sized.

Ratchada Dunn

Sharp PN-40TC1 Huddle Board

The Huddle Board’s built in program; Sharp Touch Viewing software allows us to easily manipulate and edit our documents (jpegs and PDFs) all at the same time on the dashboard.

George Khoury

Sharp PN-40TC1 Huddle Board

The biggest perks for me would be that it comes with easy to use and comprehensive programs that make the collaboration process a whole lot more intuitive and organic

David Coyle

Brother PocketJet PJ-773 A4 Portable Thermal Printer

I rate the printer as a 5 out of 5 stars as it has been able to fit seamlessly into my busy and mobile lifestyle.

Featured Content

Product Launch Showcase

Latest Jobs

Don’t have an account? Sign up here

Don't have an account? Sign up now

Forgot password?