LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Virtualization and Cloud
User Name
Password
Linux - Virtualization and Cloud This forum is for the discussion of all topics relating to Linux Virtualization and Linux Cloud platforms. Xen, KVM, OpenVZ, VirtualBox, VMware, Linux-VServer and all other Linux Virtualization platforms are welcome. OpenStack, CloudStack, ownCloud, Cloud Foundry, Eucalyptus, Nimbus, OpenNebula and all other Linux Cloud platforms are welcome. Note that questions relating solely to non-Linux OS's should be asked in the General forum.

Notices


Reply
  Search this Thread
Old 05-06-2011, 11:51 PM   #1
kdmorse
LQ Newbie
 
Registered: May 2011
Posts: 2

Rep: Reputation: 0
Changing Grub Defaults until VMWare


This is gonna be a strange questions, but here it goes....

Is there any way for Grub to sense if it is running under VMWare or not, and perform different actions based on that detection?

Simple example. If GRUB is booted from the MBR on a a host system, I want it to default to entry #1 (and boot windows 7). If Grub is started inside VMWare (which not surprisingly is running under Windows 7) - I want it to know that under VMWare, it's to start entry #2 - Linux.

I know there are potentially fatal flaws to this design. It comes with the warning of "Don't do this if you value your data". But I've already done it in a play environment, and am looking to streamline it.

All I'm really looking for is a way for GRUB to default to Windows when the hardware boots (but make Linux and option). But when under VMWare, that same grub should default to Linux.

The current result, is that if I don't catch it, grub selects windows 7 by default and attempts to boot the same windows 7 it's running under, and that goes somewhat south in a hurry.

Anyway, just angling for clever ideas....

Thanks

-Ken
 
Old 05-07-2011, 12:56 PM   #2
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
@ Reply

Hi there,

Can you please let us know how your host machine is configured i.e. which OS is installed on it, what are the partitions available etc etc.

Also let us know about your virtual machine configuration (Guest Machine) i.e. How you have configured it and from where it is taking grub.cfg/grub.conf file

As of now from what you say I can understand that you have two OS installed on your host machine one is Windows 7 and not sure which is the other one. In your host machine grub has got two entries: default entry is 0 and entry 1 is Windows 7 you want the default entry to be set to 1 so that it automatically start Windows 7.

Now lets come to VMware part, I am bit confused here as to how you are using the host system grub in VMware.

Can you please make the things a bit straight so that all of us can understand as to what you are trying to do.
 
Old 05-07-2011, 02:47 PM   #3
kdmorse
LQ Newbie
 
Registered: May 2011
Posts: 2

Original Poster
Rep: Reputation: 0
Sorry, the perils of asking questions in the wee hours of the morning may have obscured some information, apparently including the thread title (Should have been 'under vmware' of course), and what I'm really after.

The host hardware is a Thinkpad, nothing special. On this thinkpad two OS's are installed. At the front of the disk is Windows 7. After that is a linux system, Fedora 14. Grub is currently the bootloader stored in the MBR. (I was using windows bootmgr for a while, and while it worked for this, it was problematic). Either can be booted normally, bios -> grub -> one os or the other.

So, two OS's installed side by side. Under Windows 7 is installed VMWare player (I may switch to a different vmware product if I decide another will work better). VMWare player has a guest defined for the physical Linux Fedora 14 listed above. It's defined as raw disk access, there is no VMDK, no separate guest disk - it simply boots the other top level system up as a guest.

In doing so, it uses the same bootloader (grub in the MBR) as the host does when it boots. So the guest powers up, reads the mbr from it's 'virtual' disk, which happens to be mapped directly to the MBR of the physical disk. The same grub config gets loaded. And if you select Linux, the same linux that can be booted natively, now comes up as a guest under windows.

It would be correct to point out that this is slightly(*) dangerous. It's not as dangerous as you might think, as windows on the host will block any writes to any volumes it has mounted, but it's still not terribly sane. On the other hand, it works great, and is remarkably handy.

Now - back to the original dilemma. There is no way to configure grub that I can think of, that doesn't require constant manual selection. The host will boot Windows 7 90% of the time, so Windows 7 is the default. However, this means when bringing up the linux guest, windows 7 is the default (causing windows 7 to try to come up as a guest under itself, when ends badly). So, my main grub needs a generous timeout to allow for guest selection, which slows unattented host boots by the same amount.

Ideally, I would like to rig something so that grub is aware it's being started under vmware, or is somehow started differently under vmware, so that it, for that boot, defaults to linux without intervention. So that when powered up, the system boots to windows 7, and when vmware is started, linux boots - all with no human intervention or timeout interruption required.

It may be a crazy dream, and I'm very close, so I'm angling for clever ideas.

(And yes, there is a very specific reason why I'm heading down this road. If this works out, I will no longer have to carry two laptops with me everywhere I go).

Thanks,

-Ken
 
Old 05-07-2011, 03:09 PM   #4
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
@ Reply

Well that make the things a lot clearer.

As I can understand you are using Use Physical Disk option in VMware to allow your VM to get the direct access to the physical disk and from there you are booting another top level OS as guest in VMware.

Well in that case I would say you can go with an increased timeout of say 10 secs (I think that much delay in booting up the host machine is nominal). I am really not sure if there is a way to make grub aware that it is running in VMware (Anyways just a logic here, you run VMs in that way that it looks like you are working on a physical machine then why differentiating here ;-) ). Also using windows boot manager will not work as you are using physical disk grub will be the one that will get loaded in the memory and if you change windows boot manager that will make the changes at top level as well and can mess up with both of your OS.

So I would say be quick enough and change to Fedora when starting VM within 10 secs if you set timeout to 10 :-)

Last edited by T3RM1NVT0R; 05-07-2011 at 03:11 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
SuEXEC Defaults Values not changing IwantLINUX Linux - Server 2 11-26-2010 08:10 AM
[SOLVED] no grub/defaults/grub to edit on triole-boot system EDDY1 Linux - Software 21 10-31-2010 03:10 PM
[SOLVED] Changing hard drive mounts to defaults heberg21 Linux - Newbie 4 01-17-2010 07:55 AM
Changing defaults in ssh Koven Linux - Security 3 07-03-2005 03:15 PM
Grub defaults TazLinux Linux - Hardware 1 11-24-2004 06:38 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Virtualization and Cloud

All times are GMT -5. The time now is 05:40 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration