Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have hunch that a certain intermittent bug might only manifest itself when there is a slow disk read rate. Troubleshooting is difficult because I can't reliably reproduce it.

Short of simply gobbling IO with a high priority process, is there any way for me to simulate having a slow hard drive?

share|improve this question
I remember seeing a command to tell harddrives to run at certain bus speeds. I'll see if I can dig it out. – Jeremy Nov 17 '10 at 1:22
man hdparm take a look at the -X option maybe? There are quite a few things in there you could use to slow down your drive, but some of them risk doing nasty things to the data! – Jeremy Nov 17 '10 at 1:27
Also, try mounting a network share as a folder (google is your friend), maybe even over wifi, if that is plausible. – Jeremy Nov 17 '10 at 1:27
This isn't a direct answer, but: if I had an intermittent bug like this, I would probably try running the process under Valgrind (if it was in a compiled language), because that would likely capture IO race conditions. – poolie Nov 17 '10 at 21:55
Are you talking about a bug in an application, or the kernel, or a device driver? Or you don't know at all? It might help if you explained more. – poolie Nov 18 '10 at 1:29
up vote 12 down vote accepted

Use nbd, the Network Block Device, and then rate limit access to it using say trickle.

sudo apt-get install nbd-client nbd-server trickle
share|improve this answer
+1 for a pretty cool solution. however, it's not a real test because you not going to the real hard disk device driver, which where the problem may lie. – user5883 Nov 18 '10 at 1:01
I didn't think he was talking about a driver bug, but that was just an assumption. Let's see. – poolie Nov 18 '10 at 1:30
Is it possible to add the actual command to this answer? At the moment you only show how to install the tools required :) – Rich Sep 18 '15 at 7:33

Have a USB 1.1 hub? Or a slow SD card? They'll get you down to under 10mbps.

share|improve this answer
nice...not technical enough for the +1 but nice – RobotHumans Nov 17 '10 at 2:32
# echo 1 > /proc/sys/vm/drop_caches

That'll slow you down :)

It'll force you to read from disk, instead of taking advantage of the cached page.

If you really wanted to get sophisticated you could do something like fake a read error every nth time using the scsi fault injection framework.

share|improve this answer
+1 for coolness! – user5883 Nov 18 '10 at 15:37

This is by no means a complete solution, but it may help in conjunction with other measures: There is an I/O scheduler much like a process scheduler, and it can be tweaked.

Most notably, you can actually choose amongst different schedulers:

~# cat /sys/block/sda/queue/scheduler 
noop anticipatory deadline [cfq] 
~# echo "deadline" > /sys/block/sda/queue/scheduler
~# cat /sys/block/sda/queue/scheduler 
noop anticipatory [deadline] cfq 

deadline may help you get more strongly reproducible results.

noop, as its name implies, is insanely dumb, and will enable you to wreck absolute havoc on I/O performance with little effort.

anticipatory and cfq both try to be smart about it, though cfq is generally the smarter of the two. (As I recall, anticipatory is actually the legacy scheduler from right before the kernel started supporting multiple schedulers.)

share|improve this answer

Apart from trying to slow down the hard drive itself, you could try using filesystem benchmarking tools such as bonnie++ Install bonnie++ which can cause a great deal of disk I/O.

share|improve this answer
As the question says, "Short of simply gobbling IO".... – poolie Sep 18 '15 at 21:10

You could try running a copy of a large file, such as an iso of the Ubuntu install cd, and run it twice. That should slow your drive down quite a bit.

share|improve this answer
As the question says, "Short of simply gobbling IO".... – poolie Sep 18 '15 at 21:10

You can use a Virtual Machine and throttle disk access ... here are some tips about how do it in Virtualbox 5.8. Limiting bandwidth for disk images

share|improve this answer

how about make -j64? in articles describing that new 200line performance patch, make -j64 was a task eating a lot of computer resources

share|improve this answer
You should explain what that command actually does. – papukaija Feb 20 '11 at 22:21
As the question says, "Short of simply gobbling IO".... – poolie Sep 18 '15 at 21:10

Why not run iotop and see if the process that you are trying to debug is causing lots of disk reads/writes?

share|improve this answer
I think this answer is seen as unhelpful because the mere fact that the process is doing lots of IO may be already known, or not a problem in itself. The issue is that there is some kind of timing-related bug in the way it handles those IOs. – poolie Nov 17 '10 at 21:54

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.