dd saturating disk I/O
Today I was in need of pre-allocating a 50G file on a number of CC‘s servers. I started off with this:
# dd if=/dev/zero of=bigfile.bin bs=1M count=50000
However, that operation was too expensive in terms of disk I/O and was causing critical web services to fail. I played around with multiple options in dd but to no avail. I finally ended up doing this, which works, but seems rather ridiculous. Surely there’s a better way to do it:
# for i in $(seq 1 50000); do nice -n 19 dd if=/dev/zero of=bigfile.bin conv=notrunc oflag=append bs=1M count=1 &> /dev/null && sleep 0.1; done
The nice probably isn’t necessary, but I threw it in for good measure.