Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 12-25-2006, 03:45 PM   #1
Registered: Nov 2003
Location: Ireland
Distribution: Debian testing
Posts: 79

Rep: Reputation: 15
Booting XP resets boot flag to its partition


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

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.

Last edited by gavinbeatty; 12-25-2006 at 03:48 PM.
Old 12-25-2006, 03:54 PM   #2
Registered: Aug 2002
Posts: 16,028

Rep: Reputation: 1851Reputation: 1851Reputation: 1851Reputation: 1851Reputation: 1851Reputation: 1851Reputation: 1851Reputation: 1851Reputation: 1851Reputation: 1851Reputation: 1851
linux does not care about the boot flag. You can use windows bootloader to start linux:
Old 12-26-2006, 12:50 PM   #3
Registered: Nov 2003
Location: Ireland
Distribution: Debian testing
Posts: 79

Original Poster
Rep: Reputation: 15
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?

Last edited by gavinbeatty; 12-26-2006 at 12:51 PM.
Old 12-26-2006, 02:40 PM   #4
Senior Member
Registered: Sep 2005
Location: Newcastle upon Tyne UK
Distribution: Any free distro.
Posts: 3,398
Blog Entries: 1

Rep: Reputation: 112Reputation: 112
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)
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
sudo grub
root (hd0,j)
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.

Last edited by saikee; 12-26-2006 at 02:49 PM.
Old 12-26-2006, 06:44 PM   #5
Registered: Nov 2003
Location: Ireland
Distribution: Debian testing
Posts: 79

Original Poster
Rep: Reputation: 15
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
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!

Last edited by gavinbeatty; 12-26-2006 at 07:13 PM.
Old 12-26-2006, 06:50 PM   #6
Registered: Nov 2003
Location: Ireland
Distribution: Debian testing
Posts: 79

Original Poster
Rep: Reputation: 15
Oh and here's what my grub on the debian partition has in its menu.lst for windows

# This entry automatically added by the Debian installer for a non-linux OS
# on /dev/sda1
title           Microsoft Windows XP Professional
root            (hd0,0)
chainloader     +1
Just in case grub could do with some help! Unlikely I fear...
Old 12-26-2006, 07:04 PM   #7
Registered: Nov 2003
Location: Ireland
Distribution: Debian testing
Posts: 79

Original Poster
Rep: Reputation: 15
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:
timeout 0
default 0

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
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:
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:
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.

Last edited by gavinbeatty; 12-26-2006 at 07:07 PM.


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Creating and booting from a separate /boot partition eldiener Linux - General 5 11-12-2006 06:13 PM
PCM level resets to 0 on boot PhoenixofMT Linux - General 4 03-19-2006 10:59 AM
boot fails when booting from lvm partition jlatl69 Linux - Newbie 6 03-07-2006 06:23 AM
system clock resets self at boot pearman Linux - Newbie 8 07-21-2005 03:53 AM
When booting from a CD I can't boot from my root partition. sharpie Linux - Newbie 3 01-28-2004 05:20 PM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:18 PM.

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