grub2 custom configuration

I run windows for Adobe Lightroom, an occasional foray into outlook, and for iTunes, Adobe Elements and Photoshop.

I run linux for the terminal, the native command line for system administration, and for development. I am working with Jenkins Continuous Integration platform, which runs easily on Ubuntu. I’ve run development versions of a LAMP stack and WordPress when doing customization of a WordPress site, on Ubuntu.

I usually dual boot every Windows machine I have. I use Ubuntu and grub, now grub2 to manage the dual boot. Macs I leave as OSX.

What I want is for Windows to be the default boot, and for Ubuntu to require intervention to boot. That was done in grub(1) by moving an entry for Windows into the “0” position, in menu.1st, and having it boot to windows.

That looked something like:

title WinXP
rootnoverify (hd0,0)
makeactive
chainloader +1

As of about Ubuntu 9.x, Ubuntu upgrades would preserve that grub(1) behavior, but new installs would use grub2.

Grub2 has a config file in /boot/grub called “grub.cfg” which is generated by the command “update-grub”.

Editing grub.cfg is not recommended – your edits will go away when “update-grub” is run, and that can be called by a kernel update or OS upgrade.

Instead you place a file in /etc/grub.d. I used the following for Ubuntu 9.04 through to Ubuntu 10.04:

root@vermeer:/etc/grub.d# cat 01_winXP
#!/bin/sh -e
cat 

You create the file and then run "chmod 755 01_WinXP" to make it exectuable, then run "update-grub" to recreate grub.cfg in /boot/grub.

Today I upgraded to Ubuntu 12.04 LTS. And I started getting errors,

"error: no argument specified"

It turns out, the grub2 parameter "search --no-floppy --fs-uuid --set 180c9d7e0c9d5798" has become more restrictive in its syntax. Now it needs to read "search --no-floppy --fs-uuid --set=root 180c9d7e0c9d5798"

So the file becomes:

#!/bin/sh -e
cat 

And you have given it the correct number of arguments, and the error is gone.

 

—doug