Reformating hard drive after malware damaged boot sector

Solution 1:

Wipe the boot sector

If you suspect that the boot sector is infected with malware, you can use hdparm but need not use such a basic or powerful tool. The boot sector is available via 'regular' tools, that can write to a mass storage device, for example dd or Disks alias gnome-disks, or mkusb.

hdparm and dd are powerful but risky tools. Disks and mkusb provide safer conditions because they help you identify the target drive and double check, that you are wiping the correct drive (and not a drive, where you have important data).

It is enough to wipe the first few bytes, but wiping the first mibibyte will be enough for this purpose as well as removing other data that might disturb or confuse the function of partitioning tools like gparted. There is a menu entry for this task in mkusb. You may want to wipe the whole drive (if you suspect that there is other malware somewhere in the drive), and there is also a menu entry for that task.

enter image description here

Low level wiping

Maybe you did not create a correct low level format with hdparm. You can try again, for example according to the instructions in the following link,

Re: best way to wipe a drive

It is probably easier to succeed with DBAN, that you can find via the following link,

dban.org/

It works well enough for this purpose with the free version.

Maybe the disk hardware is damaged

Maybe there is some serious damage (for example physical damage), that makes the drive fail. See this link (some of the tips but not all of them are relevant for hard disk drives),

Can't format my usb drive ... Analysis of the problem

It is a good idea to check the S.M.A.R.T. information about the drive's health status for example via Disks alias gnome-disks. Select S.M.A.R.T. via the button at (1) and check the overall assessment at (2).

enter image description here