Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

One of the methods to do dual booting Windows with Linux OS is by installing grub boot loader onto Linux partition so you can retain Windows boot loader and let Windows handles the dual booting process.

What's the odd that grub bootloader could partially overwrite the data at the beginning of the Linux partition and corrupt the file? Does grub actually check if there's a data at the beginning of the partition and move it to other location on the partition before writing its bootloader?

share|improve this question
    
what filesystem? You need to check your particular partition/fs yourself before installing. If you're using ext# filesystem you should be safe in the default case. –  akostadinov Jun 29 '12 at 9:42
    
I'm using ext4 for the Linux partition. Care to explain why it's safe in ext# case? –  Flint Jun 29 '12 at 10:11

3 Answers 3

GRUB does not install its files in a partition willy-nilly, it uses the file system drivers and thus will never overwrite existing files. However, current GRUB documentation discourages the practice of installing to a Linux filesystem and deems that method "fragile". Whether it is any more fragile than installing to the no-man's-land between the MBR and the beginning of the first partition is open to debate. It is well known that several programs write data that area, and currently the GRUB developers are forced to include ad-hoc workarounds in GRUB code whenever a new such program is discovered. The basic problem seems to be that ext* filesystems do not provide for a fixed location for boot code (other than the filesystem boot block, which is inadequate) and thus GRUB uses a simple block list, but cannot ensure that those blocks will remain unchanged. This is in contrast to, say, NTFS filesystems, whose bootcode is accessed via fixed-location pointers and files.

share|improve this answer
    
There was some patch for grub using a file name instead of block list but I can't find it at the moment. Anyways I'm using grub for many years but have not ever had a problem with that. I think it is pretty unlikely to be a problem if you don't do stuff you are not anticipated to do and should not do if you don't know what you are doing.. –  akostadinov Jul 3 '12 at 4:59

Windows (Vista, 7 & 8, anyway) usually tries to make a separate partition for booting. And when it does, it's almost always invisible to normal Windows stuff like the file manager.

Typically, this Windows boot partition is 100MEG, has a volume name called "System Reserved" and is NOT given a drive letter. Of course, you can still install Windows into one partition and not go this route, but you do have to go out of your way when installing Windows to do it.

So take another look at your drive partitioning using something like diskmgmt.msc (type that into your Windows start orb search pane to use the utility) to see if you don't have the 100Meg "System Reserved" partition. It's a little pointless but I just want to show that you probably have 2 partitions with Windows - not one.

Either way, we're really talking about a boot manager here. And if Grub does make a mistake then about all that will happen is that you might not be able to boot to Windows. But all your stuff should still be safe - and even accessible. It's still quite repairable but obviously a bit of a PITA too. (About the only "easy" way I've found to fix this sort of problem is to format the boot partition or intentionally screw up the boot flag or something like that and then let the Windows system recovery on DVD fix it).

So the short answer that Grub will overwrite stuff is not really possible or even an issue. Of course, if you have a failing hard drive where the SMART flag has been tripped or even if the data is seriously fragmented then that's another matter. Just don't go making it worse by adjusting partitions or especially formatting them.

And speaking of which... I hope you are defragmenting your Windows partition(s) under it's own power before using a Linux tool like GParted. Not defragging before shrinking a partition or adjusting it in any way is likely going to introduce a whole new set of problems. (So you can't say I didn't warn you.)

share|improve this answer
    
how is this answer relevant at all? –  akostadinov Jul 3 '12 at 4:52

Based on your input that you are using ext4, grub should not destroy your filesystem. ext2 begins with space for a boot sector: http://www.makelinux.net/books/ulk3/understandlk-CHP-18-SECT-2

share|improve this answer
    
Note that when you install grub this way, it has to embed the sectors containing /boot/grub/core.img in the boot sector, and this configuration is prone to breakage, which is why grub complains loudly and makes you use the --force switch. –  psusi Jul 2 '12 at 2:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.