Hi,
On 25 Jun 2007, at 05:29, K T Ligesh wrote:
> OK. I have finally isolated all my windows woes into a simple
> reproducable and seemingly weird problem. I have an LV image of
> 1.7GB of windows that boots perfectly.
>
> ---------------------
> $ fdisk -ul /dev/VolGroup00/
> windows_rootimg
> ~[8]
>
> Disk /dev/VolGroup00/windows_rootimg: 1811 MB, 1811939328 bytes
> 46 heads, 45 sectors/track, 1709 cylinders, total 3538944 sectors
> Units = sectors of 1 * 512 = 512 bytes
>
> Device Boot Start End
> Blocks Id System
> /dev/VolGroup00/windows_rootimg1 * 63 3538943
> 1769440+ 7 HPFS/NTFS
> -------------------------
>
> The above boots perfectly.
>
> Now I merely do lvextend /dev/VolGroup00/windows_rootimg -L+1.5G
>
> And that's it, the boot hangs at the very beginning itself; It
> stops after printing the message "booting from harddisk". The fdisk
> for the extended image is:
>
> ---------------------
> $ fdisk -ul /dev/VolGroup00/
> windows_rootimg
> ~[8]
>
> Disk /dev/VolGroup00/windows_rootimg: 3422 MB, 3422552064 bytes
> 46 heads, 45 sectors/track, 3229 cylinders, total 6684672 sectors
> Units = sectors of 1 * 512 = 512 bytes
>
> Device Boot Start End
> Blocks Id System
> /dev/VolGroup00/windows_rootimg1 * 63 3538943
> 1769440+ 7 HPFS/NTFS
> --------------------
>
> Why would merely extending the partition prevent it from booting,
> and how do I overcome this?
Well you are not extending the partition, you are effectively
replacing the hard disk with a bigger one as far as Windows is
concerned. That almost certainly means that the CHS values change
thus the values in the NTFS boot sector are no longer valid and this
Windows fails to boot.
To confirm this is the case, simply install Windows from a CD or
whatever on the bigger disk, then once you have done that compare the
boot sectors from the smaller disk and the bigger disk.
The fields of interest are the "sectors_per_track" and "heads". They
are both 16-bit fields (little endian) and to be found at offset 0xd
and 0xf in the bios parameter block (bpb) respectively. Adding the
bpb offset inside the boot sector which is 0xb gives an absolute
offset of:
sectors_per_track: 0x18 (or 24 in decimal)
heads: 0x1a (or 26 in decimal)
Those offset are from the start of the partition thus you need to
figure out the start from the disk by looking at the fdisk -ul output
which shows a starting sector of 63, i.e. 63*512=32256 bytes thus the
absolute offsets from the beginning of the disk are:
sectors_per_track: 0x7e18 (or 32280 in decimal)
heads: 0x7e1a (or 32282 in decimal)
Easiest way to do this is to take a copy of the values before
reinstalling windows like so:
dd if=/dev/VolGroup00/windows_rootimg of=~/old-sectors_per_track.dat
bs=1 count=2 skip=32280
dd if=/dev/VolGroup00/windows_rootimg of=~/old-heads.dat bs=1 count=2
skip=32282
Then reinstall windows and issue:
dd if=/dev/VolGroup00/windows_rootimg of=~/new-sectors_per_track.dat
bs=1 count=2 skip=32280
dd if=/dev/VolGroup00/windows_rootimg of=~/new-heads.dat bs=1 count=2
skip=32282
Now use hexdump:
hexdump -C ~/old-sectors_per_track.dat
hexdump -C ~/new-sectors_per_track.dat
hexdump -C ~/old-heads.dat
hexdump -C ~/new-heads.dat
For example on my real NTFS partition I see:
$ hexdump -C ~/old-sectors-per_track.dat
00000000 3f 00 |?.|
00000002
The interesting two bytes are the "3f 00" which means that the
sectors per track value is 0x003f = 0x3f = 63 sectors per track and
for the heads I see:
$ hexdump -C ~/old-heads.dat
00000000 ff 00 |..|
00000002
Again the insteresting two bytes are the "ff 00" which means the
heads value is 0x00ff = 0xff = 255 heads.
I am almost certain you will see different values between old and
new, i.e. Windows sees the disk as a completely different geometry
thus unless you can work out how Windows determines the geometry you
are screwed. Alternatively you need to figure out how your
virtualization software determines the geometry and then tells it to
Windows via the virtual BIOS. I am not sure how the geometry is
obtained so can't tell you which of the two is doing it...
Good luck! If you figure something out please let us know. A lot of
people are in the position that you are in and really would like to
know how to determine the geometry. Heck if we knew how to do it
accurately we could put it into ntfsclone or create a new utility to
fix bootability...
Best regards,
Anton
--
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @)
Unix Support, Computing Service, University of Cambridge, CB2 3QH, UK
Linux NTFS maintainer, http://www.linux-ntfs.org/
|