To copy the Master Boot Record (MBR) on a UNIX or Linux system, you can use the dd
command.
dd if=/dev/DEVICE_NAME of=OUTPUT_FILE bs=512 count=1
Replace DEVICE_NAME
with the name of the device (e.g., sda
) and OUTPUT_FILE
with the desired filename for the copy of the MBR.
For example, to copy the MBR of the sda
device to a file named mbr.bin
, you would run:
dd if=/dev/sda of=mbr.bin bs=512 count=1
This will create a new file named mbr.bin
that contains a copy of the MBR.
dd if=INPUT_FILE of=/dev/DEVICE_NAME bs=512 count=1
Replace INPUT_FILE
with the name of the file containing the copy of the MBR and DEVICE_NAME
with the name of the device to which you want to restore the MBR.
For example, to restore the MBR from the mbr.bin
file to the sda
device, you would run:
dd if=mbr.bin of=/dev/sda bs=512 count=1
Note: Make sure to use the correct device names and be careful when using the dd
command, as it can overwrite important data if used improperly.