LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   unable to boot XP after removing HDD containing Linux (https://www.linuxquestions.org/questions/linux-newbie-8/unable-to-boot-xp-after-removing-hdd-containing-linux-720166/)

vikas027 04-19-2009 04:18 AM

unable to boot XP after removing HDD containing Linux
 
Hi All,

I had two Hard Drives
1) 80 GB containing XP
2) 40 GB containing RHEL 5.2

My dual boot worked perfectly previously.

For some reasons, I need to remove my 40 GB HDD. Now, I just have my 80 GB XP drive.

But, I am unable to boot my XP. This has happened to me many times, but every time when I ran FIXMBR from the XP CD, it worked perfectly.

I did ran FIXMBR this time too, but it was giving my GRUB Disk error, so I ran FIXBOOT too.


I guess I messed up this time. Now, I am getting this error

Code:

Disk Error
Press any key to restart

I have checked in BIOS, the HDD is very much there.

Pls anyone can help me out.

jschiwal 04-19-2009 04:30 AM

The /boot partition in the linux drive may have a copy of the original MBR in the /boot/grub/ directory.

Boot up with a live distro and look at the disk with "fdisk -l". "fdisk -lu" may give you more accurate results. The first partition probably starts on sector 63. You won't see that without the -u option.

Check if the disk is marked active (bootable).

If the XP partition is there, can you mount it?

How are the drive jumpers set? Master/Slave/Lone Drive/Cable Select?

Run as root "file -s /dev/sda1" (or whatever device the XP partition is).
Also try "file -s /dev/sda".

Code:

/dev/sda1: Linux rev 1.0 ext3 filesystem data (needs journal recovery)
[jschiwal@hpamd64 ~]$ sudo file -s /dev/sda
/dev/sda: x86 boot sector, LInux i386 boot LOader; partition 1: ID=0x83, active, starthead 1, startsector 63, 401562 sectors; partition 2: ID=0x8e, starthead 0, startsector 401625, 194964840 sectors

Make sure the partitions aren't damaged and the contents are OK before proceding. Then backing your important files would be the next step.

---

I almost forgot. Be sure that the drive cable didn't work itself loose.

vikas027 04-19-2009 04:53 AM

Quote:

Originally Posted by jschiwal (Post 3513895)
The /boot partition in the linux drive may have a copy of the original MBR in the /boot/grub/ directory.

Boot up with a live distro and look at the disk with "fdisk -l". "fdisk -lu" may give you more accurate results. The first partition probably starts on sector 63. You won't see that without the -u option.

Check if the disk is marked active (bootable).

If the XP partition is there, can you mount it?

How are the drive jumpers set? Master/Slave/Lone Drive/Cable Select?

Run as root "file -s /dev/sda1" (or whatever device the XP partition is).
Also try "file -s /dev/sda".

Code:

/dev/sda1: Linux rev 1.0 ext3 filesystem data (needs journal recovery)
[jschiwal@hpamd64 ~]$ sudo file -s /dev/sda
/dev/sda: x86 boot sector, LInux i386 boot LOader; partition 1: ID=0x83, active, starthead 1, startsector 63, 401562 sectors; partition 2: ID=0x8e, starthead 0, startsector 401625, 194964840 sectors

Make sure the partitions aren't damaged and the contents are OK before proceding. Then backing your important files would be the next step.

---

I almost forgot. Be sure that the drive cable didn't work itself loose.


Thanks for the response.

I have checked all the connections (cables etc). All are well. I dont have have that Linux 80GB HDD now.

Also, my win XP C: Drive is NTFS, I dont think that will mount using Live Distro (like knoppix etc)

I dont have much important files on it, the only thing is I have so many applications installed into XP. Installing all of them again, will be a great pain :(

Is there any other way than to re-install XP ??

jschiwal 04-19-2009 05:23 AM

You may need to run "modprobe ntfs" before being able to read an ntfs partition. If there is a fuse module, and the ntfs-3g package is installed, then you can not only mount an ntfs partiton, but also write to it.

mount -t ntfs /dev/sda1 /mnt -o ro,fmask=0111,dmask=0000

---

lsmod | grep fuse
# if you don't see the fuse module run `modprobe fuse'
mount -t ntfs-3g /dev/sda1 /mnt -o ro, fmask=0111,dmask=0000


Suppose that you find out that the partition table is damaged. If the filesystem itself isn't damaged, you may still be able to mount it. I'd recommend mounting it and checking it out before attempting to fix the partition table.

example:
Here I ssh'ed into my desktop; attached a loop device; and mounted the loop device. I didn't wack my partition table for this example. If it were, however, I would guess that the first partition starts at sector 63.
Code:

fdisk -lu /dev/sdb

Disk /dev/sdb: 203.9 GB, 203928109056 bytes
255 heads, 63 sectors/track, 24792 cylinders, total 398297088 sectors
Units = sectors of 1 * 512 = 512 bytes
Disk identifier: 0x27347fb3

  Device Boot      Start        End      Blocks  Id  System
/dev/sdb1              63      144584      72261  83  Linux
/dev/sdb2          144585    10635029    5245222+  82  Linux swap / Solaris
...
hpmedia:~ # losetup -fs /dev/sdb -o $((63*512))
/dev/loop0
hpmedia:~ # mount -t ext3 /dev/loop0 /mnt/sdb1
hpmedia:~ # file -s /dev/sdb1
/dev/sdb1: Linux rev 1.0 ext3 filesystem data (needs journal recovery)
hpmedia:~ # file -s /dev/loop0
/dev/loop0: Linux rev 1.0 ext3 filesystem data (needs journal recovery)

Notice that I used the device for the entire disk on the losetup command.
If I had needed to recover the location of other partitions, I could use "df" to locate the top of the first one, and try to repeat the process. Keeping track of the start of each partition, it is possible to reconstruct what the partition table should be.

Code:

df --block-size=512 /mnt/sdb1
Filesystem        512B-blocks      Used Available Use% Mounted on
/dev/loop0              139944    87686    45032  67% /mnt/sdb1

Imagine that the problem is that the first 20 sectors are damaged and can't be repaired. If sectors 63 on up are OK, you could use dd to copy the rest of the drive to a new one, and use this technique to recover.

If the MBR were zeroed out, you would probably see a "no operating system" message instead of disk error. That has me concerned that the problem my be more serious. At least knowing whether you can access the disk using a live distro or rescue disk would provide usefull information.

shpenat 04-19-2009 05:47 AM

Sorry, but I am not sure how to help you. Fixmbr fixes Master Boot Record, where GRUB usually reside so it should worked. But in fixmbr info page is mentioned, that is may damage filesystem on that particular disk making it unreadable. But I dont thing that is what happened. Fixboot fixes boot sector on specified partition. There in case of dualboot XP loader is stored, so it should have no effect.

But I will try to give you hints what happened and how to prevent it from happening again. GRUB is too large to squeeze itself to MBR. So it keeps some part of itself on linux drive. Usually in /boot/grub/stage2. Removing Linux drive mean removing this part hence making GRUB unusable.

You seems to do it quite often. So instead of using GRUB as you primary boot loader, use XP bootloader. Go check http://sourceforge.net/projects/grub4dos Dont be confused by the name. Grub4dos is what you want, not wingrub (which is just windows graphical frontend). If you read documentation you will find (in part UPDATE 1) that starting GRUB from XP boot loader is as simple as copying grldr to c:, modifying boot.ini and creating menu.lst (or using menu.lst from your Linux).

It will not solve your current problem since it requires working windows booting.

Edit: Ummm, sorry I missed that you are Linux admin. I wrote it as for newbie :)

shpenat 04-19-2009 05:55 AM

Sorry, but I am not sure how to help you. Fixmbr fixes Master Boot Record, where GRUB usually reside so it should worked. But in fixmbr info page is mentioned, that is may damage filesystem on that particular disk making it unreadable. But I dont thing that is what happened. Fixboot fixes boot sector on specified partition. There in case of dualboot XP loader is stored, so it should have no effect.

But I will try to give you hints what happened and how to prevent it from happening again. GRUB is too large to squeeze itself to MBR. So it keeps some part of itself on linux drive. Usually in /boot/grub/stage2. Removing Linux drive mean removing this part hence making GRUB unusable.

You seems to do it quite often. So instead of using GRUB as you primary boot loader, use XP bootloader. Go check http://sourceforge.net/projects/grub4dos Dont be confused by the name. Grub4dos is what you want, not wingrub (which is just windows graphical frontend). If you read documentation you will find (in part UPDATE 1) that starting GRUB from XP boot loader is as simple as copying grldr to c:, modifying boot.ini and creating menu.lst (or using menu.lst from your Linux).

It will not solve your current problem since it requires working windows booting.

malekmustaq 04-19-2009 06:30 AM

vikas027:

Following are my comments/suggestions to your last post:

======
Q--"I had two Hard Drives
1) 80 GB containing XP
2) 40 GB containing RHEL 5.2
.......

"Thanks for the response.

I have checked all the connections (cables etc). All are well. I dont have have that Linux 80GB HDD now.---"

Comment:

You mean the 40GB containing RHEL?

If your 40GB HD containing RHEL is no longer there then you have to approach the problem OUTSIDE Grub and outside Linux since the files of these system are gone with it. Your approach should be solely based on XP rescue tactics with only the 80GB running. AFAIU from your words only the HDD containing Xp is connected now and its MBR is not well.

======

Q---"Also, my win XP C: Drive is NTFS, I dont think that will mount using Live Distro (like knoppix etc)"--

Comment:

A Gnu/Linux live can mount an NTFS. This is a matter of fact not a speculation.

======

Q---"I dont have much important files on it, the only thing is I have so many applications installed into XP. Installing all of them again, will be a great pain

Is there any other way than to re-install XP ??"---

Comment:

Yes there is of course. Are you using a Retail Installer for your XP? If yes then try do this: <Note: installers given free by manufacturers do not have this feature>

Boot the Xp installer, after it loads hdwe drivers a prompt for choices comes: click "r" for Repair then enter into the rescue Console. There type help, a list of master boot record commands shall be listed aside from the common "fixmbr", use them according to your taste. This console saved me from trouble many times before during my windows days.

Another way is again to boot the installer, choose "r" for repair, then choose "Install" in this method Xp will do two things: a) fix your mbr; b) install fresh copies of system files but keeping the same registry with your applications untouched.

Last means, reattach your 40GB containing previous RHEL, try boot from it <if it doesn't boot you can boot by means of the Linux live cd, having in mind> to recover the original mbr kept by RHEL under /boot/grub folder, using 'dd' command in the terminal flash the old --pre RHEL-- mbr into the first sector of the 80GB HDD, this way your old Xp should boot again as it was before Linux. This method presumes that you have the two HDD's 40GB and 80GB mounted again.

I hope this helps.

onebuck 04-19-2009 08:26 AM

Hi,

How is the current single drive configured? MASTER, Slave, Single or Cable Select? Some manufactures require that you remove or store the jumper when a Single drive is installed? Do you have the drive at the end of the cable?

What happens when you boot a LiveCD or install CD? Is the drive shown by a 'fdisk -l'?

vikas027 04-19-2009 09:56 AM

I have got my 40GB HDD Linux drive back for obvious reasons. Linux GRUB was not coming initially, thus I ran grub-install /dev/hdd. Now, I have Linux running without a problem.

40GB HDD is master the one with Linux.
and 80GB HDD is slave. They are on the the same data cable attached from motherboard.



Quote:

Boot up with a live distro and look at the disk with "fdisk -l". "fdisk -lu" may give you more accurate results. The first partition probably starts on sector 63. You won't see that without the -u option.

Check if the disk is marked active (bootable).
fdisk -lu output may help further
Code:

Disk /dev/hdc: 40.0 GB, 40060403712 bytes
255 heads, 63 sectors/track, 4870 cylinders, total 78242976 sectors
Units = sectors of 1 * 512 = 512 bytes

  Device Boot      Start        End      Blocks  Id  System
/dev/hdc1  *          63    14329979    7164958+  83  Linux
/dev/hdc2        14329980    30716279    8193150  83  Linux
/dev/hdc3        30716280    34909244    2096482+  82  Linux swap / Solaris
/dev/hdc4        34909245    78236549    21663652+  5  Extended
/dev/hdc5        34909308    35118089      104391  83  Linux
/dev/hdc6        35118153    54669194    9775521  83  Linux

Disk /dev/hdd: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders, total 156301488 sectors
Units = sectors of 1 * 512 = 512 bytes

  Device Boot      Start        End      Blocks  Id  System
/dev/hdd1  *          63    25173854    12586896    c  W95 FAT32 (LBA)
/dev/hdd2        25173855  112326479    43576312+  f  W95 Ext'd (LBA)
/dev/hdd3      112326480  156296384    21984952+  c  W95 FAT32 (LBA)
/dev/hdd5        25173918  112326479    43576281    b  W95 FAT32





Quote:

If the XP partition is there, can you mount it?
Yes, I have mounted it and can access all files.




file -s /dev/hdd1 output
Code:

[root@station1 ~]# file -s /dev/hdd1
/dev/hdd1: x86 boot sector, Microsoft Windows XP Bootloader NTLDR, code offset 0x58, OEM-ID "MSWIN4.1", sectors/cluster 16, Media descriptor 0xf8, heads 255, hidden sectors 63, sectors 25173792 (volumes > 32 MB) , physical drive 0xf8, physical drive 0x78, reserved 0x2f, dos < 4.0 BootSector (0x0)






GRUB.CONF
Code:

# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You do not have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /, eg.
#          root (hd1,0)
#          kernel /boot/vmlinuz-version ro root=/dev/hdc1
#          initrd /boot/initrd-version.img
#boot=/dev/hdd
default=1
timeout=27
splashimage=(hd1,0)/boot/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux Server (2.6.18-92.el5)
        root (hd1,0)
        kernel /boot/vmlinuz-2.6.18-92.el5 ro root=LABEL=/ rhgb quiet
        initrd /boot/initrd-2.6.18-92.el5.img
title Other
        rootnoverify (hd0,0)
        chainloader +1




XP boot.ini output
Code:

[boot loader]
timeout=1
default=multi(0)disk(0)rdisk(0)partition(1)\WINDOWS
[operating systems]
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Professional" /noexecute=optin /fastdetect





Thanks, for the response people. I owe you all. Really, I am feeling lucky to have so many helping hands for me. I respect this forum.

vikas027 04-19-2009 10:14 AM

Hey people,

Just to add some more info.

Now, when I am trying to boot with other option (i.e. win XP) in the GRUB, I am getting a GRUB prompt.


All times are GMT -5. The time now is 02:53 PM.