Data recovery and disk repair questions and discussions related to old-fashioned SATA, SAS, SCSI, IDE, MFM hard drives - any type of storage device that has moving parts
Post a reply

NTFS & MBR structure question

July 24th, 2011, 21:46

Hi All,

This might be slightly OT, but I am sure someone here will be able to point me in the right direction. Lord knows I have googled and tinkered with this problem for ages.

What I want to do is have a series of images of XP machines on my linux box and be able to deploy those images from my linux box. The basic problem is deploying the image back to a target hard disk ends up with a "Error Loading Operating System" message.

My method so far is to load XP on the target computer then remove the hard disk and image it with NTFS clone. I dont want to use dd or ddrescue cause its so slow, and beside my source hard disks dont have errors.

Progress so far:

1. Install XP on a spare PC.

2. Remove hard disk and connect to my Ubuntu box.

3. Clone XP partition (sdb1) with NTFSCLONE:

Code:
sudo ntfsclone --save-image --output /home/al/XP_physical_OEM_SP2.ntfsclone /dev/sdb1


4. Erase the disk. Zero fill the sucker to make sure its blank. Now set about recreating things on the disk.

5. Create partition with fdisk: n for new primary partition. Starting at sector 63 (thats same as what is was), mark bootable and set type to 07. w to write it to disk and then run partprobe. I assume as long as there is enough space it doesnt matter if the end sector is different? (tho I have been keping it the same)

6.
Code:
sudo ms-sys -m /dev/sdb

7. Put partition data for XP back with;
Code:
sudo ntfsclone --restore-image --overwrite /dev/sdb1 /home/al/XP_physical_OEM_SP2.ntfsclone

8. Attempt to boot the disk and I get:

Error loading operating system

Right after POST finishes.

I have done some experimenting and tend to think that I am getting something wrong in either MBR or part table.

I have used dd to take the first 512b from the disk when it working, before I zero fill the drive

Code:
al@al-ubuntu:~$ file mbr1.bin
mbr1.bin: x86 boot sector, Microsoft Windows XP MBR, Serial 0x8d80fdb8; partition 1: ID=0x7, active, starthead 1, startsector 63, 39085137 sectors, code offset 0xc0

And the again took a copy of the first 512b after the ntfsclone operation:

Code:
al@al-ubuntu:~$ file mbr3.bin
mbr3.bin: x86 boot sector, Microsoft Windows XP MBR; partition 1: ID=0x7, active, starthead 1, startsector 63, 39102273 sectors, code offset 0xc0
al@al-ubuntu:~$


The only difference I can see is the 'serial number' (not sure what it is or does?) and the end sectors - which I dont think should effect the ability to boot?

I have also used sfdisk -d /dev/sdb > sdb.parttable to backup the part table and restore it with sfdisk /dev/sdb < sdb.partable. Same problem.

Even writing the part table back with the working copy from mbr1.bin and then ntfsclone the image back fails, and also it fails if I restore the part table/mbr with sfdisk /dev/sdb < sdb.partable .

I have been using ms-sys -m /dev/sdb to write the MBR back. I assume this is the only ms-sys command I need to issue?


Thanks

-Al

MBR's in hex

Code:
al@al-ubuntu:~$ hexdump -C -s 512 mbr1.bin
00000200  33 c0 8e d0 bc 00 7c fb  50 07 50 1f fc be 1b 7c  |3.....|.P.P....||
00000210  bf 1b 06 50 57 b9 e5 01  f3 a4 cb bd be 07 b1 04  |...PW...........|
00000220  38 6e 00 7c 09 75 13 83  c5 10 e2 f4 cd 18 8b f5  |8n.|.u..........|
00000230  83 c6 10 49 74 19 38 2c  74 f6 a0 b5 07 b4 07 8b  |...It.8,t.......|
00000240  f0 ac 3c 00 74 fc bb 07  00 b4 0e cd 10 eb f2 88  |..<.t...........|
00000250  4e 10 e8 46 00 73 2a fe  46 10 80 7e 04 0b 74 0b  |N..F.s*.F..~..t.|
00000260  80 7e 04 0c 74 05 a0 b6  07 75 d2 80 46 02 06 83  |.~..t....u..F...|
00000270  46 08 06 83 56 0a 00 e8  21 00 73 05 a0 b6 07 eb  |F...V...!.s.....|
00000280  bc 81 3e fe 7d 55 aa 74  0b 80 7e 10 00 74 c8 a0  |..>.}U.t..~..t..|
00000290  b7 07 eb a9 8b fc 1e 57  8b f5 cb bf 05 00 8a 56  |.......W.......V|
000002a0  00 b4 08 cd 13 72 23 8a  c1 24 3f 98 8a de 8a fc  |.....r#..$?.....|
000002b0  43 f7 e3 8b d1 86 d6 b1  06 d2 ee 42 f7 e2 39 56  |C..........B..9V|
000002c0  0a 77 23 72 05 39 46 08  73 1c b8 01 02 bb 00 7c  |.w#r.9F.s......||
000002d0  8b 4e 02 8b 56 00 cd 13  73 51 4f 74 4e 32 e4 8a  |.N..V...sQOtN2..|
000002e0  56 00 cd 13 eb e4 8a 56  00 60 bb aa 55 b4 41 cd  |V......V.`..U.A.|
000002f0  13 72 36 81 fb 55 aa 75  30 f6 c1 01 74 2b 61 60  |.r6..U.u0...t+a`|
00000300  6a 00 6a 00 ff 76 0a ff  76 08 6a 00 68 00 7c 6a  |j.j..v..v.j.h.|j|
00000310  01 6a 10 b4 42 8b f4 cd  13 61 61 73 0e 4f 74 0b  |.j..B....aas.Ot.|
00000320  32 e4 8a 56 00 cd 13 eb  d6 61 f9 c3 49 6e 76 61  |2..V.....a..Inva|
00000330  6c 69 64 20 70 61 72 74  69 74 69 6f 6e 20 74 61  |lid partition ta|
00000340  62 6c 65 00 45 72 72 6f  72 20 6c 6f 61 64 69 6e  |ble.Error loadin|
00000350  67 20 6f 70 65 72 61 74  69 6e 67 20 73 79 73 74  |g operating syst|
00000360  65 6d 00 4d 69 73 73 69  6e 67 20 6f 70 65 72 61  |em.Missing opera|
00000370  74 69 6e 67 20 73 79 73  74 65 6d 00 00 00 00 00  |ting system.....|
00000380  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000003b0  00 00 00 00 00 2c 44 63  b8 fd 80 8d 00 00 80 01  |.....,Dc........|
000003c0  01 00 07 ef ff ff 3f 00  00 00 51 64 54 02 00 00  |......?...QdT...|
000003d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000003f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
00000400
al@al-ubuntu:~$


Code:
al@al-ubuntu:~$ hexdump -C -s 512 mbr3.bin
00000200  33 c0 8e d0 bc 00 7c fb  50 07 50 1f fc be 1b 7c  |3.....|.P.P....||
00000210  bf 1b 06 50 57 b9 e5 01  f3 a4 cb bd be 07 b1 04  |...PW...........|
00000220  38 6e 00 7c 09 75 13 83  c5 10 e2 f4 cd 18 8b f5  |8n.|.u..........|
00000230  83 c6 10 49 74 19 38 2c  74 f6 a0 b5 07 b4 07 8b  |...It.8,t.......|
00000240  f0 ac 3c 00 74 fc bb 07  00 b4 0e cd 10 eb f2 88  |..<.t...........|
00000250  4e 10 e8 46 00 73 2a fe  46 10 80 7e 04 0b 74 0b  |N..F.s*.F..~..t.|
00000260  80 7e 04 0c 74 05 a0 b6  07 75 d2 80 46 02 06 83  |.~..t....u..F...|
00000270  46 08 06 83 56 0a 00 e8  21 00 73 05 a0 b6 07 eb  |F...V...!.s.....|
00000280  bc 81 3e fe 7d 55 aa 74  0b 80 7e 10 00 74 c8 a0  |..>.}U.t..~..t..|
00000290  b7 07 eb a9 8b fc 1e 57  8b f5 cb bf 05 00 8a 56  |.......W.......V|
000002a0  00 b4 08 cd 13 72 23 8a  c1 24 3f 98 8a de 8a fc  |.....r#..$?.....|
000002b0  43 f7 e3 8b d1 86 d6 b1  06 d2 ee 42 f7 e2 39 56  |C..........B..9V|
000002c0  0a 77 23 72 05 39 46 08  73 1c b8 01 02 bb 00 7c  |.w#r.9F.s......||
000002d0  8b 4e 02 8b 56 00 cd 13  73 51 4f 74 4e 32 e4 8a  |.N..V...sQOtN2..|
000002e0  56 00 cd 13 eb e4 8a 56  00 60 bb aa 55 b4 41 cd  |V......V.`..U.A.|
000002f0  13 72 36 81 fb 55 aa 75  30 f6 c1 01 74 2b 61 60  |.r6..U.u0...t+a`|
00000300  6a 00 6a 00 ff 76 0a ff  76 08 6a 00 68 00 7c 6a  |j.j..v..v.j.h.|j|
00000310  01 6a 10 b4 42 8b f4 cd  13 61 61 73 0e 4f 74 0b  |.j..B....aas.Ot.|
00000320  32 e4 8a 56 00 cd 13 eb  d6 61 f9 c3 49 6e 76 61  |2..V.....a..Inva|
00000330  6c 69 64 20 70 61 72 74  69 74 69 6f 6e 20 74 61  |lid partition ta|
00000340  62 6c 65 00 45 72 72 6f  72 20 6c 6f 61 64 69 6e  |ble.Error loadin|
00000350  67 20 6f 70 65 72 61 74  69 6e 67 20 73 79 73 74  |g operating syst|
00000360  65 6d 00 4d 69 73 73 69  6e 67 20 6f 70 65 72 61  |em.Missing opera|
00000370  74 69 6e 67 20 73 79 73  74 65 6d 00 00 00 00 00  |ting system.....|
00000380  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000003b0  00 00 00 00 00 2c 44 63  00 00 00 00 00 00 80 01  |.....,Dc........|
000003c0  20 00 07 3f e0 ff 3f 00  00 00 41 a7 54 02 00 00  | ..?..?...A.T...|
000003d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000003f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
00000400
al@al-ubuntu:~$

Re: NTFS & MBR structure question

July 25th, 2011, 1:43

After copying the partition to the target you most probably have wrong mbr info
on that hdd.

You could try following procedure to solve the problem:

boot with the xp cd and chose on the first screen the repair option to access
the command prompt.

then enter following commands:

fixmbr c:
fixboot c:
copy d:\i386\ntldr c:\
copy d:\i386\ntdetect.com c:\

where d: is for the cd drive - if it has a different drive letter you should use
the correct one.

it might even work without the last two lines.

+++

Re: NTFS & MBR structure question

July 25th, 2011, 2:12

Cheers for the tip, but the point here is to get the machine bootable without intervention XP as I want to use this machine to deploy images to other machines which have PXE booted.

It is possible under Linux to make it bootable again - just not sure where I am going wrong :-(

Re: NTFS & MBR structure question

July 28th, 2011, 21:44

try instead of using 512 for the mbr, try using 4096, that way you get 4 sectors as opposed to 1,
might work... also i think i see clonezilla copy 4 sectors in the beginning,

also download the clonezilla server edition, it might offer clues to what it does & you might be able to incorporate those ideas into your set up....

we use Clonzilla Live & Clonezilla Server Edition to Mass deploy Images (mostly to Same Size or Bigger Drives) used with WIN7 that has a more complicated Boot Sector ....that i think..

Re: NTFS & MBR structure question

July 28th, 2011, 21:51

Ok. It turned out to be a geometry problem.

Windows is really picky about this.

It isnt sufficient to specify the geometry in Sectors, you need to also modify the CHS properties.

I made a quick tutorial about it here:

http://www.youtube.com/watch?v=UDM39Vo8Z0M

-Al

Re: NTFS & MBR structure question

July 28th, 2011, 23:05

Code:
Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 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: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *          63  1953520064   976760001   83  Linux
al@al-ubuntu:~$


The key in the above code is the heads (255), sectors (63) and clyinders (121601). You must not only recreate the partition geometry but also get the disk's chs the same. All this can be done with sfdisk.

Hope this helps some people - I dont mind sharing information :-)

-Al

Re: NTFS & MBR structure question

July 29th, 2011, 0:04

Having only skimmed the post
why not use Acronis, it is a great tool, once you have creatd your initial image with Acronis and stored it on a network location simply use the bootable Acronis media on any machine and deploy your image, if deploying to different hardware you will need to use Universal restore to compensate for different hardware controlers.
great tool and will enable you to deploy a standard windows xp image to new hardware in under 10 minutes.

Re: NTFS & MBR structure question

July 29th, 2011, 0:23

crecomp wrote:Having only skimmed the post
why not use Acronis, it is a great tool, once you have creatd your initial image with Acronis and stored it on a network location simply use the bootable Acronis media on any machine and deploy your image, if deploying to different hardware you will need to use Universal restore to compensate for different hardware controlers.
great tool and will enable you to deploy a standard windows xp image to new hardware in under 10 minutes.


I could do it that way, but in my first post I mentioned that I want to make a deployment server, and PXE boot machines.

If I boot acronis and pull image from server, I bet I will run into problems with acronis not always having the network driver!

PXE boot I wont have that problem!

Re: NTFS & MBR structure question

July 29th, 2011, 0:37

To date i havent encountered any issues with any network cards, Acronis does have an ability to use a pxe server for booting, i know with the new version of Acronis when you create the bootable media you have a choice of using a windows environment if you need to add network or RAID drivers.
Post a reply