LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Password
Debian This forum is for the discussion of Debian Linux.

Notices


Reply
  Search this Thread
Old 06-12-2010, 09:15 AM   #1
Draylath
Member
 
Registered: May 2004
Location: Great Paxton
Distribution: Debian
Posts: 112

Rep: Reputation: 15
Hard Disk problems compounded by MBR


Hi sorry for the less than helpful subject but I'm very much out of my comfort zone on this one.

My set up is a dual boot with windows on an old IDE hard disk which I use primarly for gaming. It is on the slave setting with my CD drive on the master.

I have my linux hard disk, which is newer, on the first SATA port.

The MBR and the grub bootloader was set automatically on the IDE windows drive when I installed linux.

The IDE hard disk was old and has now died sadly which is irritating. I need to replace this disk but I don't know how to go about making sure I still have a dual boot system. I guess I will need to swap the bootloader over the the linux drive but I have no idea how to do this at all. I really need to make sure I can still get back into my linux system whatever happenes.

My apologies for not being able to be more clear but I'm terrified of playing with this part of the setup as I've broken perfectly good installs before with this sort of thing.

Any help would be fantastic
 
Old 06-12-2010, 09:27 AM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,103

Rep: Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117
Fixing MBRs is trivial - it's only scary because it happens to be the first thing we as users have control over in the boot sequence. It has bad consequences, but is easy to fix.

I'm going to show some ignorance here as I don't use Debian.
- which bootloader
- which version
- let's see a fstab and bootloader config file (windoze included if relevant).
 
Old 06-12-2010, 09:27 AM   #3
Mr-Bisquit
Member
 
Registered: Feb 2009
Distribution: FreeBSD, OpenBSD, NetBSD, Debian, Fedora
Posts: 770
Blog Entries: 52

Rep: Reputation: 68
You could reinstall the bootloader.
 
Old 06-12-2010, 09:47 AM   #4
hughetorrance
Member
 
Registered: Aug 2009
Location: London North West
Distribution: x86_64 Slack 13.37 current : +others
Posts: 459

Rep: Reputation: 59
Get yourself a copy of the UBCD,Google and download the free one...on the UBCD you will find many tools to help you recover a broken system including GRUB and GRUB 2 ...
Also you will find Smart boot manager which if you highlight your windoze partition then press tab you will see an option which says "BOOT IT" and Boot previous MBR... when it says save changes Y/N if you press Y it will keep the change to the MBR and if you press N it will try to boot the system but will not change anything,it will attempt to boot it even with a broken BIOS...
If you rewrite the MBR with any utility it will rewrite it for your windoze,then later you can reinstall GRUB from the disc with automatically install.

ps Parted Magic is great as well. Good luck !
 
Old 06-12-2010, 09:53 AM   #5
Draylath
Member
 
Registered: May 2004
Location: Great Paxton
Distribution: Debian
Posts: 112

Original Poster
Rep: Reputation: 15
Thanks for the replies and empathy over my fear

I'm afraid I would have no idea on how reinstall a bootloader so pointing me to a reference would be awesome as I am prepared to do some reading.

I'm assuming that debian uses the grub boot loader by default but beyond that I have no idea about versions. If you can tell me how to find out I'll let you know.

the fstab I can do:
# /etc/fstab: static file system information.
#
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc defaults 0 0
/dev/sda1 / ext3 errors=remount-ro 0 1
/dev/sda5 none swap sw 0 0
/dev/hda /media/cdrom0 udf,iso9660 user,noauto 0 0
/dev/fd0 /media/floppy0 auto rw,user,noauto 0 0
/dev/hdb1 /home/neil/C ntfs user,ro,auto,uid=neil 0 0

as for the bootloader config file I don't know where that is kept.

Please forgive my ineptitude as I am still quite a noob on most linux things
 
Old 06-12-2010, 09:58 AM   #6
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,103

Rep: Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117
Go to sf.net and get the bootinfoscript - run that and post the RESULTS.txt it generates (can be run from a liveCD/chroot in need). It will tell us all we need to know.
 
Old 06-12-2010, 10:02 AM   #7
Draylath
Member
 
Registered: May 2004
Location: Great Paxton
Distribution: Debian
Posts: 112

Original Poster
Rep: Reputation: 15
============================= Boot Info Summary: ==============================

=> Grub 0.97 is installed in the MBR of /dev/hdb and looks on boot drive #2
in partition #1 for /boot/grub/stage2 and /boot/grub/menu.lst.
=> No boot loader is installed in the MBR of /dev/sda

hdb1: _________________________________________________________________________

File system: ntfs
Boot sector type: Windows XP
Boot sector info: No errors found in the Boot Parameter Block.
Operating System: Windows XP
Boot files/dirs: /grub.cfg /boot.ini /BOOT.INI /ntldr /NTLDR
/NTDETECT.COM /ntdetect.com

sda1: _________________________________________________________________________

File system: ext3
Boot sector type: -
Boot sector info:
Operating System: Debian GNU/Linux 5.0
Boot files/dirs: /boot/grub/menu.lst /etc/fstab

sda2: _________________________________________________________________________

File system: Extended Partition
Boot sector type: -
Boot sector info:

sda5: _________________________________________________________________________

File system: swap
Boot sector type: -
Boot sector info:

=========================== Drive/Partition Info: =============================

Drive: hdb ___________________ _____________________________________________________

Disk /dev/hdb: 164.6 GB, 164696555520 bytes
255 heads, 63 sectors/track, 20023 cylinders, total 321672960 sectors
Units = sectors of 1 * 512 = 512 bytes
Disk identifier: 0xc39dc39d

Partition Boot Start End Size Id System

/dev/hdb1 * 63 321,653,429 321,653,367 7 HPFS/NTFS


Drive: sda ___________________ _____________________________________________________

Disk /dev/sda: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders, total 488397168 sectors
Units = sectors of 1 * 512 = 512 bytes
Disk identifier: 0x0003bbf5

Partition Boot Start End Size Id System

/dev/sda1 * 63 476,311,184 476,311,122 83 Linux
/dev/sda2 476,311,185 488,392,064 12,080,880 5 Extended
/dev/sda5 476,311,248 488,392,064 12,080,817 82 Linux swap / Solaris


blkid -c /dev/null: ____________________________________________________________

Device UUID TYPE LABEL

/dev/hdb1 D698CBFC98CBD95F ntfs
/dev/sda1 26d3a466-47cc-45ca-9d94-23a5b44e7c5b ext3
/dev/sda5 swap

============================ "mount | grep ^/dev output: ===========================

Device Mount_Point Type Options

/dev/sda1 / ext3 (rw,errors=remount-ro)
/dev/hdb1 /home/neil/C ntfs (ro,noexec,nosuid,nodev,uid=1000)


================================ hdb1/grub.cfg: ================================

linux /debian/linux video=vesa:ywrap,mtrr vga=788 -- quiet
initrd /debian/initrd.gz
boot

================================ hdb1/boot.ini: ================================

[boot loader]

timeout=30

default=multi(0)disk(0)rdisk(0)partition(1)\WINDOWS

[operating systems]

multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Home Edition" /fastdetect /NoExecute=OptIn

C:\g2ldr.mbr="Debian Installer"


================================ hdb1/BOOT.INI: ================================

[boot loader]

timeout=30

default=multi(0)disk(0)rdisk(0)partition(1)\WINDOWS

[operating systems]

multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Home Edition" /fastdetect /NoExecute=OptIn

C:\g2ldr.mbr="Debian Installer"


=================== hdb1: Location of files loaded by Grub: ===================


.0GB: grub.cfg

=========================== sda1/boot/grub/menu.lst: ===========================

# menu.lst - See: grub(8), info grub, update-grub(8)
# grub-install(8), grub-floppy(8),
# grub-md5-crypt, /usr/share/doc/grub
# and /usr/share/doc/grub-legacy-doc/.

## default num
# Set the default entry to the entry number NUM. Numbering starts from 0, and
# the entry number 0 is the default if the command is not used.
#
# You can specify 'saved' instead of a number. In this case, the default entry
# is the entry saved with the command 'savedefault'.
# WARNING: If you are using dmraid do not change this entry to 'saved' or your
# array will desync and will not let you boot your system.
default 0

## timeout sec
# Set a timeout, in SEC seconds, before automatically booting the default entry
# (normally the first entry defined).
timeout 5

# Pretty colours
color cyan/blue white/blue

## password ['--md5'] passwd
# If used in the first section of a menu file, disable all interactive editing
# control (menu entry editor and command-line) and entries protected by the
# command 'lock'
# e.g. password topsecret
# password --md5 $1$gLhU0/$aW78kHK1QfV3P2b2znUoe/
# password topsecret

#
# examples
#
# title Windows 95/98/NT/2000
# root (hd0,0)
# makeactive
# chainloader +1
#
# title Linux
# root (hd0,1)
# kernel /vmlinuz root=/dev/hda2 ro
#

#
# Put static boot stanzas before and/or after AUTOMAGIC KERNEL LIST

### BEGIN AUTOMAGIC KERNELS LIST
## lines between the AUTOMAGIC KERNELS LIST markers will be modified
## by the debian update-grub script except for the default options below

## DO NOT UNCOMMENT THEM, Just edit them to your needs

## ## Start Default Options ##
## default kernel options
## default kernel options for automagic boot options
## If you want special options for specific kernels use kopt_x_y_z
## where x.y.z is kernel version. Minor versions can be omitted.
## e.g. kopt=root=/dev/hda1 ro
## kopt_2_6_8=root=/dev/hdc1 ro
## kopt_2_6_8_2_686=root=/dev/hdc2 ro
# kopt=root=/dev/sda1 ro

## default grub root device
## e.g. groot=(hd0,0)
# groot=(hd1,0)

## should update-grub create alternative automagic boot options
## e.g. alternative=true
## alternative=false
# alternative=true

## should update-grub lock alternative automagic boot options
## e.g. lockalternative=true
## lockalternative=false
# lockalternative=false

## additional options to use with the default boot option, but not with the
## alternatives
## e.g. defoptions=vga=791 resume=/dev/hda5
# defoptions=quiet

## should update-grub lock old automagic boot options
## e.g. lockold=false
## lockold=true
# lockold=false

## Xen hypervisor options to use with the default Xen boot option
# xenhopt=

## Xen Linux kernel options to use with the default Xen boot option
# xenkopt=console=tty0

## altoption boot targets option
## multiple altoptions lines are allowed
## e.g. altoptions=(extra menu suffix) extra boot options
## altoptions=(single-user) single
# altoptions=(single-user mode) single

## controls how many kernels should be put into the menu.lst
## only counts the first occurence of a kernel, not the
## alternative kernel options
## e.g. howmany=all
## howmany=7
# howmany=all

## should update-grub create memtest86 boot option
## e.g. memtest86=true
## memtest86=false
# memtest86=true

## should update-grub adjust the value of the default booted system
## can be true or false
# updatedefaultentry=false

## should update-grub add savedefault to the default options
## can be true or false
# savedefault=false

## ## End Default Options ##

title Debian GNU/Linux, kernel 2.6.26-2-amd64
root (hd1,0)
kernel /boot/vmlinuz-2.6.26-2-amd64 root=/dev/sda1 ro quiet
initrd /boot/initrd.img-2.6.26-2-amd64

title Debian GNU/Linux, kernel 2.6.26-2-amd64 (single-user mode)
root (hd1,0)
kernel /boot/vmlinuz-2.6.26-2-amd64 root=/dev/sda1 ro single
initrd /boot/initrd.img-2.6.26-2-amd64

### END DEBIAN AUTOMAGIC KERNELS LIST

# This is a divider, added to separate the menu items below from the Debian
# ones.
title Other operating systems:
root


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


=============================== sda1/etc/fstab: ===============================

# /etc/fstab: static file system information.
#
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc defaults 0 0
/dev/sda1 / ext3 errors=remount-ro 0 1
/dev/sda5 none swap sw 0 0
/dev/hda /media/cdrom0 udf,iso9660 user,noauto 0 0
/dev/fd0 /media/floppy0 auto rw,user,noauto 0 0
/dev/hdb1 /home/neil/C ntfs user,ro,auto,uid=neil 0 0

=================== sda1: Location of files loaded by Grub: ===================


233.4GB: boot/grub/menu.lst
233.4GB: boot/grub/stage2
233.4GB: boot/initrd.img-2.6.26-2-amd64
233.4GB: boot/initrd.img-2.6.26-2-amd64.bak
233.4GB: boot/vmlinuz-2.6.26-2-amd64
233.4GB: initrd.img
233.4GB: vmlinuz
=======Devices which don't seem to have a corresponding hard drive==============

hda
=============================== StdErr Messages: ===============================

FIBMAP: Invalid argument
FIBMAP: Invalid argument
FIBMAP: Invalid argument
FIBMAP: Invalid argument
FIBMAP: Invalid argument
FIBMAP: Invalid argument
FIBMAP: Invalid argument
FIBMAP: Invalid argument
FIBMAP: Invalid argument
 
Old 06-12-2010, 12:07 PM   #8
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
If I understand all that correctly,
Your IDE drive is showing up in Linux as sdb and in grub as hd0
Your SATA drive is showing up in Linux as sda and in grub as hd1

The MBR of the IDE drive has grub's boot sector code set to transfer control to the rest of grub on (hd1,0).

You plan to remove the IDE drive? So the SATA drive will become hd0.

You need to put grub's boot sector code in the MBR of the sata drive and you need to deal with the fact that from grub's point of view the sata drive will change from hd1 to hd0.

I'm not sure of the details nor the simplest approach. If I were in your position, I might:

1) Edit /boot/grub/menu.lst and make a copy of each entry using hd1 giving the copy a different name and making it use hd0. Then during the transition, you will have valid entries to choose from.

For example, this is one of your entries now
Code:
title Debian GNU/Linux, kernel 2.6.26-2-amd64
root (hd1,0)
kernel /boot/vmlinuz-2.6.26-2-amd64 root=/dev/sda1 ro quiet initrd /boot/initrd.img-2.6.26-2-amd64
I would change that into two entries like this
Code:
title Debian GNU/Linux, kernel 2.6.26-2-amd64
root (hd1,0)
kernel /boot/vmlinuz-2.6.26-2-amd64 root=/dev/sda1 ro quiet initrd /boot/initrd.img-2.6.26-2-amd64

title (hd0) Debian GNU/Linux, kernel 2.6.26-2-amd64
root (hd0,0)
kernel /boot/vmlinuz-2.6.26-2-amd64 root=/dev/sda1 ro quiet initrd /boot/initrd.img-2.6.26-2-amd64
2) You need to get grub's boot code into the MBR of the SATA drive. I hope you can do that correctly while the IDE is still the boot drive (if not, I think you would need a liveCD).
At a grub prompt
Code:
root (hd1,0)
setup (hd1)
That might not stay valid after the sata becomes hd0. In that case, the only way I know to deal with it would be waiting till after the sata is hd0, then giving the same commands but for hd0 from grub on a liveCD

3) Your BIOS probably has an option to set the boot priority or sequence. After doing the above steps, try changing the BIOS to boot sata first. Now the sata drive will be hd0. If the results of the above setup command remain valid you'll get into grub and you can select starting the Linux kernel from hd0.
If you don't get to grub, you need a liveCD as described above.

If your BIOS doesn't have a boot sequence choice, you would need to disconnect the IDE drive to make the sata drive become hd0.

Last edited by johnsfine; 06-12-2010 at 12:27 PM.
 
Old 06-12-2010, 07:55 PM   #9
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,103

Rep: Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117
Debian seems to have a problem in the init scripts with mixed IDE and SATA - probably explains the (hd0) <=> /dev/hdb
(very odd to still even see /dev/hd<anything> - especially at 2.6.26)

Because of that, I'd do all changes from a liveCD - and depending on which one, you may find the disks change name (and sda above may become sdb). This can be seriously annoying - once you're on SATA only, this issue should go away.

I agree the above suggestions should work, but there is also /etc/fstab that will need adjustment - there is no real way to make that either/or; has to be right if using /dev/... notation. Grub will probe the BIOS for numbering - which is a problem if you run it (grub) from a terminal under Linux. From root run grub and post the output these generate - will make it easier to advise how to structure the commands
Code:
geometry (hd0)
geometry (hd1)
Another problem is that the OP appears to want dual boot with the new disk - to me that implies a Windoze re-install. If it were me, I'd look at doing something like the above to get the current SATA sorted, pull the connector out, plug in the second disk and install Windoze (it needs to think it's on the first/only disk).
Test it out, then connect the old SATA back up. See what boots - or possibly doesn't. Should be easily fixable if you have that liveCD handy.
 
Old 06-13-2010, 04:14 AM   #10
Draylath
Member
 
Registered: May 2004
Location: Great Paxton
Distribution: Debian
Posts: 112

Original Poster
Rep: Reputation: 15
I'm sorry I went with the advice and got the UBCD and then rather arrogantly thought I could handle it from there myself. Consequently my fears have been reaslised and nothing now will boot except for the UBCD. Mercifully I can still use it as a live CD and can see the following:

Linux is on sda1
Windoze on sda2

hd is indeed been reallocated to 0 as I have removed the old broken IDE disk.

I have tried using and figuring out the tools on the live CD but I think I have really made a mess off my MBR.
From using the live CD I have seen that my files and OS's seem to be on their correct partitions and intact. They just won't boot and instead of getting a text menue with the linux kernal and windoze xp to boot to I just get a little blinking grey cursor in the corner and then the system hangs.

Is this just cos it is looking for a boot loader that now no longer exists? Some of the MBR tools (supergrub) seem to sugest there is a bootloader in this new disk.
 
Old 06-13-2010, 04:54 AM   #11
Draylath
Member
 
Registered: May 2004
Location: Great Paxton
Distribution: Debian
Posts: 112

Original Poster
Rep: Reputation: 15
Update:

I have managed to get the linux partitions to boot (this is the first partition) but I get error message 13 when I try to boot windows.

I got this far by up dateing the menu.lst file

The output from geometry (hd0) is

drive 0x80: C/H/S = 0/255/63, The number of sectors = 488397168, /dev/sda
Partition num: 0, Filesystem type is ext2fs, partition type 0x83
Partition num: 1, Filesystem type is unknown, partition type 0x7
Partition num: 4, Filesystem type is unknown, partition type 0x82

Is this simply becuase windoze is not on the first partition of the disk? if so is it possible to work round this?

Last edited by Draylath; 06-13-2010 at 06:34 AM.
 
Old 06-14-2010, 02:55 AM   #12
Draylath
Member
 
Registered: May 2004
Location: Great Paxton
Distribution: Debian
Posts: 112

Original Poster
Rep: Reputation: 15
I've now managed to make it so windoze boots now but not linux.

I reinstalled windows to the new partition on the SATA drive which of course rode roughshode over the mbr and grub. I then reinstalled the grub using my live cd:
root (hd0,0)
setup (hd0,0)

This said that everything was done apart from: stage 1_5 (this is not fatal)

I made sure the menu.lst was what I think is right

debian *kernel* (hd0,0)

windows xp (hd0,1)

but now when I boot up I get no grub menu and the system boots straight into XP.

I bet it's something really simple I'm overlooking so any insight would be great
 
Old 06-14-2010, 05:24 AM   #13
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Quote:
Originally Posted by Draylath View Post
root (hd0,0)
setup (hd0,0)
The setup line should be
setup (hd0)
not
setup (hd0,0)

The form setup (hd0,0) is used when you want grub to start from the partition boot sector rather than from the MBR. That is appropriate when you have some other boot loader configured to offer the choice of chainloading to that copy of grub.

There are instructions for configuring the Windows boot loader so it offers a choice to chainload to grub. But I don't think you want that. So re do that setup of grub.
 
Old 06-14-2010, 09:11 AM   #14
Draylath
Member
 
Registered: May 2004
Location: Great Paxton
Distribution: Debian
Posts: 112

Original Poster
Rep: Reputation: 15
thanks for the reply

Tried the above advice and it worked!!

Many thanks to all the kind folks who helped me get this sorted out, and I've learned quite a bit about how mbr and grub works in the process (always nice to learn). You are all getting a "thanked@ from me )
 
Old 06-14-2010, 03:02 PM   #15
hughetorrance
Member
 
Registered: Aug 2009
Location: London North West
Distribution: x86_64 Slack 13.37 current : +others
Posts: 459

Rep: Reputation: 59
Draylath ... you have the same problem that most of us have,you get too involved and stressed out...but you also have the patience and persistence to see it through...well done.

Now...if you had another all singing,dancing box you could then use it while you make yourself a cup of tea and take your time and resolve the problem...I have put problems on the back burner for months while I think up possiblities that might work... LOL

Once you can see that your systems are there you can relax a bit and know that there are many ways to skin a cat...you could have booted wiondoze anytime with Smart Boot manager found on the UBCD,I suggest you do as I have done and familiarise yourself with it and the many other rescue discs around,so as when you need it you have a head start.

ps if you rewrite the MBR from say disc wizard(or any utility) it wiil make windoze bootable,I usually start by doing that,then I go about getting the rest to boot,and so far I usually always succeed... LOL thanks for the thanks.
 
  


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
SATA Hard disk(Windows) MBR corrupted by IDE hard disk(Linux) Peter_APIIT Fedora 6 07-07-2007 12:20 AM
how Recover my Hard disk Mbr & partion viji2ks Linux - Hardware 1 09-01-2006 08:25 AM
move mbr to different hard disk taiwf Linux - Hardware 4 08-11-2005 09:58 PM
how do i recover my Hard Disk and MBR? Pisces107 Linux - General 5 12-25-2003 11:12 PM
Lilo and MBR of the second hard disk petarsabev Slackware 9 09-30-2003 11:35 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian

All times are GMT -5. The time now is 11:50 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