Как обнулить загрузочный код MBR?

3893
K.A

У меня есть два диска в моей системе Windows:

  • Диск 1, Система и Загрузка.
  • Диск 2, хранилище данных.

Некоторое время назад у меня была установлена ​​Windows на втором диске. Теперь, когда у меня есть текущая настройка, я бы хотел удалить загрузочный код из Windows из загрузочного сектора на диске 2. Если быть точным, я не хочу стирать таблицу разделов или что-либо еще, просто избавиться от (обнулить) немного кода, который ищет NTLDR.

Есть ли программное обеспечение или команда для этого?

0
Загрузочные сектора не могут быть удалены, только заменены чем-то другим. Ignacio Vazquez-Abrams 11 лет назад 0
Обновил мой ответ ниже для вашего обновления ...: p Xyon 11 лет назад 0

3 ответа на вопрос

2
Xyon

The MBR, in the case of DOS-style partition tables, is always present on the drive as a very small collection of sectors at the start of the drive.

It's not a thing to get rid of, because it contains, in addition to boot code, the partition table of your drive. Losing that means that the data on your disk, while intact, is suddenly a lot harder to get at (most OS'es I've seen will report a bad format and windows asks if you want to format the drive if it doesn't understand the partition table).

More info: http://technet.microsoft.com/en-us/library/cc976786.aspx

Edit: since you edited the question, I'll update my answer; dd can wipe it. Boot into a linux livecd and on your unmounted data drive run;

dd if=/dev/<path to data drive> of=/dev/<somewhere safe on windows drive>/mbr.img bs=512 count=1 

This will give you a 512-byte backup of the MBR including partition table, in case anything goes wrong.

To wipe the 446-byte bootstrap:

dd if=/dev/zero of=/dev/<path of data drive> bs=446 count=1 seek=0 

Depending on what you are trying to achieve you might only want to wipe the first 440 bytes of the MBR. The 4 bytes following the first 440 bytes contain the Windows Unique Disk Signature which you might want to retain. To wipe only the first 440-bytes use this command:

dd if=/dev/zero of=/dev/<path of data drive> bs=440 count=1 seek=0 
+1, но будущие читатели должны принять к сведению, что нет (очевидной) причины, по которой кто-то на самом деле хотел бы это сделать. Harry Johnston 11 лет назад 2
Есть ли конкретная причина для 'seek = 0' здесь? Это по умолчанию, конечно? Hashim 6 лет назад 0
Пояс и брекеты. Xyon 6 лет назад 0
1
LSerni

I beg your pardon in advance for the complicated answer, but I don't quite grasp what you want to do (or better: why).

I think that you are looking for the FDISK /CMBR command. There are also utilities that perform the same task, e.g. Paragon Partition Magic, or Boot/Partition Editor.

What you want to do is to rewrite the MBR and set the D: partition to non-system (not active, not bootable, no B flag, etc.).

Note that FDISK /CMBR should act only on a non system disk; many boot loaders install code that is needed afterwards to "see" the disk with the correct format or geometry; replacing them with a stock loader (which is what /CMBR does) can then render the disk unaccessible until the previous code is restored.

If you need to make the disk non-bootable because it interferes on the boot sequence or something (and displays a "NTLDR not found" error instead of booting, say), a better choice would be to modify the BIOS parameters for boot device order or using a FDISK-like utility to mark all partitions on that drive as non-system. In a pinch, swapping two hard disks ought to achieve the same result.

Otherwise, there are "selective boot loaders" (e.g. GRUB) that may help you implement a flexible booting option (e.g. booting Linux, or Windows, or another Windows from a startup menu screen).

1
Bryan

Marking it as not active in disk management should more than suffice for your situation.