You don't "erase" as much as "write over" the data on a hard disk.

Your write head "writes" spots on the platter such that some spots are magnetized as though the spot were a magnet with the "south" end up, and other spots were "north" end up.  

To "erase," you write zeroes (or ones) to all the addressable spots on the platter.  This doesn't actually set all the spots to the same direction.  The data you write are encoded in various ways.  All zeroes would probably result in a series of alternating "north up" and "south up" spots.

The whole thing is much more complicated than that, but is based on the ability of the write head to change the magnetic polarity of small spots on the platter.

The write head is an electromagnetic that can make very small (but strong) magnetic fields. Push current through one way and it forces a spot on the platter to magnetize "north up."  Push current through the write head the other way and it forces a spot on the platter to magnetize "south up."  Changing the eletrical polarity of the current through the write head changes the magnetic polarity of the written spot on the platter.

[The Wikipedia page on the technology of hard disks explains it fairly well.](https://en.wikipedia.org/wiki/Hard_disk_drive#Magnetic_recording)  That link goes right to the section on how magnetic recording is done on hard disk drives.

This image from the Wikipedia page shows how data is written:

[![enter image description here][1]][1]

Longitudal recording changes which **direction** is north or south (with or against the rotation direction.)

Perpendicular recording changes whether up or down is north or south - that's the one I used in the explanation above


  [1]: https://i.sstatic.net/akajA.png