Linux Tutorials - Herong's Tutorial Examples - v5.45, by Herong Yang
Use "dd" Command to Test I/O Speed
This section provides a tutorial example on how to test I/O speed of hard disk and USB drives using the 'dd' command with different block sizes.
The "dd (data duplicator)" command can also be used to measure I/O (Input/Output) speed of a given storage device.
Tests on my CentOS 8.0 computer
1. Test input (writing) speed of the internal hard disk. I see that bigger block size (bs) is more efficient when writing to the hard disk.
herong$ pwd /home/herong herong$ dd if=/dev/zero of=one-giga bs=64k count=16k 16384+0 records in 16384+0 records out 1073741824 bytes (1.1 GB, 1.0 GiB) copied, 0.255833 s, 4.2 GB/s herong$ dd if=/dev/zero of=one-giga bs=1k count=1024k 1048576+0 records in 1048576+0 records out 1073741824 bytes (1.1 GB, 1.0 GiB) copied, 1.98674 s, 540 MB/s herong$ ls -l one* -rw-rw-r--. 1 herong herong 1073741824 Apr 5 03:23 one-giga
2. Test output (reading) speed of the internal hard disk. I see that bigger block size (bs) is more efficient when reading from the hard disk. I also see that reading is two times slower than writing, which is a little surprise to me.
herong$ dd if=one-giga of=/dev/null bs=64k count=16k 16384+0 records in 16384+0 records out 1073741824 bytes (1.1 GB, 1.0 GiB) copied, 0.113039 s, 9.5 GB/s herong$ dd if=one-giga of=/dev/null bs=1k count=1024k 1048576+0 records in 1048576+0 records out 1073741824 bytes (1.1 GB, 1.0 GiB) copied, 1.18922 s, 903 MB/s
3. Test input (writing) speed of a USB drive. I see that the input speed on USB drive is about the same as the hard disk with block size of 1 KB, which is a little surprise to me.
(USB drive is mounted on /media) herong$ df /dev/sdc1 Filesystem 1K-blocks Used Available Use% Mounted on /dev/sdc1 7813124 1146116 6667008 15% /media herong$ cd /media herong$ sudo dd if=/dev/zero of=one-giga bs=64k count=16k 16384+0 records in 16384+0 records out 1073741824 bytes (1.1 GB, 1.0 GiB) copied, 0.937841 s, 1.1 GB/s herong$ sudo dd if=/dev/zero of=one-giga bs=1k count=1024k 1048576+0 records in 1048576+0 records out 1073741824 bytes (1.1 GB, 1.0 GiB) copied, 2.12935 s, 504 MB/s
4. Test output (reading) speed of the same USB drive. I see that the output speed on USB drive is about the same as the hard disk for both large and small block sizes, which is a little surprise to me.
herong$ dd if=one-giga of=/dev/null bs=64k count=16k 16384+0 records in 16384+0 records out 1073741824 bytes (1.1 GB, 1.0 GiB) copied, 0.115699 s, 9.3 GB/s herong$ dd if=one-giga of=/dev/null bs=1k count=1024k 1048576+0 records in 1048576+0 records out 1073741824 bytes (1.1 GB, 1.0 GiB) copied, 1.13126 s, 949 MB/s
Tests on my macOS 10 computer
1. Test input (writing) speed of the internal hard disk. I see that the input speed of my macOS hard disk is much slower that my CentOS computer.
herong$ pwd /Users/herong herong$ dd if=/dev/zero of=one-giga bs=64k count=16k 16384+0 records in 16384+0 records out 1073741824 bytes transferred in 0.741450 secs (1,448,164,705 bytes/sec) herong$ dd if=/dev/zero of=one-giga bs=1k count=1024k 1048576+0 records in 1048576+0 records out 1073741824 bytes transferred in 4.046084 secs (265,378,040 bytes/sec)
2. Test output (reading) speed of the internal hard disk. I see that the output speed is much faster than input speed, which makes sense.
herong$ dd if=one-giga of=/dev/null bs=64k count=16k 16384+0 records in 16384+0 records out 1073741824 bytes transferred in 0.218341 secs (4,917,726,275 bytes/sec) herong$ dd if=one-giga of=/dev/null bs=1k count=1024k 1048576+0 records in 1048576+0 records out 1073741824 bytes transferred in 2.320591 secs (462,701,888 bytes/sec)
3. Test input (writing) speed of the same USB drive. I see that the input speed on the same USB drive on macOS is about 200 times slower than than CentOS. I think the main cause of the speed drop is the USB to USB-C cable used to connect the USB drive.
(USB drive is auto mounted on /Volumes/NO NAME) herong$ df Filesystem 512-blocks Used Available Capacity Mounted on ... /dev/disk3s1 15626248 2294808 13331440 15% /Volumes/NO NAME herong$ cd '/Volumes/NO NAME' herong$ sudo dd if=/dev/zero of=one-giga bs=64k count=16k 16384+0 records in 16384+0 records out 1073741824 bytes transferred in 214.298787 secs (5,010,490 bytes/sec) herong$ sudo dd if=/dev/zero of=one-giga bs=1k count=1024k 1048576+0 records in 1048576+0 records out 1073741824 bytes transferred in 208.157021 secs (5,158,326 bytes/sec)
4. Test output (reading) speed of the same USB drive. I see that the output speed on USB drive is about 600 times faster than the input speed, which is a big surprise to me.
herong$ dd if=one-giga of=/dev/null bs=64k count=16k 16384+0 records in 16384+0 records out 1073741824 bytes transferred in 0.353298 secs (3,039,196,314 bytes/sec) herong$ dd if=one-giga of=/dev/null bs=1k count=1024k 1048576+0 records in 1048576+0 records out 1073741824 bytes transferred in 2.318289 secs (463,161,373 bytes/sec)
Table of Contents
Cockpit - Web Portal for Administrator
"df" - Display Free Space of File System
Mount USB Drive as File System
"dd" - Copy Data from/to Storage Devices
►Use "dd" Command to Test I/O Speed
"du" - Display Disk Usage of Directories
Mount Windows NTFS File System
Access Persmissions on "ntfs-3g" File System
Reformat NTFS Partition into EXT4 Partition
Mount NFS (Network File System) on macOS
/etc/mtab and /etc/fstab Files
Unreachable Remote File Systems
SELinux - Security-Enhanced Linux
SSH Protocol and ssh/scp Commands
Software Package Manager on CentOS - DNF and YUM
vsftpd - Very Secure FTP Daemon