dd is a native linux command also available on XenServer that can be used to measure the performance of a block device like /dev/sda at a block level. We can use this command to troubleshoot storage performance issues within the Host as well as the guest while clubbing it with other tools like iostat, vmstat
Caution: Please use dd with care as interchanging the if and of can cause disk corruptions
# dd if=/dev/sda of=/dev/zero
We can specify block size for read by adding the block size parameter bs
# dd if=/dev/sda of=/dev/zero bs=1M
Sample output will be like
# dd if=/dev/sda of=/dev/zero ^C25577+0 records in 25576+0 records out 13094912 bytes (13 MB) copied, 1.46965 s, 8.9 MB/s
Here we can see it copied 13 MB at a rate 8.9 MB/s
To measure write performance of a disk , we can use the below command to write a file named testfile of 1 GB under /root which is on device sda
# dd if=/dev/zero of=/root bs=1M count=1024
Sample output like
dd if=/dev/zero of=/root/testfile bs=1M count=1024 1024+0 records in 1024+0 records out 1073741824 bytes (1.1 GB) copied, 12.9848 s, 82.7 MB/s
Here we can see it took 12 seconds to create a 1 GB file at 82.7 MB/s
In order to bypass the filesystem cache we can use oflag
# dd if=/dev/zero of=/root/testfile bs=1M count=1024 oflag=direct