Before I sell an old HDD I completely read and write the disk to verify that it has no bad sectors.
I always did writing like this:
dd if=/dev/zero of=/dev/sdb bs=100M status=progress
But my computer has 32GB RAM and a lot of the data might be in cache when dd exits.
Is there a way to see when the OS fails to write the cache to the disk (after dd terminated)?
What is the right option for dd to to flush the cache before exiting? sync, fsync or fdatasync?
Please don't suggest disk checking tools. dd is enough for me.