You are not logged in.

#1 2016-08-24 01:15:10

Physicist1616
Member
Registered: 2015-02-16
Posts: 32

[SOLVED] dd to Restore MBR Backup

I upgraded my Windows partition to Windows 10, but it decided to kill my Syslinux MBR on another drive just because that was the one that was set to primary boot in the BIOS.

In a fit of benevolence, it backed my old MBR up to BOOTSECT.BAK in the fat32 boot partition.  As expected, it's 512 bytes and xxd reveals the characters SYSLINUX on the first line, so it looks right so far.  I dd'd it back into place with the following:

dd if=/path/mbr-backup of=/dev/sda conv=notrunc

Now it appears as a partitionless disk in lsblk.  I see that on the wiki, it suggests the same command without the notrunc. 

Please help me understand what I have done wrong (other than install Windows 10 big_smile).

Last edited by Physicist1616 (2016-08-25 19:04:05)

Offline

#2 2016-08-24 03:36:36

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,801

Re: [SOLVED] dd to Restore MBR Backup

Windows 10 tells me you may be using GPT https://wiki.archlinux.org/index.php/GU … tion_Table
Not to be confused with MBR


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#3 2016-08-24 10:47:07

R00KIE
Forum Fellow
From: Between a computer and a chair
Registered: 2008-09-14
Posts: 4,734

Re: [SOLVED] dd to Restore MBR Backup

If indeed the disk was partitioned as MBR _and_ you have done no other changes, then that should have done the trick. But it depends on how you have nuked the MBR. That said, you can check with fdisk if at least the primary partitions and the first logical partition are listed.


R00KIE
Tm90aGluZyB0byBzZWUgaGVyZSwgbW92ZSBhbG9uZy4K

Offline

#4 2016-08-24 10:56:37

Physicist1616
Member
Registered: 2015-02-16
Posts: 32

Re: [SOLVED] dd to Restore MBR Backup

Good thinking, but from the same page, "For Windows, there is no support for booting from a BIOS/GPT partitioning scheme." 

My motherboard doesn't support EFI, so it can't boot Windows from a GPT drive at all.

The Linux drive could hypothetically be GPT with MBR style boot, but I'm 95% sure I didn't make this disk GPT either (How long has Syslinux been capable of it?).  To confirm, I'm looking for the location and hex code that specifies GPT in the backup MBR, but I haven't found a great diagram to tell me what offset to find yet.

Offline

#5 2016-08-24 19:12:27

Physicist1616
Member
Registered: 2015-02-16
Posts: 32

Re: [SOLVED] dd to Restore MBR Backup

I'm thinking the BOOTSECT.BAK is invalid.  It looks valid, but maybe the Windows process to create it does something screwy instead of a byte for byte copy.

R00KIE, are you saying the notrunc for sure didn't break stuff?  It seems like it shouldn't, but I don't know for 100% sure.

Offline

#6 2016-08-24 19:42:26

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,810

Re: [SOLVED] dd to Restore MBR Backup

Physicist1616 wrote:

xxd reveals the characters SYSLINUX on the first line

Actually, that doesn't sound right to me. I've xxd'd a syslinux bootsector or two (bios/mbr) and never seen that. You can xxd the appropriate /usr/lib/syslinux/bios/<mbr bin> to see what it should look like.


But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

#7 2016-08-24 20:40:08

R00KIE
Forum Fellow
From: Between a computer and a chair
Registered: 2008-09-14
Posts: 4,734

Re: [SOLVED] dd to Restore MBR Backup

Notrunc should not do any harm, although I suppose it might not be needed.

What alphaniner says might be right on the money, syslinux does not have/use the SYSLINUX string in the code. You probably have a borked mbr backup, are you sure you used the right device, as in sda and not sdaX?


R00KIE
Tm90aGluZyB0byBzZWUgaGVyZSwgbW92ZSBhbG9uZy4K

Offline

#8 2016-08-24 20:56:34

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,810

Re: [SOLVED] dd to Restore MBR Backup

That got me thinking:

$ xxd /boot/syslinux/ldlinux.sys |head -1
00000000: 0d0a 5359 534c 494e 5558 2036 2e30 3320  ..SYSLINUX 6.03 

Though, more likely (sde1 is /boot partition):

# dd if=/dev/sde1 bs=16 count=1 status=none |xxd
00000000: eb58 9053 5953 4c49 4e55 5800 0200 0000  .X.SYSLINUX.....

Last edited by alphaniner (2016-08-24 21:00:51)


But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

#9 2016-08-25 19:00:15

Physicist1616
Member
Registered: 2015-02-16
Posts: 32

Re: [SOLVED] dd to Restore MBR Backup

Thanks for posting that, alphaniner.  The string I saw matches your sde1.  The BOOTSECT.BAK file is clearly the partition boot sector, not the disk's sector 0.

Having no partition table, I have restored most of the file structure from my home folder by just recreating partitions and fscking in hopes it would find the f2fs table (it did).

Offline

#10 2016-08-25 22:26:16

jmp186
Member
Registered: 2016-08-13
Posts: 22

Re: [SOLVED] dd to Restore MBR Backup

why did you dd 512 bytes and not just the 446 bytes of the actual Bootstrap zone of your drive ?

Offline

Board footer

Powered by FluxBB