1 |
it is possible with fdisk, i did it and it worked, and this is steps i |
2 |
followed, step 7 wasnt necesary for me: |
3 |
|
4 |
Fix for the XP dual boot problem |
5 |
|
6 |
* From: Radu Cornea <ccradu yahoo com> |
7 |
* To: For testers of Fedora Core development releases <fedora-test-list |
8 |
redhat com> |
9 |
* Subject: Fix for the XP dual boot problem |
10 |
* Date: Tue, 18 May 2004 22:37:57 -0700 (PDT) |
11 |
|
12 |
Like other people on this list I was affected by the bug which makes the |
13 |
XP partition in a dual boot configuration inaccessible after installing |
14 |
Fedora. Below are the steps I used to restore the partition table to its |
15 |
original configuration. |
16 |
|
17 |
Some people mentioned a fix that involved setting the hard disk |
18 |
configuration to LBA in the BIOS, but that may not work in some cases (I |
19 |
have an old IBM Thinkpad which does not allow it). |
20 |
|
21 |
By looking at the partition information as printed by fdisk after the |
22 |
partition is corrupted, it seems that the bug affects only the C/H/S |
23 |
values, the LBA are still correct. Even the fdisk manual specifies that |
24 |
"DOS uses C/H/S only, Windows uses both [C/H/S and LBA], Linux never uses |
25 |
C/H/S". This means that the correct information is still there but just |
26 |
one copy is correct, the LBA one (most people affected said they could |
27 |
access the Windows partition from Linux just fine). The procedure below |
28 |
attempts to regenerate the MBR from scratch using the LBA values. In most |
29 |
cases the original disk geometry had 255 (or 240) as number of heads |
30 |
initially and was changed to 16 after the partition was corrupted by FC2. |
31 |
|
32 |
More info about the bug can be found here: |
33 |
https://bugzilla.redhat.com/bugzill...g.cgi?id=115980 |
34 |
https://bugzilla.redhat.com/bugzill...g.cgi?id=113201 |
35 |
|
36 |
This did work for me. I don't guarantee it will work for everyone, use it |
37 |
at your own risk... |
38 |
|
39 |
You need a bootable Linux CD (e.g. Knoppix) and a DOS system disk with |
40 |
fdisk on it. |
41 |
Here are the steps I followed: |
42 |
|
43 |
1. boot from Knoppix or other bootable Linux CD (using the Fedora rescue |
44 |
CD or booting in the newly installed system in single mode, ro mounted |
45 |
may work too, but I haven't tried) |
46 |
|
47 |
2. save the content of the MBR (and possibly all the boot sectors from |
48 |
the partitions). This is important in case something goes wrong and you |
49 |
want to restore later: |
50 |
$ dd if=/dev/hda of=mbr.img bs=512 count=1 |
51 |
|
52 |
3. run fdisk, go into expert mode and write down (or save into a file) |
53 |
the starting sector (NOT block), end sector and type for each partition |
54 |
(example below): |
55 |
$ fdisk /dev/hda |
56 |
Command: u (change units to sectors) |
57 |
Command: p (print) |
58 |
Example output: |
59 |
|
60 |
Device Boot Start End Blocks Id System |
61 |
/dev/hda1 * 63 33732719 16866328+ 7 HPFS/NTFS |
62 |
/dev/hda2 74692800 78140159 1723680 1c Hidden W95 FAT32 |
63 |
(LBA) |
64 |
/dev/hda3 35834400 74692799 19429200 83 Linux |
65 |
/dev/hda4 33732720 35834399 1050840 82 Linux swap |
66 |
|
67 |
4. completely erase the MBR by writing zeros to it (you may skip this |
68 |
step, I am not sure if it is really needed, but this way it worked for |
69 |
me): |
70 |
$ dd if=/dev/zero of=zero.img bs=512 count=1 |
71 |
$ dd if=zero.img of=/dev/hda |
72 |
|
73 |
5. force the original number of heads. In my case (20Gb in a Thinkpad) |
74 |
this was 240, but in most other cases it would be 255. See this post for |
75 |
more info: |
76 |
|
77 |
http://groups.google.com/groups?hl=....bofh.it&rnum=4 |
78 |
|
79 |
Using fdisk this will also create a new DOS partition table and restore |
80 |
the original partitions: |
81 |
|
82 |
$ fdisk -H 255 /dev/hda # or 240 for some configurations |
83 |
Command: o (create new partition table) |
84 |
|
85 |
6. by now you have a newly generaed partition table, with the original |
86 |
disk geometry. Recreate the partitions as they were before: |
87 |
|
88 |
Command: n (new partition) |
89 |
Primary partition (p) |
90 |
Partition number: 1 |
91 |
First cylinder: 63 # beginning of first partition |
92 |
Last cylinder or +size[...]: 33732719 # end of first partition |
93 |
|
94 |
Command: t (change type) |
95 |
Partition number: 1 |
96 |
Hex code: 07 # they type of the partition |
97 |
|
98 |
Repeat for all 4 partitions. Verify at the end that the start/end/id are |
99 |
correct: |
100 |
|
101 |
Command: p (print) |
102 |
|
103 |
If everything is correct, write the partition table to the disk and exit: |
104 |
|
105 |
Command: w (write) |
106 |
Command: q (quit) |
107 |
|
108 |
7. in my case, I had to run an extra "fdisk /mbr" using the DOS bootdisk |
109 |
(may work with a XP installation CD too, but I haven't tried). After |
110 |
that, everything worked fine, the partition table was back to the |
111 |
original configuration. |
112 |
|
113 |
If you have the GRUB in the MBR, the "fdisk /mbr" will overwrite it so |
114 |
you may want to restore it later (but use the Knoppix CD, not FC2, |
115 |
otherwise you may end up where you started if the bug is in grub). On my |
116 |
machine GRUB was installed in the Linux partition so it wasn't affected. |
117 |
|
118 |
You can return to the original MBR at any time by writing the saved image |
119 |
to the disk (in case this fix does not work for you) as long as you only |
120 |
make changes to the MBR: |
121 |
|
122 |
$ fdisk if=mbr.img of=/dev/hda |
123 |
|
124 |
This is it, I hope it works for others, if it does please let me know. |
125 |
|
126 |
|
127 |
-- |
128 |
Radu |
129 |
|
130 |
|
131 |
At 21:25 2005.07.25., you wrote: |
132 |
>Martins wrote: |
133 |
> |
134 |
>> |
135 |
>>> |
136 |
>>>Um, if you do this, you will more than likely destroy the filesystems as |
137 |
>>>well, because the new partitions will not line up exactly with the old ones. |
138 |
>>> |
139 |
>>>Anyway I don't think this is the problem. Afterall, WinXP booted fine |
140 |
>>>before on this drive with LBA disabled, so something else is up. If you |
141 |
>>>already made the right changes to the boot.ini file, then I suspect that |
142 |
>>>a "fixboot" from the recovery mode of the WinXP CD will be necessary. |
143 |
>>>This should not overwrite the MBR, only the boot loader that is at the |
144 |
>>>beginning of the windows partition. |
145 |
>>> |
146 |
>>>-Richard |
147 |
>>> |
148 |
>>>-- |
149 |
>>>gentoo-user@g.o mailing list |
150 |
>> |
151 |
>> |
152 |
>>there is no worry, writing new partition table give it the same values |
153 |
>>(partition start, end, type, order) as before and not a single bit is lost |
154 |
> |
155 |
>What I am saying is that this is not possible with fdisk, because fdisk |
156 |
>will insist on creating the new partitions aligned on cylinder boundaries, |
157 |
>which will have moved in terms of logical sectors. Example: |
158 |
> |
159 |
>Let's say you want a 100MB partition, or about 200000 512-byte sectors: |
160 |
> |
161 |
>With non-LBA geometry, the math is 200000 sectors / (63 sectors/track * 16 |
162 |
>heads) = 198.41 cylinders. Now round down to 198 cylinders and you get |
163 |
>199584 sectors in your partition |
164 |
> |
165 |
>With LBA geometry, the math is 200000 / (63 sectors/track * 255 heads) = |
166 |
>12.449 cylinders. Again, round down to 12, and you get 192780 sectors in |
167 |
>your partition. You can round up to 13 and get 208845, but you *cannot* |
168 |
>get 199584. Possibly with another partitioning tool that allows you to |
169 |
>specify the starting and ending heads as well as cylinders, but not with fdisk. |
170 |
> |
171 |
>It is *possible* for this to work if you have just one huge partition, or |
172 |
>if your partitions happen to end at even multiples of both (63 * 255) and |
173 |
>(63 * 16). |
174 |
> |
175 |
>And just for the sake of accuracy, the cylinder alignment thing is true |
176 |
>for all partitions except: |
177 |
> |
178 |
>- Cylinder 0, head 0 is reserved for the MBR, so any partition starting at |
179 |
>cylinder 0 actually starts at head 1. |
180 |
>- Logical partitions actually start at head 0, sector 1, because the first |
181 |
>sector contains another partition table that points to the next partition. |
182 |
> |
183 |
>-Richard |
184 |
> |
185 |
>-- |
186 |
>gentoo-user@g.o mailing list |
187 |
|
188 |
-- |
189 |
gentoo-user@g.o mailing list |