LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   Booting XP resets boot flag to its partition (http://www.linuxquestions.org/questions/linux-general-1/booting-xp-resets-boot-flag-to-its-partition-513619/)

gavinbeatty 12-25-2006 03:45 PM

Booting XP resets boot flag to its partition
 
Hello,

My laptop has a very good open-source multimedia player that needs its own custom MBR. I need to use a special key to boot to the multimedia player - so a normal boot just goes straight to the partition with the boot flag set.
So to use linux, I install bootloader (grub) to a partition, and have its boot flag set.

Current setup is

Code:

Partition:        OS:                Type:                Boot flag:
===========================================================
1                Windows XP        ntfs               
2                Linux (debian)        reiserfs        *

Problem is that when windows boots, it resets the boot flag to partition 1. This means that my bootloader is skipped!

So currently, I need to boot a recovery CD/USB key and use parted to reset the boot flag.


The way I see it, there are 2 solutions:

* find a scriptable way to reset the boot flag to partition 2 on boot of windows so that it can be run automatically at startup. (I'd even accept a non-scriptable way, as long as it doesn't involve a boot floppy with fdisk as that's worse than using a linux recovery CD)
* find a way to get windows to stop acting like it owns by disk!! Can it be told to not reset the boot flag?


Been using linux for 4 years but I know quite little about partition management for windows etc. This not being a windows forum but I figured some other dual-booter may have solved this problem before ;-) . Any suggestion or redirects welcome.


Thanks everyone.

michaelk 12-25-2006 03:54 PM

linux does not care about the boot flag. You can use windows bootloader to start linux:
http://highlandsun.com/hyc/linuxboot.html

gavinbeatty 12-26-2006 12:50 PM

Hmmm, not a preferred solution. 2 bootloaders? I know linux does not NEED to be the boot flag set on its partition in order to boot. But I want a SINGLE bootloader (grub), installed on a linux partition that has its boot flag set. (By single bootloader, I mean single interactive bootloader of course ;-) )

It seems the tutorial you link to is a way around doing what I'm talking about. Is the reason for this that my second suggestion in the original post is impossible?

saikee 12-26-2006 02:40 PM

Easier than you think

(1) While in XP to set Linux partition active

Right click "My Computer", then left click "Manage", then "Storage" then "Disk Management". In there higlight the Linux partition and click "Mark partition as active". On a reboot the Linux will fire up.

(1) While in Linux to make XP bootable

Method A - Using cfdisk - Click terminal and issue command (assuming you disk is hda)
Code:

sudo cfdisk /dev/hda
inside it navigate to the XP partition (the one with Partition type 7 indicating ntfs), highlight it and tap "bootable".

Method B - Using Grub - (This is avilable only in Linux that has Grub) invoke a Grub shell in terminal and issue command
Code:

sudo grub
root (hd0,j)
makeactive
quit

where j=Xp partition number less 1 as Grub counts from 0. Example is xp is the 1st partition the the statement should be "root (hd0,0)"

On a reboot XP will fire up.

--------------------------------

Having said the above I must say I share MichaelK view that we expect Linux to boot without the active flag switched on. Linux doesn't use the damn thing. Have you tried to boot it without the booting flag.

It has to be a damn stupid boot loader that can't boot a Linux with the help of the booting flag. I believe it is a 3rd party boot loader controlling XP's boot loader and Grub in your PC.

Lilo and Grub differ from the MS systems by declaring which partition to be booted up front. Booting flag or not has absolutely no consequence.

gavinbeatty 12-26-2006 06:44 PM

OK, misunderstanding of the situation I think. I'll try be more clear.


So, I want to dual-boot but writing to the MBR isn't an option as there's a very good, open-source, linux-based media player that has it's own crazy bootloader* in there already (and I'd like to keep it).
This leaves one option: install grub to some other location.

So put grub on some external media like a USB key or a CD (using a laptop with no floppy) maybe?
- Nada, too much hassle - don't want some stupid pseudo-dongle just to boot linux... I almost ALWAYS boot linux - hassle hassle hassle.
So put grub somewhere else... like the root of a partition (as I'm not using anything un-über-grub-friendly like XFS/JFS, I can do this easily).
- Yes, this sounds lovely! Just set this said linux partition to be "checked" first by setting its boot flag! :) - except windows will reset which partition is "checked" first every time I boot it :( . How? It resets the boot flag to its own partition. >:-@
Any other places to put grub? I don't know any... you might but I'm stumped.

So this leaves... "the problem". Windows resets the boot flag. How to rectify it:
1. Stop windows from changing it in the first place - No idea how. *I'M* ignorant enough to not know if it's windows that's even doing it or my crazy media player thingy.
2. Get windows to change it back after it resets it - No idea how to do this *IN WINDOWS*. I can use linux and parted and do it in one command
Code:

parted /dev/sda set 2 boot on
On windows however, I'm stuck. parted isn't ported to windows and I don't know of any good free partition managers for windows that have a non-interactive command line interface (so they can become part of a windows startup script). I could just reset it in XP like you said saikee... but I was wondering if anyone knew of a different way that's less hassle. I don't want to have to teach someone who may use my laptop (and who may use windows for games etc.) to "go to My Computer, right-click.....". One such person, who I don't want to teach, who may use my laptop in this way is me ;)


So, anyone know how to stop windows from resetting the boot flag or of a command line interface program (that isn't interactive) for windows that can reset it?

I'm using XP pro and Debian etch/testing on a Fujitsu-Siemens Amilo M 3438G for the curious.

* It actually used grub and I can even post the menu.lst that it uses [below] but I've tried adding the boot choice it specifies to a grub *I* install to the MBR and it doesn't work. Weird that it works in the first place, reading an NTFS partition like that but then again I don't know much about bootloaders :) Still strange seeing as I thought grub needed read-access even more than LILO needs because you don't quite INSTALL it quite as HARD. Gosh, I should stop when I say I know hardly anything about what I'm talking about!

gavinbeatty 12-26-2006 06:50 PM

Oh and here's what my grub on the debian partition has in its menu.lst for windows

Code:

# This entry automatically added by the Debian installer for a non-linux OS
# on /dev/sda1
title          Microsoft Windows XP Professional
root            (hd0,0)
savedefault
makeactive
chainloader    +1

Just in case grub could do with some help! Unlikely I fear...

gavinbeatty 12-26-2006 07:04 PM

saikee:
Quote:

I believe it is a 3rd party boot loader controlling XP's boot loader and Grub in your PC.
Incorrect as far as I know. BIOS checks in this order: USB, CD, HD. Assuming no external media:

1. MBR: Media-player's bootloader*. Selects option based on what key I press to boot: "Multimedia" or "On"
Suppose I press "On"
2. Boot partition: ordinarily, that's linux, so we get grub as I've it installed there. Whenever I boot windows via this grub, boot flag is reset to windows. Windows being partition 1 and linux partition 2 may be something to do with it, I don't know.

So, yes, in a way there's a third party bootloader. BUT, pressing "On" hands it all over to the boot flag game. Windows doesn't like this game.


Out of interest, here's the menu.lst for the media player in MBR:
Code:

timeout 0
default 0
hiddenmenu

title Original
rootnoverify (hd0,0)
chainloader (hd0,0)/PROGRA~1/CYBERL~1/POWERC~1/bootsect.orig

title PCM Linux
kernel (hd0,0)/PROGRA~1/CYBERL~1/POWERC~1/bzImage root=/dev/loop0 rw video=vesabf:ywrap,mtrr vga=788 splash=silent
initrd (hd0,0)/PROGRA~1/CYBERL~1/POWERC~1/initrd.gz

And here's what linux `file` has to say about bootsect.orig
Code:

bootsect.orig: x86 boot sector; partition 1: ID=0x7, active, starthead 1, startsector 63, 20482812 sectors; partition 2: ID=0x83, starthead 254, startsector 20482875, 25382700 sectors; partition 3: ID=0x82, starthead 254, startsector 45865575, 1959930 sectors; partition 4: ID=0x5, starthead 254, startsector 47825505, 69384735 sectors, code offset 0x48
And here's what `fdisk -l` on linux gives:
Code:

Disk /dev/sda: 60.0 GB, 60011642880 bytes
255 heads, 63 sectors/track, 7296 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

  Device Boot      Start        End      Blocks  Id  System
/dev/sda1              1        1275    10241406    7  HPFS/NTFS
/dev/sda2  *        1276        2855    12691350  83  Linux
/dev/sda3            2856        2977      979965  82  Linux swap / Solaris
/dev/sda4            2978        7296    34692367+  5  Extended
/dev/sda5            2978        7296    34692336    b  W95 FAT32

And here's what `parted /dev/sda print` gives:
Code:

Disk /dev/sda: 60.0GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start  End    Size    Type      File system  Flags
 1      32.3kB  10.5GB  10.5GB  primary  ntfs
 2      10.5GB  23.5GB  13.0GB  primary  reiserfs    boot
 3      23.5GB  24.5GB  1003MB  primary  linux-swap
 4      24.5GB  60.0GB  35.5GB  extended
 5      24.5GB  60.0GB  35.5GB  logical  fat32

Information: Don't forget to update /etc/fstab, if necessary.



All times are GMT -5. The time now is 08:14 PM.