Linux under DD and OD command backup view hard disk MBR and use VIM to modify!

Source: Internet
Author: User

The Master boot record (master boot RECORD,MBR) is located on a hard disk with 0 cylinders, 0 disk faces, and 1 sectors, total 512 bytes. The specific divisions are: Boot code area 440 bytes, disk signature 4 bytes, white space (Ox0000) 2 bytes, MBR partition table (Disk Partition table,dpt) 64 bytes, end flag (OX55AA) 2 bytes. The MBR partition table (DPT) differs from another "Globally unique identity partition table (GUID Partition table,gpt)". This article discusses only MBR and DPT today.

Needless to say, the following first describes how to back up, restore MBR and DPT:

Back up and restore MBR, partition table DPT:

The following commands are examples of the SDA hard drive.

Backup/restore HDD MBR (all 512 bytes):

#备份 #  DD if=/dev/sda of=./mbr.bak bs=512 count=1# Recovery #  DD If=./mbr.bak OF=/DEV/SDA bs=512 count=1

Partition Table DPT (after 66 bytes) for backup/restore only disks:

#备份 #  DD if=/dev/sda of=./dpt.bak bs=1 skip=446 count=66# Recovery #  DD if=./dpt.bak OF=/DEV/SDA bs=1 seek=446 count=66

Recover only the boot code portion of the hard disk mbr (first 446 bytes):

#恢复 #  DD if=./mbr.bak OF=/DEV/SDA bs=446 count=1

View with OD

Od-ax-x./mbr.bak

Linux command :od
  function Description : Output file contents.

  syntax : od [-abcdfhilovx][-a < Loadline cardinality >][-j < number of characters >][-n < number of characters >][-s < string characters >][-t < output format;] [-W < number of characters per column;] [--help] [--version] [File ...]

  Supplemental Note : The OD instruction reads the contents of the given file and renders its contents in octal loadline.

  Parameters :

-a The effect of this parameter is the same as specifying the "-ta" parameter.

-a< Loadline Cardinality > select the cardinality to calculate loadline.

-B The effect of this parameter is the same as specifying the "-TOC" parameter.

-C This parameter has the same effect as specifying the "-TC" parameter.

-d The effect of this parameter is the same as specifying the "-TU2" parameter.

-F The effect of this parameter is the same as specifying the "-TFF" parameter.

-H This parameter has the same effect as specifying the "-TX2" parameter.

-I the effect of this parameter is the same as specifying the "-TD2" parameter.

-j< number of characters > or--skip-bytes=< characters > skip setting the number of characters.

-L The effect of this parameter is the same as specifying the "-TD4" parameter.

-n< number of characters > or--read-bytes=< characters > until the number of characters set.

-O This parameter has the same effect as specifying the "-to2" parameter.

-s< string character count > or--strings=< string character > displays only strings that match the specified number of characters.

-t< output format > or--FOrmat=< output format > Set output format.

-V or--output-duplicates output without omitting duplicate data.

-w< number of characters per column > or--width=< per column character > sets the maximum number of characters per column.

-X The effect of this parameter is the same as specifying the "-H" parameter.

--help online Help.

--version Displays version information.

From Linux system operations:
Http://www.linuxyw.com/a/wenjianguanli/20130505/191.html

First open it in a binary way:
Vim Mbr.bak-b
Then enter in VIM command mode:
:%!xxd #参数% refers to the file currently being edited
The MBR file appears in hexadecimal, and you can edit it now.

When the edits are finished, we need to revert to binary files:
:%!xxd-r #参数-R means converting the current 16 binary into binary

Save exit:

Linux under DD and OD command backup view hard disk MBR and use VIM to modify!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.