Author Topic: Possible wiki mistake for "Restore command" for "Windows Partition Boot Deleted"  (Read 859 times)

Offline computer.enthusiastic

  • Newbie
  • *
  • Posts: 2
Hi.

First of all, my greetings to the followers of the forum. Then I apologize for my English because I'm not a native English speaker.

I would like to report a possible mistake in the Wiki (http://www.supergrubdisk.org/wiki/Windows_Partition_Boot_Deleted#The_Restore_Command). It's current content is:
Quote
The Restore Command
Now we are using dd command as root to do the actual restore.
Code: [Select]
dd if=/dev/sda1 of=/dev/sda1 count=1 bs=512 seek=117194111 skip=0[..]

It seems to me that the previous command does not accomplish the desired task, but - instead - it overwrite the backup copy of boot disk sector at the end of the windows partition, failing to recover the boot sector and making the recovery impossible in the future.

I've tried to simulate the "restore command" currently shown in the wiki ; these are the  commands and their outputs:
Code: [Select]
# Create a file named "image.img" with 10 blocks; each block is 512 bytes long 
$ n=0; [ -e image.img ] && rm image.img; while [ "$n" -lt 10 ]; do c=0; while [ "$c" -lt 512 ]; do echo -ne "\x$n" >> /tmp/image.img; c=$(( $c+1 )); done; n=$(( $n+1 )); done

# This is the dump of image.img after creation
$ hexdump /tmp/image.img
0000000 0000 0000 0000 0000 0000 0000 0000 0000
*
0000200 0101 0101 0101 0101 0101 0101 0101 0101
*
0000400 0202 0202 0202 0202 0202 0202 0202 0202
*
0000600 0303 0303 0303 0303 0303 0303 0303 0303
*
0000800 0404 0404 0404 0404 0404 0404 0404 0404
*
0000a00 0505 0505 0505 0505 0505 0505 0505 0505
*
0000c00 0606 0606 0606 0606 0606 0606 0606 0606
*
0000e00 0707 0707 0707 0707 0707 0707 0707 0707
*
0001000 0808 0808 0808 0808 0808 0808 0808 0808
*
0001200 0909 0909 0909 0909 0909 0909 0909 0909
*
0001400

# According to instruction at http://www.supergrubdisk.org/wiki/Windows_Partition_Boot_Deleted#The_Restore_Command
# the following command is intended to overwrite the first block one with the last one.
$ dd if=/tmp/image.img of=/tmp/image.img count=1 bs=512 seek=9 skip=0

# This is the dump of image.img after the previous command
$ hexdump /tmp/image.img
0000000 0000 0000 0000 0000 0000 0000 0000 0000
*
0000200 0101 0101 0101 0101 0101 0101 0101 0101
*
0000400 0202 0202 0202 0202 0202 0202 0202 0202
*
0000600 0303 0303 0303 0303 0303 0303 0303 0303
*
0000800 0404 0404 0404 0404 0404 0404 0404 0404
*
0000a00 0505 0505 0505 0505 0505 0505 0505 0505
*
0000c00 0606 0606 0606 0606 0606 0606 0606 0606
*
0000e00 0707 0707 0707 0707 0707 0707 0707 0707
*
0001000 0808 0808 0808 0808 0808 0808 0808 0808
*
0001200 0000 0000 0000 0000 0000 0000 0000 0000
*
0001400
As you can see, the first block is unchanged, while the last sector is overwritten with the data of the first one. It seems that the current behaviour of this command is the opposite of the intended one.

I suppose that the restore command should be (related to the previous example):
Code: [Select]
dd if=/tmp/image.img of=/tmp/image.img count=1 bs=512 seek=0 skip=9
So that, the "skip" and "seek" options should be inverted.

Please, verify the previous statements and, if the are confirmed, update the wiki.

Thanks.
« Last Edit: 2012/01/07, 18:47:55 pm by computer.enthusiastic »

Offline adrian15

  • Administrator
  • Hero Member
  • *****
  • Posts: 794
  • Please test Rescatux and report back feedback...
    • El blog de adrian15
Yeah. That was true. The command was wrong. I have fixed it.

Thank you very much indeed!

adrian15
If you have liked this piece of advice please consider donating to the Super Grub Disk project.

Offline computer.enthusiastic

  • Newbie
  • *
  • Posts: 2
Hi,

Thanks for your verification and for the fast wiki update.

For reference, the wiki is now updated as following:
Quote
The Restore Command
Now we are using dd command as root to do the actual restore.
Code: [Select]
dd if=/dev/sda1 of=/dev/sda1 count=1 bs=512 skip=117194111 seek=0
where, of course, the parameter of the "skip" option depends on parameters explained in the wiki.
« Last Edit: 2012/01/07, 18:56:26 pm by computer.enthusiastic »