Fixing error mounting EBS volume: “appears to contain a partition table (dos).”

If you mount an EBS volume and try to format it, you may get an error like so:

mkfs -t xfs /dev/xvdcz
mkfs.xfs: /dev/xvdcz appears to contain a partition table (dos).
mkfs.xfs: Use the -f option to force overwrite.

This command (mkfs) is a bit confusing, because if you look at the man pages there is no “-f” argument. In fact, it appears to be a proxy for another command which has more options, so the solution is to call that directly and add the -f, i.e.:

mkfs.xfs -f /dev/xvdcz