LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 09-07-2008, 11:30 PM   #1
grol
LQ Newbie
 
Registered: Sep 2007
Posts: 7

Rep: Reputation: 0
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
 
Old 09-08-2008, 01:01 AM   #2
vkmgeek
Member
 
Registered: Feb 2006
Location: Ahmedabad
Distribution: rhel5
Posts: 185
Blog Entries: 2

Rep: Reputation: 31
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
 
Old 09-08-2008, 01:09 AM   #3
keithieopia
Member
 
Registered: Feb 2005
Posts: 69

Rep: Reputation: 18
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?
 
Old 09-08-2008, 03:45 AM   #4
grol
LQ Newbie
 
Registered: Sep 2007
Posts: 7

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by vkmgeek View Post
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 View Post
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

Last edited by grol; 09-08-2008 at 08:03 PM.
 
Old 09-08-2008, 08:47 AM   #5
aus9
LQ 5k Club
 
Registered: Oct 2003
Location: Australia
Distribution: Devuan
Posts: 5,476

Rep: Reputation: Disabled
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
 
Old 09-08-2008, 11:37 AM   #6
grol
LQ Newbie
 
Registered: Sep 2007
Posts: 7

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by aus9 View Post
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?
 
Old 09-08-2008, 11:46 AM   #7
keithieopia
Member
 
Registered: Feb 2005
Posts: 69

Rep: Reputation: 18
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. :-)
 
Old 09-08-2008, 07:54 PM   #8
grol
LQ Newbie
 
Registered: Sep 2007
Posts: 7

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by KommanderKaos View Post
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.

Last edited by grol; 09-08-2008 at 07:57 PM.
 
Old 09-08-2008, 08:09 PM   #9
aus9
LQ 5k Club
 
Registered: Oct 2003
Location: Australia
Distribution: Devuan
Posts: 5,476

Rep: Reputation: Disabled
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
 
Old 09-09-2008, 12:13 AM   #10
keithieopia
Member
 
Registered: Feb 2005
Posts: 69

Rep: Reputation: 18
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.

Last edited by keithieopia; 09-09-2008 at 12:14 AM. Reason: Grammer
 
Old 09-09-2008, 05:56 AM   #11
grol
LQ Newbie
 
Registered: Sep 2007
Posts: 7

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by KommanderKaos View Post
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.
 
Old 09-09-2008, 11:41 AM   #12
keithieopia
Member
 
Registered: Feb 2005
Posts: 69

Rep: Reputation: 18
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
grub not seeing grub-set-default change bic Linux - Software 4 02-15-2008 02:44 PM
LXer: Howto Change Default Text editor in Debian Etch LXer Syndicated Linux News 0 05-22-2007 03:01 PM
Grub: Change Default Boot Entry luwigie Linux - General 4 08-22-2004 03:17 PM
how to change default os in Grub eye Linux - Software 3 05-16-2003 09:10 AM
hot to change default os in Grub jt1020 Linux - General 6 04-27-2003 12:52 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:41 PM.

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