Which of the following commands overwrites the bootloader located on /dev/sda without overwriting the partition table or any data following it?

A.

dd if=/dev/zero of=/dev/sda bs=512

B.

dd if=/dev/zero of=/dev/sda bs=512 count=1

C.

dd if=/dev/zero of=/dev/sda bs=440 count=1

D.

dd if=/dev/zero of=/dev/sda bs=440

题解

「dd」指令搭配「count」参数才可以限制写入的次数,否则会读写完所有输入来源的数据。「bs」参数为每次写入的字节数量。

MBR (Master Boot Record)在硬盘的第一个磁区(512 bytes),前 446 bytes 为 Boot Loader;接下来的 64 bytes 是 Partition Table,可以纪录 4 笔数据;最后的 2 bytes 是 Verify Data。

若要覆盖 Boot Loader,写入的范围不能超过前 446 bytes,否则会动到之后的 Partition Table。选项 C 只会写入 1 次 440 bytes,Boot Loader 的代码主要就放在前 440 bytes(第 441 ~ 446 bytes 在现在的 MBR 中是用来存放磁盘签章等数据),所以答案是选项 C。