Simulating a slow disk with nbd
roger peppe
rogpeppe at gmail.com
Mon Sep 8 10:29:25 UTC 2014
On 6 September 2014 02:11, Michael Hudson-Doyle
<michael.hudson at canonical.com> wrote:
> Michael Foord <michael.foord at canonical.com> writes:
>
>> Hey all,
>
> Nice trick!
>
>> I've been diagnosing some replicaset issues that particularly show up on
>> systems with slow disks, particularly our CI infrastructure. To simulate
>> a slow disk I've been using nbd (Network block device [1]), with
>> trickle. This provides a "remote mounted" disk (actually local served
>> over the loopback) that is rate limited. I then run the tests inside an
>> lxc container with its filesystem on the rate limited disk.
>>
>> Getting this working was tricky, so I thought I'd share the information.
>> In particular I couldn't get nbd-server to read a configuration file, so
>> I force it to skip loading the config file and specify the parameters at
>> the command line. This is deprecated, but works fine.
>>
>> The sequence of commands to create the nbd drive and create / start the
>> lxc container are as follows:
>>
>> sudo apt-get install trickle nbd-server nbd-client
>>
>> # create a 10GB file to act as the disk.
>> dd if=/dev/zero of=/path/to/some/file bs=1024 count=10000000
>
> Just one more factoid worth knowing if you are doing this sort of thing:
> you can do this much much much more quickly with "truncate -s 10G
> /path/to/some/file" (on the order of 0.01s vs minutes, and it creates a
> sparse file too...).
For the record, one can also use dd to do that:
dd if=/dev/zero of=/path/to/some/file bs=1024 seek=9999999 count=1
which amounts to much the same thing.
More information about the Juju-dev
mailing list