what command to restore if the boot block is corrupted in
linux
Answer / 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 |
What is the Difference between Broadcaste Domain and Collison Domain and where it is used ?
2 Answers DataCraft, DataGraph,
Which file is used to define host-wide aliases ?
Your previous Network Administrator had subnneted your class C network into many subnets. Only info you have is that one of the IP range was 200.252.144.33 through 128.252.144.46. How many subnets did he make ? what was the mask ?
How frequent the STP information will be exchanged
Define firewalls?
How dynamic host configuration protocol aid in network administration?
what is the difference between gsm and cdma
You have a class C subnet. You would like to divide it up into 10 more Subnets by "subnetting" . How many hosts can you have per subnet?
What routing problems have you troubleshot?
If a switch has been configured with two vlans, how many broadcast domains will be there
What is nat?
Explain how to identify the ip class of a given ip address?