Browsing articles in "sysadmin"
May
21

How to back up and restore MBR?

By Alaa Qutaish  //  sysadmin  //  7 Comments

Backup and restore MBR (Master Boot Record).

What is MBR anyway ?
MBR is the first 512 byte boot sector of a partitioned data storage device “Hard Disk” and it is not located in a partition, it is located in the Main boot record in front of the first partition.
MBR contains the primary partition entries in its partition table.

What is it for?

  1. Holding storage primary partition table, with exact max four primary partition tables
  2. Bootstrapping the operating system after BIOS loads and executes the MBR
  3. Identifying uniquely disk media with 32-bit disk signature

MBR code expects and scans the list of primary partitions entries in its partition table to find one and only partition marked with “active” flag , and then it loads its VBR “Volume Boot Record”

It is possible to edit the code inside the MBR sector using “Disk Editors” like fdisk. So what fdisk does is manipulating MBR code.

what would happen if we deleted our MBR or messed up with its code?
Simply, we will not be able to locate our partitions anymore and it would be a blind hard disk that can not see its partitions.
That hurts isn`t it? So the solution for this is to back up the MBR so we will not be afraid if something wrong happened in it.

How to back up the MBR?
Back up command:
dd if=/dev/sda of=/home/alaa/Sonyvaio-MBR.bkp bs=512 count=1

How to restore the MBR?
If the MBR is damaged, then you will be not able to boot from your disk, right? , so you have to do the following steps:

1- Boot up from Live CD like “Ubuntu or Gentoo or whatever you like”
2- In the terminal window type:
mkdir tmp
3- You have to mount the partition where the MBR image is saved, for example we saved it in my home directory, so :
mount /dev/sda5 tmp
cd tmp/home/alaa
4- Finally we restore the MBR image with this command:
dd of=/dev/sda if=Sonyvaio-MBR.bkp  bs=512 count=1

My Twitter Friends

asscert
sunilbhatia79
securityvibesuk
cashflowec
ErisDS
virusexperts
terminusdv
digininja
_defcon_
bensonk42
sarahsharp
funtoo
auspicatus
GaiussOblog
security_inci
pmo
DoubleDragonIII
Hyde_Ciel
oktet8
nmap
Friends: 179 Followers: 196

My Tweets

  • i was trying to deactivate my twitter account, after i saw the crying bird and what twitter team wrote, i reconsidered deactivating. 21 hrs ago
  • Just deactivated my Facebook account .. 21 hrs ago
  • ما في نجوم ما بدا قمر ومافي ليل ما بدو سهر ومافي عيون ما فيها نظر بالغرام 1 day ago
  • Going to Lattakia for few days ... 1 day ago
  • More updates...

Powered by Twitter Tools