Linux manual backup restore HDD Master boot record MBR with hard disk partition Table DPT Tutorial

Source: Internet
Author: User

Linux manual backup restore HDD Master boot record MBR with hard disk partition Table DPT Tutorialtwo Cow Linux, Ubuntu, Windows 1,885 views View comments

Recently cows have been tossing Linux grub and GRUB2, because the former ghost restore Windows when the error occurred, causing the partition table is destroyed, unable to enter the system. Today we are going to show you how to back up and restore our HDD master boot sector. First of all, let me introduce the main boot sector of this hard disk, because for this master boot record the MBR with this hard disk partition table DPT relationship, probably some friends are not so clear.

HDD Master boot sector (first 512 bytes of hard disk) = hard disk master boot record (MBR, first 446 bytes of hard disk) + hard disk partition table (66 bytes after dpt,mbr)

MBR 446 bytes (0000–01bd), DPT 64 bytes (01BE–01FD), End Flag 2 bytes (in AA)

This end flag is important and will cause the system to restart indefinitely if it is missing.

This master boot record MBR is part of what we usually call a boot program, whether it's a Windows or Linux system, where a part of the bootstrapper is written. But this part of the boot program is just part of the boot program, take the latest version of Grub GRUB2, through the MBR boot grub2, and then grub2 boot to continue to the hard disk on the/boot/grub/directory to continue to boot, Here the cows will be on the hard drive or USB stick when installing grub description.

Said MBR, we'll talk about it. partition table, partition table DPT is 66 bytes after MBR, can have up to four primary partitions or three primary partitions plus one logical partition. The logical partition information is written on the extended partition start sector. Therefore, generally as long as the partition table DPT does not have problems, logical partitions generally do not have problems.

The main boot sector of the hard disk has been introduced, the following is the specific method of backup and restore.

Here the cows are done with the DD command under Ubuntu Linux.

To back up the primary boot sector of the hard disk:

DD IF=/DEV/SDA Of=./mbr.bak bs=512 count=1

Note If is the input device, we here put the first hard drive as an input device, here you need to note that some hard disk is not SDA but HDA, we can through

sudo fdisk-l

To see if you are an SD hard drive or an HD hard drive.

For the output file name, here we output to the current directory in the Mbr.bak file, you can use the PWD command to see the current directory location.

We can also specify that its output position is/boot/, the command is

DD IF=/DEV/SDA Of=/boot/mbr.bak bs=512 count=1

Restore also uses the same method

DD If=/boot/mbr.bak OF=/DEV/SDA bs=512 count=1

If you just want to restore the partitioned table DPT

DD If=/boot/mbr.bak OF=/DEV/SDA Bs=1 skip=446 count=66

The way to determine if our backup is correct is to see if the backup file Mbr.bak is 512 bytes and the end byte is $ AA.

Here the cows suggest that you often use ghost to restore friends, it is best to save the backup file more than a few backup, because think, if the partition table is wrong, our partition information may not be read out, so there is a disk partition table backup may not be able to restore. So, it is necessary to keep a backup cow on the Internet or on a USB flash drive. I hope this article is helpful to everyone.

Linux manual backup restore HDD Master boot record MBR with hard disk partition Table DPT Tutorial

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.