what command to restore if the boot block is corrupted in
linux

Answer Posted / mohammed sajjad

Scenario 1: Backup the boot sector (or MBR)
If the first harddisk in the system is /dev/sda, to backup the boot sector the following command can be used:

# dd if=/dev/sda of=bsbackup.bin bs=512 count=1

Essentially this command will read the first 512 bytes of /dev/sda and write it to the file bsbackup.bin.
Scenario 2: Restore the boot sector from a file:

# dd if=bsbackup.bin of=/dev/sda bs=512 count=1

This will restore the boot sector to /dev/sda that was backed up in Scenario 1.
Scenario 3: Zero out the boot sector (leaving the partition table intact)
Sometimes a virus or other issue can leave a corrupted executable code section in the MBR. I have personally seen a boot sector that would not store grub information (and thus boot linux after its installed) properly until the first 446 bytes were zeroed out and grub re-installed. The following command will do just that:

# dd if=/dev/zero of=/dev/sda bs=446 count=1

Scenario 4: Zero out the entire MBR (this will erase the partition table as well – effectively destroying the ability to easily access data on the drive)
A variation of the last dd command will wipe out the master boot record entirely. You will have to repartition and reformat your hard disk after this:

Is This Answer Correct ?    1 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

User Datagram Protocol (UDP) is __ and __ a. connectionless, stateless b. connection-orineted, stateless c. connection-oriented, stateful d. connectionless, stateful

1307


What platforms do you currently work on at your desk?

1521


when affected the system from virus , which paths will be it stored in system ?

1423


List the advantage of address sharing?

610


Define the role of ieee in computer networking?

598






Suppose if a network which contains two servers and twenty workstations, where is the best place to install an anti-virus program?

571


When you connect two redundant links of switch to hub to form a loop , and when the switch receives its own BPDU what it will do.

3634


Define dos?

592


How to securing a computer network?

598


What is the behavior of the L2 Switch in case of receiving a multicast packet.

1575


Define rip?

710


Which application protocol can not be blocked by the Switch?

2442


Define rsa algorithm?

681


How to delete software errors? What is that?

1541


Do you know what protocols fall under the tcp/ip internet layer?

574