How to prevent dd from freezing the system

ddio

I want to fill the free space on my hard drive with a command like that :

# dd if=/dev/zero of=z

but it causes GNOME to freeze regularly for a few seconds. Even the mouse cursor is affected.

How can I prevent dd from freezing the interface when writing huge amounts of data ?

Best Answer

Try using ionice:

# ionice -c3 dd if=/dev/zero of=z

This start the dd process with the "idle" IO priority: it only gets disk time when no other process is using disk IO for a certain amount of time.

Of course this can still flood the buffer cache and cause freezes while the system flushes out the cache to disk. There are tunables under /proc/sys/vm/ to influence this, particularly the dirty_* entries.

It also depends on the disk scheduling algorithm, CFQ is best for this.

Related Question