LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Howto change GRUB default entry to use with VMWARE without restart? (https://www.linuxquestions.org/questions/linux-software-2/howto-change-grub-default-entry-to-use-with-vmware-without-restart-668235/)

grol 09-07-2008 10:30 PM

Howto change GRUB default entry to use with VMWARE without restart?
 
Hi everyone,

I'm using vmware workstation under suse to boot into xp installed on another partition (i wish wasn't;)) I was trying to come up with a script that would change the grub default entry for the time vmware is run. That didn't work out very well. As I understand grub writes something to boot sector during the shut down, and that's when the changes come into place. Is there a way to do this on the fly without rebooting?

thanks in advance
george

vkmgeek 09-08-2008 12:01 AM

I think u r talking two different things...
If you just need to change default OS boot, you just need to change "default=" in grub.conf and nothing else....
It doesnt have anything to do with shutdown and all tht

keithieopia 09-08-2008 12:09 AM

Do you mean you want vmware to start after a certain amount of time is passed or at a scheduled interval (ex: load XP under vmware at (9:00pm)? If so you'd probably want to use cron to do so. If not, could you re-phrase what you want to do?

grol 09-08-2008 02:45 AM

Quote:

Originally Posted by vkmgeek (Post 3272864)
I think u r talking two different things...
If you just need to change default OS boot, you just need to change "default=" in grub.conf and nothing else....
It doesnt have anything to do with shutdown and all tht

That's what I thought, but apparently you have to restart for the changes to take effect. While the system is running, grub in the virtual machine will not pick the recent changes. Not sure why it is so.

Just to make it clear, the virtual machine boots off the physical drive even thought under a host OS. So it is possible to boot into WinXP natively.

Quote:

Originally Posted by KommanderKaos (Post 3272873)
If not, could you re-phrase what you want to do?

OK, sorry, I should have been more descriptive. My grub config file normally looks like this:

Code:

cat /boot/grub/menu.lst
# Modified by YaST2. Last modification on Thu Aug 21 23:42:06 EST 2008
default 2                                                           
timeout 3                                                           
gfxmenu (hd0,0)/boot/message                                         
##YaST - activate                                                   

###Don't change this comment - YaST2 identifier: Original name: linux###
title openSUSE 11.0 - 2.6.25.15-jen67                                 
    root (hd0,0)                                                       
    kernel /boot/vmlinuz-2.6.25.15-jen67-default root=/dev/sda1 \
        resume=/dev/sda3 splash=silent showopts vga=0x314
    initrd /boot/initrd-2.6.25.15-jen67-default

###Don't change this comment - YaST2 identifier: Original name: failsafe###
title Failsafe -- openSUSE 11.0 - 2.6.25.15-jen67
    root (hd0,0)
    kernel /boot/vmlinuz-2.6.25.15-jen67-default root=/dev/sda1 \
        showopts ide=nodma apm=off acpi=off noresume \
        nosmp noapic maxcpus=0 edd=off x11failsafe vga=0x314
    initrd /boot/initrd-2.6.25.15-jen67-default

###Don't change this comment - YaST2 identifier: Original name: linux-2.6.25.8-jen67-rt###
title Rt -- openSUSE 11.0 - 2.6.25.8-jen67
    root (hd0,0)
    kernel /boot/vmlinuz-2.6.25.8-jen67-rt root=/dev/sda1 \
        resume=/dev/sda3 splash=silent showopts vga=0x314
    initrd /boot/initrd-2.6.25.8-jen67-rt

###WOW
title
    rootnoverify (hd0,2)
    savedefault
    makeactive
    chainloader +1

And this is the script (does not have a good style but does what it's asked to):

Code:

cat /usr/local/bin/xp
kdesu "chmod g+w /dev/sda*;\
mv /boot/grub/menu.lst /boot/grub/menu.lst.old;\
sed 's/default 2/default 3/' /boot/grub/menu.lst.old > /boot/grub/menu.lst;\
su grol -c vmware;\
mv /boot/grub/menu.lst /boot/grub/menu.lst.old;\
sed 's/default 3/default 2/' /boot/grub/menu.lst.old > /boot/grub/menu.lst;\
rm -f /boot/grub/menu.lst.old;\
chmod g-w /dev/sda*"

Don't worry about the first line, vmware just needs the write access to the xp partition and apparently to the root partition as well.
By the end of the third line, menu.lst does have 3 as the default entry which is the windows xp entry. However when vmware runs and shows my grub menu, the highlighted option is still suse and I have to manually choose the xp entry. Not a big deal, it just feels good when everything is automated ;)

aus9 09-08-2008 07:47 AM

hmm well I think you are confusing real bios and partitions to virtual?

if xp is on an emulated partition visible to vmware...then grub can boot it under emulation and you change the emulated grub file if you have
one, to reflect your preferences.

but it is not clear to me, that the grub menu file you have posted is a real or not. So me ask a couple of questions and maybe you can see how to
reply.

1) You have a suse install and a suse grub file. I want to boot directly from suse into a vmware xp?
yes setup vmware load xp as an emulation, choose your bootloader etc if dual booted emulation.

2) I have a suse host with vmware and I want to boot into a real partition that is xp?
News to me that you can do it without a reboot. please tell me how you are doing it.

3) I am not sure what I want....what are my options in the current mindset?

a) get rid of linux...install xp for real...download an emulator (or whatever) run linux from that application
b) get rid of ms....install linux for real...download an emulator (or whatever) run ms from that application
c) keep my xp and linux partitions but I want to play with linux...install more virtual linux systems then

I do not use vmware so I may be wrong on what you can already achieve I use virtualbox. Feel free to correct me on all of my mistakes

grol 09-08-2008 10:37 AM

Quote:

Originally Posted by aus9 (Post 3273237)
hmm well I think you are confusing real bios and partitions to virtual?

if xp is on an emulated partition visible to vmware...then grub can boot it under emulation and you change the emulated grub file if you have
one, to reflect your preferences.

but it is not clear to me, that the grub menu file you have posted is a real or not. So me ask a couple of questions and maybe you can see how to
reply.

1) You have a suse install and a suse grub file. I want to boot directly from suse into a vmware xp?
yes setup vmware load xp as an emulation, choose your bootloader etc if dual booted emulation.

2) I have a suse host with vmware and I want to boot into a real partition that is xp?
News to me that you can do it without a reboot. please tell me how you are doing it.

3) I am not sure what I want....what are my options in the current mindset?

a) get rid of linux...install xp for real...download an emulator (or whatever) run linux from that application
b) get rid of ms....install linux for real...download an emulator (or whatever) run ms from that application
c) keep my xp and linux partitions but I want to play with linux...install more virtual linux systems then

I do not use vmware so I may be wrong on what you can already achieve I use virtualbox. Feel free to correct me on all of my mistakes

Like I said in the beginning of my previous post, the virtual machine boots off the physical drive even thought under a host OS. So it is possible to boot into WinXP natively. By that I mean that I have WinXP installed on /dev/sda3 which is a FAT partition. It has two hardware profiles. One for native use, the other for running it under vmware from linux or whatever host. So that sounds like your QA-2 and here is a good howto for that: Link

I only need windows for that work that has to be done in AVRStudio (wine's no good here). There are plenty of tools for linux to code for atmel's boards but it's just easier to communicate with other people in the team if i use the same software. I'm from UniNSW btw, that's for one of the courses)

So when vmware starts its virtual machine it does look at my real grub (or at least it shoud). If I let it go over the timeout it will even try to boot the same kernel I'm running at the moment. Usually the host OS just freezes, and it is not recommended anyway. So the question is still the same: why suse needs to reboot before vmware would recognise the changes to grub's menu.lst?

keithieopia 09-08-2008 10:46 AM

Ah OK, I think I have deciphered what you're trying to say! Let me know if this is correct.
  • You are dual booting Linux and Windows from the same hard drive.
  • VMWare / Virtualbox is using a real partition and not a disk image.
  • You want to boot Windows from inside of linux using VMWare or vice versa.
  • However, VMWare is not writing the files you change directly to disk.

Is this remotely right? Did I get some of the points correct? If not please re-re-phrase. I don't think we're even understanding the information let alone the problem yet. :-)

grol 09-08-2008 06:54 PM

Quote:

Originally Posted by KommanderKaos (Post 3273423)
Ah OK, I think I have deciphered what you're trying to say! Let me know if this is correct.
  • You are dual booting Linux and Windows from the same hard drive.
  • VMWare / Virtualbox is using a real partition and not a disk image.
  • You want to boot Windows from inside of linux using VMWare or vice versa.
  • However, VMWare is not writing the files you change directly to disk.

Is this remotely right? Did I get some of the points correct? If not please re-re-phrase. I don't think we're even understanding the information let alone the problem yet. :-)

The first 3 points are exactly right (the 3rd on being: I want to boot windows from inside linux using VMWare). I can read/write files without any problems from withing Windows. Lest go over the real problem step by step.

1. Say I have 4 entries in grub:
0-suse default
1-suse failsafe
2-suse realtime (current default) - my usual kernel
3-windows

2. Say I go to edit menu.lst so that it says "default 3" as if it was pointing to windows entry.

3. Now, if i run vmware and start my virtual machine it will show my normal grub screen but it will still have entry 2 (suse realtime, my usual kernel) chosen by default. That is wierd coz i just manually changed it to 3 (windows) in step 2 above.

4. If I shut the virtual machine down, AND reboot the real machine, grub's default entry does become 3 (windows)!! Both in the real machine and in vmware. As you see the change i made in step 2 does not apply until i reboot the real machine.

This is not really a problem, but rather a challenge to find out why it is so. It's not hard to hit a button during the VM boot anyway, but I just need to execute another command before vmware starts (related to direct disk write permissions as you mentioned), so why not put everything in a script.

aus9 09-08-2008 07:09 PM

ok it may be hardware issue?

VMware Workstation supports using raw disk partitions only on IDE drives. Booting guest operating systems on raw SCSI drives is experimental. However, if a virtual machine is configured with a virtual disk, instead of a raw disk partition, then its disk (file) can be stored on the Linux file system, regardless of whether the underlying drive(s) containing the file system are IDE or SCSI.

source http://www.vmware.com/support/refere...ces_linux.html

More info on vmware
http://www.vmware.com/support/refere...sks_linux.html



2) It may be a permissions issue?
http://www.vmware.com/support/refere...ces_linux.html

I think I understand what you are doing, but I use vbox so have no wish to load another emulator

good luck

keithieopia 09-08-2008 11:13 PM

I know VMWare has a option to take snapshots so that any changes are put into a so called cache until you shutdown VMWare when it gets written back to disk. It's purely speculative, but it might be caused by that. I wonder if running VMWare as its own user that doesn't have permission to the /boot/ folder would fix the issue.

grol 09-09-2008 04:56 AM

Quote:

Originally Posted by KommanderKaos (Post 3274049)
I know VMWare has a option to take snapshots so that any changes are put into a so called cache until you shutdown VMWare when it gets written back to disk. It's purely speculative, but it might be caused by that. I wonder if running VMWare as its own user that doesn't have permission to the /boot/ folder would fix the issue.

It must have permissions to the whole disk. Moreover, it needs write permissions there. Assuming the user is in the group disk, even doing
chmod g+w /dev/sda1
chmod g+w /dev/sda2
chmod g+w /dev/sda3
chmod g+w /dev/sda4
(all the partitions i have) will make vmware return
Quote:

Cannot open the disk '/home/grol/vmware/WXP321/WXP321.vmdk' or one of the snapshot disks it depends on.
Reason: Insufficient permission to access file
.
Must have write permissions to the whole disk
chmod g+w /dev/sda

Same if I chose to only use /dev/sda3 (my windows partition) when setting up vmware. But this time it will make GRUB go into error 17. I checked out some threads on other forums, the only solution is to choose the whole disk in vmware, as I was using it before.

So no way to check its behavior without giving permissions.

keithieopia 09-09-2008 10:41 AM

What I met was, give VMWare permission to use the Window's partition (it obviously will need it to run Windows), BUT only give VMWare read/write permissions to it's folder: '/home/grol/vmware/', and only read permission for the rest of the Linux root.

Since /boot/ is located on your Linux root partition, VMWare shouldn't be able to muck around with grub, but should be able to touch it's configuration and read the files that the MBR points to... but not change them in anyway.


All times are GMT -5. The time now is 09:55 AM.