Need to patch the MBR on /dev/sda

Asked by Alex S

I have a multi boot system with ubuntu running in /dev/sda5 and WinXP running in /dev/sda2. /dev/sda1 is the dell utility partition and /dev/sda3 was a playground where I tried various other OS'es. ubuntu swap is /dev/sdb5, and my common shared data partition was /dev/sdb1. All of this was being managed by Partition Magic 8.0 on two 250gb SATA drives.

Knowing that Partition Magic 8.0 does not run under Win7, I preallocated a 64 gb /dev/sda3, hoping to not need PM 8.0 for awhile. (I found out later that PM has been discontinued.) I installed Win7 on /dev/sdb3 and the install blew away grub, as expected, but it also changed something in the /dev/sda3 partition table down in the /dev/sda MBR, making PM complain about an error, and then display error status for the entire drive. PM said it could "fix it", and after thinking and making backup copies of everything (except for the partition table, that is), I let PM "fix" the error. At that point, the error went away, but the bad drive status is still there, and now Norton Ghost complains that it can't reconcile backup points.

I found out exactly what changed on the MBR, and I want to change it back, with the assumption that PM is wrong, and Win7 is right. How do I do that. I have been looking for disk editors all day. I can get into GParted from the LiveCD disk but I'm afraid that it won't make the right change. I want to make a very specific two byte change and then get some other tool, like Acronis.

Before I blow everything away and start from scratch, restoring from backup - yes, I have backups - thank you - is there a simple way to edit the MBR while running the LiveCD? I think dd is the way to go, but the documentation is weak, and the risk is strong. (Problem is that the effort to reinstall, even from backup, is large.) Thanks.

Alex S.

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu grub2 Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
actionparsnip (andrew-woodhead666) said :
#1

You can boot liveCD or USB and reinstate the Grub boot loader which can boot both OSes.
http://www.omgubuntu.co.uk/2011/09/live-usb-sticking-grub-2-video/

Revision history for this message
Alex S (alexubuntu) said :
#2

Sorry, but you misunderstand. I want to patch the partition table, and I don't want to do it with GParted. Any ideas, please? Thanks.

Revision history for this message
marcus aurelius (adbiz) said :
#3

this sounds like a windoze problem. you'll need to ask at a windoze forum.

Revision history for this message
Alex S (alexubuntu) said :
#4

No, its not a windows problem, its a disk edit problem. I want to patch two bytes on /dev/sda while running from the LiveCD when it is not mounted. I can't do this from Windows. I don't want to use GParted. I think I need dd, but the documentation is unclear and I cannot afford to make a mistake. Can someone tell me how to use dd or direct me to a stable raw disk edit program that will run in this environment. Thank you.

Revision history for this message
Alex S (alexubuntu) said :
#5

I have "solved" the problem by purchasing Acronis, and invoking its manual disk editor.

However, I would still like to know, for future reference, how to patch disk files from the LiveCD. Does anyone out there have any information on this, or on using dd, as I suspect? Thanks.

Revision history for this message
delance (olivier-delance) said :
#6

You suspect right. "dd" is the only tool I know to edit MBR from LiveCD. But from Live session, you can install temporarily packages, and e.g. an hexadecimal editor.

Revision history for this message
Alex S (alexubuntu) said :
#7

Thank you for confirming that dd is the correct tool. I suspected that but I was not certain. Question remains, however - how do I use dd to edit a byte or two in the MBR? Documentation for dd is unclear and the examples don't help. Any guidance? Thanks.

Alex S.

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#8

You can patch the installed OS using the chroot from the live CD. Once you chroot, the commands you run will modify the installed OS and not the liveCD environment. Very handy for fixing things.

Revision history for this message
Alex S (alexubuntu) said :
#9

I understand that. Thank you. My question, however, is how to use dd. The documentation is unclear. Can someone either give me an example, for instance, of how to patch two bytes starting at offset 507 of /dev/sda, changing them to 0x12, and 0x34, or point me to where good documentation lies. Thank you.

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#10
Revision history for this message
Alex S (alexubuntu) said :
#11

Thank you for the information. However, thread 607515 only talks about zeroing the first 446 bytes of the MBR. I don't want to do that. Will someone PLEASE tell me how to use dd or direct me to a link that provides concrete examples. Thank you.

Alex S.

Revision history for this message
delance (olivier-delance) said :
#12

The command
   man dd
will give you the options of the command.

Can you help with this problem?

Provide an answer of your own, or ask Alex S for more information if necessary.

To post a message you must log in.