create containers for blkio disk speed test
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 15 May 2011 00:08:10 +0000 (00:08 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 15 May 2011 00:08:10 +0000 (00:08 +0000)
git-svn-id: svn://svn.rot13.org/sysadmin-cookbook@262 191e9f34-6774-4a6d-acfc-7664dacd4a2a

recepies/lxc/kvm/10-cgroup-blkio/disk-speed.sh [new file with mode: 0644]

diff --git a/recepies/lxc/kvm/10-cgroup-blkio/disk-speed.sh b/recepies/lxc/kvm/10-cgroup-blkio/disk-speed.sh
new file mode 100644 (file)
index 0000000..839647a
--- /dev/null
@@ -0,0 +1,26 @@
+#!/bin/sh -xe
+
+lxc-ls | xargs -i sh -c "lxc-stop -n {} ; lxc-destroy -n {}"
+
+echo "lxc.network.type = empty" > blkio.conf
+
+PATH=$(pwd):$PATH lxc-create -f blkio.conf -t busybox -n disk1
+PATH=$(pwd):$PATH lxc-create -f blkio.conf -t busybox -n disk2
+PATH=$(pwd):$PATH lxc-create -f blkio.conf -t busybox -n disk3
+
+lxc-ls | xargs -i dd if=/dev/zero of=/var/lib/lxc/{}/rootfs/tmp/zero bs=1M count=100
+
+cat > /tmp/speed.sh <<EOF
+#!/bin/sh
+while true ; do
+       sync ; echo 3 > /proc/sys/vm/drop_caches
+       dd if=/tmp/zero of=/dev/null 2>&1
+done | grep MB
+EOF
+
+chmod +x /tmp/speed.sh
+
+lxc-ls | xargs -i cp /tmp/speed.sh /var/lib/lxc/{}/rootfs/tmp/speed.sh
+
+lxc-ls | xargs -i lxc-start -d -n {}
+