PDA

View Full Version : Windws XP win't boot with GRUB



Night Gyr
20th April 2011, 11:42 AM
Hello all!

Some time ago I migrated from one hard drive to another one. The old hard drive contained Windows XP and two Linux partitions, a GRUB 2GB partition and an LVM Fedora partition. To migrate, I first partitioned the new drive by hand amd then performed a simple dd copy partition-wise, IIRC. (Well, that was like a few months ago :)) Here is the corresponding new fdisk -l:

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x69205244

Device Boot Start End Blocks Id System
/dev/sda1 2048 195311615 97654784 7 HPFS/NTFS
/dev/sda2 195311616 199219199 1953792 83 Linux
/dev/sda3 199219200 976773119 388776960 8e Linux LVM

Now in GRUB, I have this:

rootnoverify (hd0,0)
chainloader +1

And XP wn't boot. All I get is a flashing cursor in the upper left corner and that's it. The same partitioning scheme with the same GRUB line used to boot fine on the old hard drive. What could be the deal?

stoat
21st April 2011, 01:48 AM
I think I would try repairing the Windows boot loader. Even though that will bust GRUB, it will be easy enough to restore afterwards with your Fedora disk. I think first I would use fdisk in Fedora to set the boot flag for /dev/sda1. Then boot with the Windows disk and enter its Recovery Environment (http://support.microsoft.com/kb/927392) to run Bootrec.exe /FixMbr and Bootrec.exe /FixBoot. Reboot and see if Windows 7 can boot again directly from BIOS.

If it does, then re-install GRUB in the master boot record and try booting it again from GRUB.

If it does not boot, then re-install GRUB in the master boot record, boot Fedora, and look at the boot sector of /dev/sda1. All NTFS boot sectors look basically the same when the binary code is viewed with a hexeditor, but some execute ntldr and some execute bootmgr depending on what formatted the partition. The boot sector is binary code, of course, but the the ASCII error messages will be helpful in that regard. If you copied the entire old partition with dd, then it should have copied the original boot sector to the new boot sector, but I would look anyway.
su
hexdump -Cvn 512 /dev/sda1If that looks normal, then try mounting the Windows partition and look for the usual Windows 7 boot loader files and the /Boot folder in its root directory. If that stuff also looks normal, then I think I am out of ideas.

P.S. and sort of a warning: It's possible that FixBoot will do no good or even make things worse. Bootrec.exe /FixBoot (and the earlier fixboot command) uses the backup copy of the boot sector that exists in the very last sector of all NTFS partitions. Since you used dd to copy the Windows 7 partition, if the new partition was not the exact same size to the sector as the original, then the Bootrec utility may use the new partition's backup boot sector and not find the original's. If the new partition was not formatted by Vista or Windows 7, then its boot code may search for and execute ntldr instead of bootmgr. Situation worse.

Night Gyr
21st April 2011, 11:31 AM
Thanks for your advice!

I'd just mention that it's XP, not 7 or Vista :) But they should be similar in that regard, I guess.

Now I've already tried fixboot and even Windows XP install (without formatting the NTFS partition). It still remains the same - blinking cursor.

BUT here's another idea:
What if I screwed something up during dd? I mean, something got in the wrong place, didn't copy at all or maybe I misaligned something(???) I could however try to dd old Windows to this new hard drive again as a last resort, there must be an IDE connector in one of the machines I've got. (that was an IDE drive, BTW, could that matter?)

--Night Gyr

stoat
21st April 2011, 01:42 PM
I'd just mention that it's XP, not 7 or Vista But they should be similar in that regard, I guess.Okay. The ideas would have been the same except XP calls its rescue mode on the disk "Recovery Console" and uses the commands fixmbr and fixboot. And the boot loader files in the root directory are ntldr, ntdetect.com, and boot.ini.




What if I screwed something up during dd? I mean, something got in the wrong place, didn't copy at all or maybe I misaligned something(???)I guess. It's not hard to botch a dd command. dd is wonderful and all that, but it's not my favorite utility for moving or cloning partitions. Try something besides dd to copy the XP partition. I prefer Acronis TrueImage for backing up and cloning NTFS partitions. I bought it, so I use it. I've cloned, moved, or restored entire XP systems with it many times. There are plenty of other imaging apps out there, free and otherwise.

P.S.: Even the partition manager gparted will copy an entire partition and paste it into free space.

Night Gyr
21st April 2011, 06:13 PM
Could you suggest some method to find the offset of the NT loader on the sda1 (NTFS) partition? After having searched for some time I've come to the conclusion that the loader offset specified in the chainloader GRUB command is not correct. What tool or method do you think could be suitable for this?

stoat
21st April 2011, 09:04 PM
The boot code of an NTFS partition starts with the very first byte of the very first sector. It's usually a jump instruction to another offset in the sector, but it starts at the beginning. Did you look at the boot sector with hexdump yet? NTFS partition boot sectors are all very similar. If the thing is there at all, then I would expect it to be okay and do its job which is merely to find and execute ntldr. Here is my XP partition's boot sector just for example...
# hexdump -Cvn 512 /dev/sda1
00000000 eb 52 90 4e 54 46 53 20 20 20 20 00 02 08 00 00 |.R.NTFS .....|
00000010 00 00 00 00 00 f8 00 00 3f 00 ff 00 3f 00 00 00 |........?...?...|
00000020 00 00 00 00 80 00 80 00 f0 60 62 02 00 00 00 00 |.........`b.....|
00000030 28 9e 09 00 00 00 00 00 2a bb 09 00 00 00 00 00 |(.......*.......|
00000040 f6 00 00 00 01 00 00 00 16 9c 8a 00 a7 8a 00 48 |...............H|
00000050 00 00 00 00 fa 33 c0 8e d0 bc 00 7c fb b8 c0 07 |.....3.....|....|
00000060 8e d8 e8 16 00 b8 00 0d 8e c0 33 db c6 06 0e 00 |..........3.....|
00000070 10 e8 53 00 68 00 0d 68 6a 02 cb 8a 16 24 00 b4 |..S.h..hj....$..|
00000080 08 cd 13 73 05 b9 ff ff 8a f1 66 0f b6 c6 40 66 |...s......f...@f|
00000090 0f b6 d1 80 e2 3f f7 e2 86 cd c0 ed 06 41 66 0f |.....?.......Af.|
000000a0 b7 c9 66 f7 e1 66 a3 20 00 c3 b4 41 bb aa 55 8a |..f..f. ...A..U.|
000000b0 16 24 00 cd 13 72 0f 81 fb 55 aa 75 09 f6 c1 01 |.$...r...U.u....|
000000c0 74 04 fe 06 14 00 c3 66 60 1e 06 66 a1 10 00 66 |t......f`..f...f|
000000d0 03 06 1c 00 66 3b 06 20 00 0f 82 3a 00 1e 66 6a |....f;. ...:..fj|
000000e0 00 66 50 06 53 66 68 10 00 01 00 80 3e 14 00 00 |.fP.Sfh.....>...|
000000f0 0f 85 0c 00 e8 b3 ff 80 3e 14 00 00 0f 84 61 00 |........>.....a.|
00000100 b4 42 8a 16 24 00 16 1f 8b f4 cd 13 66 58 5b 07 |.B..$.......fX[.|
00000110 66 58 66 58 1f eb 2d 66 33 d2 66 0f b7 0e 18 00 |fXfX..-f3.f.....|
00000120 66 f7 f1 fe c2 8a ca 66 8b d0 66 c1 ea 10 f7 36 |f......f..f....6|
00000130 1a 00 86 d6 8a 16 24 00 8a e8 c0 e4 06 0a cc b8 |......$.........|
00000140 01 02 cd 13 0f 82 19 00 8c c0 05 20 00 8e c0 66 |........... ...f|
00000150 ff 06 10 00 ff 0e 0e 00 0f 85 6f ff 07 1f 66 61 |..........o...fa|
00000160 c3 a0 f8 01 e8 09 00 a0 fb 01 e8 03 00 fb eb fe |................|
00000170 b4 01 8b f0 ac 3c 00 74 09 b4 0e bb 07 00 cd 10 |.....<.t........|
00000180 eb f2 c3 0d 0a 41 20 64 69 73 6b 20 72 65 61 64 |.....A disk read|
00000190 20 65 72 72 6f 72 20 6f 63 63 75 72 72 65 64 00 | error occurred.|
000001a0 0d 0a 4e 54 4c 44 52 20 69 73 20 6d 69 73 73 69 |..NTLDR is missi|
000001b0 6e 67 00 0d 0a 4e 54 4c 44 52 20 69 73 20 63 6f |ng...NTLDR is co|
000001c0 6d 70 72 65 73 73 65 64 00 0d 0a 50 72 65 73 73 |mpressed...Press|
000001d0 20 43 74 72 6c 2b 41 6c 74 2b 44 65 6c 20 74 6f | Ctrl+Alt+Del to|
000001e0 20 72 65 73 74 61 72 74 0d 0a 00 00 00 00 00 00 | restart........|
000001f0 00 00 00 00 00 00 00 00 83 a0 b3 c9 00 00 55 aa |..............U.|The first two bytes are the jump instruction (EB 52), followed by a NOP instruction (90), followed by the ASCII characters "NTFS", followed by four blank spaces (20). Offsets 0x48 to 0x4F are the UUID digits and should show up in your blkid output for it (read them backwards compared to how blkid prints it). Later on, the ASCII error messages are obvious. Then finally the signature ID is the final two bytes (55 AA). If you see those things in your first sector, then the thing is probably okay. Fixboot probably wouldn't help and isn't really needed. Something else is wrong IMO.

How does the partition show up in fdisk? See if you can mount it and explore the filesystem, especially the root directory for boot loader files.

Night Gyr
22nd April 2011, 02:42 PM
You won't believe it, but it looks exactly like that. So that's fine. One possible error less.

fdsik -l /dev/sda1 shows this:

Disk /dev/sda1: 100.0 GB, 99998498816 bytes
255 heads, 63 sectors/track, 12157 cylinders, total 195309568 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x69205244

This doesn't look like a partition table
Probably you selected the wrong device.

Device Boot Start End Blocks Id System
/dev/sda1p1 ? 218129509 1920119918 850995205 72 Unknown
/dev/sda1p2 ? 729050177 1273024900 271987362 74 Unknown
/dev/sda1p3 ? 168653938 168653938 0 65 Novell Netware 386
/dev/sda1p4 2692939776 2692991410 25817+ 0 Empty

Partition table entries are not in disk order

The system mounts just fine, nothing wrong here.

rusmus
23rd April 2011, 10:34 AM
For what it's worth, your results are pretty compatible with what i get when trying to fdisk -l my windows partition:


[rusmus@rusmus-pc ~]$ sudo fdisk -l /dev/sda

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x04890d0e

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 83 Linux
/dev/sda2 1026048 308021247 153497600 5 Extended
/dev/sda3 308021248 308226047 102400 7 HPFS/NTFS
/dev/sda4 308226048 976771071 334272512 7 HPFS/NTFS
/dev/sda5 1028096 308021247 153496576 8e Linux LVM
[rusmus@rusmus-pc ~]$ sudo fdisk -l /dev/sda4

Disk /dev/sda4: 342.3 GB, 342295052288 bytes
255 heads, 63 sectors/track, 41615 cylinders, total 668545024 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x6e697373

This doesn't look like a partition table
Probably you selected the wrong device.

Device Boot Start End Blocks Id System
/dev/sda4p1 ? 1936269394 3772285809 918008208 4f QNX4.x 3rd part
/dev/sda4p2 ? 1917848077 2462285169 272218546+ 73 Unknown
/dev/sda4p3 ? 1818575915 2362751050 272087568 2b Unknown
/dev/sda4p4 ? 2844524554 2844579527 27487 61 SpeedStor

Partition table entries are not in disk order


But you don't seem to have a partition marked as boot? I've experienced dual-booting problems with windows before, based on what windows considers an 'active' partition. Maybe try marking /boot as the boot partition (seems like a good idea regardless of windows trouble...).

Did you run grub setup to install it properly on the MBR?

JEO
23rd April 2011, 11:22 AM
I would try running a chkdsk on your ntfs volume from the windows recovery console.

One bad thing about using dd to clone partitions is it clones things that you really don't want to clone, such as volume serial numbers, UUIDs, and volume labels. Most operating systems produce undefined behavior if they see two partitions with the same info. Usually whichever is the first cloned partition it sees the o/s will latch onto and the other partition will be inivisible/ignored.