User Tools

Site Tools


backup_and_restore_mbr

Linking to a good howto first:

https://www.cyberciti.biz/faq/howto-copy-mbr/

The MBR is all total 512 bytes on the very first section on a harddisk on

  • 446 bytes – Bootstrap.
  • 64 bytes – Partition table.
  • 2 bytes – Signature.

The first 440 bytes of MBR are bootstrap code area. On BIOS systems it usually contains the first stage of the boot loader.

GUID Partition Table (GPT) is an alternative, contemporary, partitioning style; it is intended to replace the old Master Boot Record (MBR) system. GPT has several advantages over MBR which has quirks dating back to MS-DOS times.

So this howto is only for BIOS based MBR partition schemes!!! NOT for GUID Partition Table (GPT) !

To backup the full MBR including partition scheme:

sudo dd if=/dev/sdX of=mbr-sdX.bak bs=512 count=1

To play it back on the same disk with the same partition scheme:

sudo dd if=mbr-sdX.bak of=/dev/sdX bs=512 count=1

This is usefull as a MBR-backup for a dual-boot system with Antergos and Windows on the same disk.

As we all know with installed grub on the MBR Windows 10 get problems on updates, and with a backup of the original MBR from WIndows you can write it back, proceeed the updates and write grub back then.

To write back only the bootstrap code area without may changed partition scheme:

sudo dd if=mbr-sdX.bak of=/dev/sdX bs=446 count=1


The above commands will preserve the partitioning schema.

An all this you will need to change sdX to the disk letter of your harddisk.

you can watch the scheme with:

sudo fdisk -l

this will look like this:

Disk /dev/sda: 149 GiB, 160000000000 bytes, 312500000 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x89809807

Device     Boot     Start       End   Sectors  Size Id Type
/dev/sda1            2048   1026047   1024000  500M  7 HPFS/NTFS/exFAT
/dev/sda2  *      1488896 187825238 186336343 88.9G  7 HPFS/NTFS/exFAT
/dev/sda3       187826176 189618175   1792000  875M 27 Hidden NTFS WinRE
/dev/sda4       189618176 312498175 122880000 58.6G  5 Extended
/dev/sda5       189620224 294477823 104857600   50G 83 Linux
/dev/sda6       294479872 312498175  18018304  8.6G 82 Linux swap / Solaris

Your disk letter is a here so it would be /dev/sda …

or use

''lsblk -f''
NAME     FSTYPE LABEL                             UUID                                                            MOUNTPOINT

sdc
├─sdc1 ntfs           System-reserved             D4A274198756403F0
├─sdc2 ntfs                                                   70S6554T8887C77E
├─sdc3 ntfs                                                   264070S6554T8881
├─sdc4
├─sdc5 ext4           root                                 5acb7147-e063fa-70S6554T-7C77E         [/]
└─sdc6 swap         swap                               87zz787633-541-4b51-bg656-6545431     [SWAP]

Custom Grub cfg Generator

backup_and_restore_mbr.txt · Last modified: 2018/04/28 11:53 by joekamprad