Public feed #380055

Stuff

public text v1 · immutable
Raw Edit
·published 2007-03-03 19:02 UTC
rendered paste body



This  how-to is written  for  people like me !!

that is if you have ever wiped out your  partition table   and the only form you have is a hexdump of it.

You can do this to regain it  and install it back this worked for me. 




Say the only representation of your partition table + mbr  WHICH you have

wiped out 

is 


00000000  fa eb 21 01 b2 01 4c 49  4c 4f 16 07 bb 65 c3 45  |úë!.².LILO..»eÃE|
00000010  00 00 00 00 57 b9 e5 01  30 a3 28 6e 81 00 80 60  |....W¹å.0£(n...`|
00000020  1f 06 8c 02 b8 c0 07 8e  d0 bc 00 08 fb 52 53 06  |....¸À..м..ûRS.|
00000030  56 fc 8e d8 31 ed 60 b8  00 12 b3 36 cd 10 61 b0  |Vü.Ø1í`¸..³6Í.a°|
00000040  0d e8 64 01 b0 0a e8 5f  01 b0 4c e8 5a 01 60 1e  |.èd.°.è_.°LèZ.`.|
00000050  07 80 fa fe 75 02 88 f2  bb 00 02 8a 76 1e 89 d0  |..úþu..ò»...v..Ð|
00000060  80 e4 80 30 e0 78 0a 3c  10 73 06 f6 46 1c 40 75  |.ä.0àx.<.s.öF.@u|
00000070  2e 88 f2 66 8b 76 18 66  09 f6 74 23 52 b4 08 b2  |..òf.v.f.öt#R´.²|
00000080  80 53 cd 13 5b 72 57 0f  b6 ca ba 7f 00 42 66 31  |.SÍ.[rW.¶Êº..Bf1|
00000090  c0 40 e8 60 00 66 3b b7  b8 01 74 03 e2 ef 5a 53  |À@è`.f;·¸.t.âïZS|
000000a0  8a 76 1f be 20 00 e8 dd  00 b4 99 66 81 7f fc 4c  |.v.¾ .èÝ.´.f..üL|
000000b0  49 4c 4f 75 29 5e 68 80  08 07 31 db e8 c7 00 75  |ILOu)^h...1ÛèÇ.u|
000000c0  fb be 06 00 89 f7 b9 0a  00 b4 9a f3 a6 75 0f b0  |û¾...÷¹..´.ó¦u.°|
000000d0  02 ae 75 0a 06 55 b0 49  e8 cd 00 cb b4 40 b0 20  |.®u..U°IèÍ.Ë´@° |
000000e0  e8 c5 00 e8 b2 00 fe 4e  00 74 07 bc e8 07 61 e9  |èÅ.è².þN.t.¼è.aé|
000000f0  5c ff f4 eb fd 60 55 55  66 50 06 53 6a 01 6a 10  |\ÿôëý`UUfP.Sj.j.|
00000100  89 e6 53 f6 c6 60 74 6e  f6 c6 20 74 14 bb aa 55  |.æSöÆ`tnöÆ t.»ªU|
00000110  b4 41 cd 13 72 0b 81 fb  55 aa 75 05 f6 c1 01 75  |´AÍ.r..ûUªu.öÁ.u|
00000120  3f 52 06 b4 08 cd 13 07  72 b4 51 c0 e9 06 86 e9  |?R.´.Í..r´QÀé..é|
00000130  89 cf 59 c1 ea 08 92 40  83 e1 3f f7 e1 93 8b 44  |.ÏYÁê..@.á?÷á..D|
00000140  08 8b 54 0a 39 da 73 94  f7 f3 39 f8 77 8e c0 e4  |..T.9Ús.÷ó9øw.Àä|
00000150  06 86 e0 92 f6 f1 08 e2  89 d1 41 5a 88 c6 eb 1c  |..à.öñ.â.ÑAZ.Æë.|
00000160  b4 42 5b bd 05 00 60 cd  13 73 16 4d 74 ba 31 c0  |´B[½..`Í.s.Mtº1À|
00000170  cd 13 61 4d eb f0 66 50  59 58 88 e6 b8 01 02 eb  |Í.aMëðfPYX.æ¸..ë|
00000180  e1 8d 64 10 61 c3 66 ad  66 09 c0 74 0a 66 03 46  |á.d.aÃf­f.Àt.f.F|
00000190  10 e8 61 ff 80 c7 02 c3  c1 c0 04 e8 03 00 c1 c0  |.èaÿ.Ç.ÃÁÀ.è..ÁÀ|
000001a0  04 24 0f 27 04 f0 14 40  60 bb 07 00 b4 0e cd 10  |.$.'.ð.@`»..´.Í.|
000001b0  61 c3 00 00 00 00 4d 7f  30 a3 28 6e cf c9 80 01  |aÃ....M.0£(nÏÉ..|
000001c0  01 00 0c 0f ff ff 3f 00  00 00 91 10 2a 01 00 0f  |....ÿÿ?.....*...|
000001d0  ff ff 83 0f ff ff c0 14  2a 01 02 e2 1a 01 00 0f  |ÿÿ..ÿÿÀ.*..â....|
000001e0  ff ff 83 0f ff ff 00 0a  54 02 90 1d 1b 01 00 0f  |ÿÿ..ÿÿ..T.......|
000001f0  ff ff 05 0f ff ff 90 27  6f 03 e0 8d 39 01 55 aa  |ÿÿ..ÿÿ.'o.à.9.Uª|
00000200

please take into note that 

Note: An MBR has 3 parts:

   1. (000000 - 0001bd) The boot code which is 446 bytes long
   2. (0001be - 0001fd) The partition table which is 64 bytes long
   3. (0001fe - 0001ff) The boot code signature of 55aa which is 2 bytes long and goes at the very end



so they way to go is to convert the hexademical code  back to  binary form and copy that file back to the MBR .

the hex code is  the "fa eb 21 01 b2 01 4c 49  4c 4f 16 07 bb 65 c3 45" ------>  ascii--> |úë!.².LILO..»eÃE|

1) you have to get rid of the 1st colum and the ascii presentation on the right 

you do 

agiofws@celeron3~
$cat ddTable | cut -c 11-58
fa eb 21 01 b2 01 4c 49  4c 4f 16 07 bb 65 c3 45
00 00 00 00 57 b9 e5 01  30 a3 28 6e 81 00 80 60
1f 06 8c 02 b8 c0 07 8e  d0 bc 00 08 fb 52 53 06
56 fc 8e d8 31 ed 60 b8  00 12 b3 36 cd 10 61 b0
0d e8 64 01 b0 0a e8 5f  01 b0 4c e8 5a 01 60 1e
07 80 fa fe 75 02 88 f2  bb 00 02 8a 76 1e 89 d0
80 e4 80 30 e0 78 0a 3c  10 73 06 f6 46 1c 40 75
2e 88 f2 66 8b 76 18 66  09 f6 74 23 52 b4 08 b2
80 53 cd 13 5b 72 57 0f  b6 ca ba 7f 00 42 66 31
c0 40 e8 60 00 66 3b b7  b8 01 74 03 e2 ef 5a 53
8a 76 1f be 20 00 e8 dd  00 b4 99 66 81 7f fc 4c
49 4c 4f 75 29 5e 68 80  08 07 31 db e8 c7 00 75
fb be 06 00 89 f7 b9 0a  00 b4 9a f3 a6 75 0f b0
02 ae 75 0a 06 55 b0 49  e8 cd 00 cb b4 40 b0 20
e8 c5 00 e8 b2 00 fe 4e  00 74 07 bc e8 07 61 e9
5c ff f4 eb fd 60 55 55  66 50 06 53 6a 01 6a 10
89 e6 53 f6 c6 60 74 6e  f6 c6 20 74 14 bb aa 55
b4 41 cd 13 72 0b 81 fb  55 aa 75 05 f6 c1 01 75
3f 52 06 b4 08 cd 13 07  72 b4 51 c0 e9 06 86 e9
89 cf 59 c1 ea 08 92 40  83 e1 3f f7 e1 93 8b 44
08 8b 54 0a 39 da 73 94  f7 f3 39 f8 77 8e c0 e4
06 86 e0 92 f6 f1 08 e2  89 d1 41 5a 88 c6 eb 1c
b4 42 5b bd 05 00 60 cd  13 73 16 4d 74 ba 31 c0
cd 13 61 4d eb f0 66 50  59 58 88 e6 b8 01 02 eb
e1 8d 64 10 61 c3 66 ad  66 09 c0 74 0a 66 03 46
10 e8 61 ff 80 c7 02 c3  c1 c0 04 e8 03 00 c1 c0
04 24 0f 27 04 f0 14 40  60 bb 07 00 b4 0e cd 10
61 c3 00 00 00 00 4d 7f  30 a3 28 6e cf c9 80 01
01 00 0c 0f ff ff 3f 00  00 00 91 10 2a 01 00 0f
ff ff 83 0f ff ff c0 14  2a 01 02 e2 1a 01 00 0f
ff ff 83 0f ff ff 00 0a  54 02 90 1d 1b 01 00 0f
ff ff 05 0f ff ff 90 27  6f 03 e0 8d 39 01 55 aa



2) to get rid of the white space just to be sure to get an accurate MBR 

$cat ddTable2 | tr -d '[[:space:]]'
faeb2101b2014c494c4f1607bb65c3450000000057b9e50130a3286e810080601f068c02b8c0078ed0bc0008fb52530656fc8ed831ed60b80012b336cd1061b00de86401b00ae85f01b04ce85a01601e0780fafe750288f2bb00028a761e89d080e48030e0780a3c107306f6461c40752e88f2668b76186609f6742352b408b28053cd135b72570fb6caba7f00426631c040e86000663bb7b8017403e2ef5a538a761fbe2000e8dd00b49966817ffc4c494c4f75295e6880080731dbe8c70075fbbe060089f7b90a00b49af3a6750fb002ae750a0655b049e8cd00cbb440b020e8c500e8b200fe4e007407bce80761e95cfff4ebfd605555665006536a016a1089e653f6c660746ef6c6207414bbaa55b441cd13720b81fb55aa7505f6c101753f5206b408cd130772b451c0e90686e989cf59c1ea08924083e13ff7e1938b44088b540a39da7394f7f339f8778ec0e40686e092f6f108e289d1415a88c6eb1cb4425bbd050060cd1373164d74ba31c0cd13614debf06650595888e6b80102ebe18d641061c366ad6609c0740a66034610e861ff80c702c3c1c004e80300c1c004240f2704f0144060bb0700b40ecd1061c3000000004d7f30a3286ecfc9800101000c0fffff3f00000091102a01000fffff830fffffc0142a0102e21a01000fffff830fffff000a5402901d1b01000fffff050fffff90276f03e08d390155aa 


3) so now we are ready to convert it back to its original state 


for this task we use  xxd  with the -r and the -p otion 

agiofws@celeron3~

$cat ddTable3  | xxd  -p -r

èd°²LILO»eÃEW¹å0£(n`¸ÀÐûRSVüØ1í`¸³6Ía°
è_°LèZ`úþuò»vÐä0àx
<söF@u.òfvf   öt#R²SÍ[rW¶ÊºBf1À@è`f;·¸tâïZSv¾ èÝ´füLILOu)^h1ÛèÇuû¾÷¹
´ó¦u°®u
U°IèÍË´@° èÅè²þNt¼èaé\ÿôëý`UUfPSjjæSöÆ`tnöÆ t»ªU´AÍr
                                                     ûUªuöÁu?RÍr´QÀééÏYÁ@á?÷áT
9Ús÷ó9øwÀäàöâÑAZÆë´B[½`ÍsMtº1ÀÍaMëðfPYXæ¸ëádaÃf­f       Àt
fFèaÿÇÃÁÀèÁÀ$'ð@`»´ÍaÃM0£(nÏÉ
                               ÿÿ?*ÿÿÿÿÀ*âÿÿÿÿ
Tÿÿÿÿ'oà9Uª



we  save the ouput to  ddTable4

agiofws@celeron3~
$cat ddTable3  | xxd  -p -r > ddTable4   

4) to check if  the above output is exaclty tha same as the  first table up  TOP  we can do


agiofws@celeron3~
$dd if=ddTable4 | hexdump -C
1+0 records in
1+0 records out
512 bytes (512 B) copied, 0.000131539 seconds, 3.9 MB/s
00000000  fa eb 21 01 b2 01 4c 49  4c 4f 16 07 bb 65 c3 45  |úë!.².LILO..»eÃE|
00000010  00 00 00 00 57 b9 e5 01  30 a3 28 6e 81 00 80 60  |....W¹å.0£(n...`|
00000020  1f 06 8c 02 b8 c0 07 8e  d0 bc 00 08 fb 52 53 06  |....¸À..м..ûRS.|
00000030  56 fc 8e d8 31 ed 60 b8  00 12 b3 36 cd 10 61 b0  |Vü.Ø1í`¸..³6Í.a°|
00000040  0d e8 64 01 b0 0a e8 5f  01 b0 4c e8 5a 01 60 1e  |.èd.°.è_.°LèZ.`.|
00000050  07 80 fa fe 75 02 88 f2  bb 00 02 8a 76 1e 89 d0  |..úþu..ò»...v..Ð|
00000060  80 e4 80 30 e0 78 0a 3c  10 73 06 f6 46 1c 40 75  |.ä.0àx.<.s.öF.@u|
00000070  2e 88 f2 66 8b 76 18 66  09 f6 74 23 52 b4 08 b2  |..òf.v.f.öt#R´.²|
00000080  80 53 cd 13 5b 72 57 0f  b6 ca ba 7f 00 42 66 31  |.SÍ.[rW.¶Êº..Bf1|
00000090  c0 40 e8 60 00 66 3b b7  b8 01 74 03 e2 ef 5a 53  |À@è`.f;·¸.t.âïZS|
000000a0  8a 76 1f be 20 00 e8 dd  00 b4 99 66 81 7f fc 4c  |.v.¾ .èÝ.´.f..üL|
000000b0  49 4c 4f 75 29 5e 68 80  08 07 31 db e8 c7 00 75  |ILOu)^h...1ÛèÇ.u|
000000c0  fb be 06 00 89 f7 b9 0a  00 b4 9a f3 a6 75 0f b0  |û¾...÷¹..´.ó¦u.°|
000000d0  02 ae 75 0a 06 55 b0 49  e8 cd 00 cb b4 40 b0 20  |.®u..U°IèÍ.Ë´@° |
000000e0  e8 c5 00 e8 b2 00 fe 4e  00 74 07 bc e8 07 61 e9  |èÅ.è².þN.t.¼è.aé|
000000f0  5c ff f4 eb fd 60 55 55  66 50 06 53 6a 01 6a 10  |\ÿôëý`UUfP.Sj.j.|
00000100  89 e6 53 f6 c6 60 74 6e  f6 c6 20 74 14 bb aa 55  |.æSöÆ`tnöÆ t.»ªU|
00000110  b4 41 cd 13 72 0b 81 fb  55 aa 75 05 f6 c1 01 75  |´AÍ.r..ûUªu.öÁ.u|
00000120  3f 52 06 b4 08 cd 13 07  72 b4 51 c0 e9 06 86 e9  |?R.´.Í..r´QÀé..é|
00000130  89 cf 59 c1 ea 08 92 40  83 e1 3f f7 e1 93 8b 44  |.ÏYÁê..@.á?÷á..D|
00000140  08 8b 54 0a 39 da 73 94  f7 f3 39 f8 77 8e c0 e4  |..T.9Ús.÷ó9øw.Àä|
00000150  06 86 e0 92 f6 f1 08 e2  89 d1 41 5a 88 c6 eb 1c  |..à.öñ.â.ÑAZ.Æë.|
00000160  b4 42 5b bd 05 00 60 cd  13 73 16 4d 74 ba 31 c0  |´B[½..`Í.s.Mtº1À|
00000170  cd 13 61 4d eb f0 66 50  59 58 88 e6 b8 01 02 eb  |Í.aMëðfPYX.æ¸..ë|
00000180  e1 8d 64 10 61 c3 66 ad  66 09 c0 74 0a 66 03 46  |á.d.aÃf­f.Àt.f.F|
00000190  10 e8 61 ff 80 c7 02 c3  c1 c0 04 e8 03 00 c1 c0  |.èaÿ.Ç.ÃÁÀ.è..ÁÀ|
000001a0  04 24 0f 27 04 f0 14 40  60 bb 07 00 b4 0e cd 10  |.$.'.ð.@`»..´.Í.|
000001b0  61 c3 00 00 00 00 4d 7f  30 a3 28 6e cf c9 80 01  |aÃ....M.0£(nÏÉ..|
000001c0  01 00 0c 0f ff ff 3f 00  00 00 91 10 2a 01 00 0f  |....ÿÿ?.....*...|
000001d0  ff ff 83 0f ff ff c0 14  2a 01 02 e2 1a 01 00 0f  |ÿÿ..ÿÿÀ.*..â....|
000001e0  ff ff 83 0f ff ff 00 0a  54 02 90 1d 1b 01 00 0f  |ÿÿ..ÿÿ..T.......|
000001f0  ff ff 05 0f ff ff 90 27  6f 03 e0 8d 39 01 55 aa  |ÿÿ..ÿÿ.'o.à.9.Uª|



as we can see indeed it is :)


now the only thing to do is to copy the partition table BACK to  its place  so you can start using you disk again 

so  all we do is   

  dd if=ddTable4 of=/dev/hda bs=512 count=1 

  and now hopefully you will be able to boot from your  drive 


* i was told that  to recover from  a wiped out partition table  you can use parted or Qparted  which 

seeks out previous entries of  your partition table  


good luck   :)