Fastest way to write to a disk

I'm trying to fill up a disk drive with random data (3TB). Mainly to overwrite the whole disk with gibberish, but also for the fun of doing it myself.
I'm aware that there are plenty of programs for that.

So I was wondering what would be the fastest method of writing data.
Currently I just use std::fstream. I get about 100MB per second, the buffer size for each call to fstream::write() is 512kB (currently).

I didn't play around with different buffer sizes, yet, and I'm not sure how the OS buffering interferes with the writing of large amounts of data.
Can I control the buffering in any way? Should I?

Should I use a different method/lib/API ?
Try using the native OS routines. The standard library tends to have terrible I/O performance.
call the disk driver interfaces directly, no cache, no filesystem, all sectors would be overwritten without mid-steps, that would be quick enough.
Topic archived. No new replies allowed.