设为首页收藏本站

ZMX - IT技术交流论坛 - 无限Perfect,追求梦想 - itzmx.com

 找回密码
 注册论坛

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

用百度帐号登录

只需两步,快速登录

搜索
查看: 17|回复: 0

linux dd命令不同bs区块对写入SSD固态磁盘io性能的影响,1MB最占优势,DD包安装速度优化

[复制链接]
 成长值: 495

签到天数: 5151 天

[LV.Master]伴坛终老

发表于 2026/2/10 03:17 | 显示全部楼层 |阅读模式 |Google Chrome 144.0.0.0|Windows 10
天涯海角搜一下: 百度 谷歌 360 搜狗 有道 雅虎 必应 即刻
linux dd命令不同bs区块对写入SSD固态磁盘io性能的影响,1MB最占优势,DD包安装速度优化

测试命令,不加bs参数的情况,默认值是0.5K,也就是512字节
  1. dd if=/dev/zero of=test count=1K oflag=dsync
  2. dd if=/dev/zero of=test bs=4K count=1K oflag=dsync
  3. dd if=/dev/zero of=test bs=128K count=1K oflag=dsync
  4. dd if=/dev/zero of=test bs=1M count=1K oflag=dsync
  5. dd if=/dev/zero of=test bs=8M count=128 oflag=dsync
复制代码


结论:SSD固态磁盘的时候,1MB区块速度最快,猜测和CPU的L3缓存有关系,8M比较巨大无法缓存所以io速度反而降低了不少
机械磁盘的时候反而是8MB才勉强起来速度,16MB区块才能达到机械硬盘的写入峰值
很多dd包教程命令都没带bs参数,这个是一定要带的,否则dd过程的时候看服务器给的Graphs数据,无bs参数情况下会发生5K iops左右的读,CPU还一直吃满,明明wget的服务器很快,但是dd需要1到2小时,这就是没加 bs=1M 导致的
一旦使用 bs=1M 后,磁盘io就不会发生读现象了,DD只会进行数据解压写入到磁盘,gzip的单线程解压速度一般是150MB/s左右,这时候大概2分钟就能完成一台设备DD包安装,参考正确的DD命令
rescue救援模式下使用
wget -O- http://文件地址.vhd.gz | gunzip | dd of=/dev/vda bs=1M


测试机器1
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                4
On-line CPU(s) list:   0-3
Thread(s) per core:    2
Core(s) per socket:    2
Socket(s):             1
NUMA node(s):          1
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 94
Model name:            Intel(R) Xeon(R) CPU E3-1275 v5 @ 3.60GHz
Stepping:              3
CPU MHz:               3599.953
BogoMIPS:              7199.90
Hypervisor vendor:     Microsoft
Virtualization type:   full
L1d cache:             32K
L1i cache:             32K
L2 cache:              256K
L3 cache:              8192K
NUMA node0 CPU(s):     0-3
[root@www ~]# dd if=/dev/zero of=test count=1K oflag=dsync
记录了1024+0 的读入
记录了1024+0 的写出
524288字节(524 kB)已复制,3.12447 秒,168 kB/秒
[root@www ~]# dd if=/dev/zero of=test bs=4K count=1K oflag=dsync
记录了1024+0 的读入
记录了1024+0 的写出
4194304字节(4.2 MB)已复制,3.17382 秒,1.3 MB/秒
[root@www ~]# dd if=/dev/zero of=test bs=128K count=1K oflag=dsync
记录了1024+0 的读入
记录了1024+0 的写出
134217728字节(134 MB)已复制,4.86477 秒,27.6 MB/秒
[root@www ~]# dd if=/dev/zero of=test bs=1M count=1K oflag=dsync
记录了1024+0 的读入
记录了1024+0 的写出
1073741824字节(1.1 GB)已复制,9.32242 秒,115 MB/秒
[root@www ~]# dd if=/dev/zero of=test bs=8M count=128 oflag=dsync
记录了128+0 的读入
记录了128+0 的写出
1073741824字节(1.1 GB)已复制,9.53983 秒,113 MB/秒
[root@www ~]#


测试机器2
Architecture:                x86_64
  CPU op-mode(s):            32-bit, 64-bit
  Address sizes:             40 bits physical, 48 bits virtual
  Byte Order:                Little Endian
CPU(s):                      2
  On-line CPU(s) list:       0,1
Vendor ID:                   GenuineIntel
  BIOS Vendor ID:            QEMU
  Model name:                Intel Xeon Processor (Skylake, IBRS, no TSX)
    BIOS Model name:         NotSpecified  CPU @ 2.0GHz
    BIOS CPU family:         1
    CPU family:              6
    Model:                   85
    Thread(s) per core:      1
    Core(s) per socket:      2
    Socket(s):               1
    Stepping:                4
    BogoMIPS:                4599.99
Virtualization features:     
  Hypervisor vendor:         KVM
  Virtualization type:       full
Caches (sum of all):         
  L1d:                       64 KiB (2 instances)
  L1i:                       64 KiB (2 instances)
  L2:                        8 MiB (2 instances)
  L3:                        16 MiB (1 instance)
root@rescue ~ # dd if=/dev/zero of=test count=1K oflag=dsync
1024+0 records in
1024+0 records out
524288 bytes (524 kB, 512 KiB) copied, 0.00297515 s, 176 MB/s
root@rescue ~ # dd if=/dev/zero of=test bs=4K count=1K oflag=dsync
1024+0 records in
1024+0 records out
4194304 bytes (4.2 MB, 4.0 MiB) copied, 0.0143906 s, 291 MB/s
root@rescue ~ # dd if=/dev/zero of=test bs=128K count=1K oflag=dsync
1024+0 records in
1024+0 records out
134217728 bytes (134 MB, 128 MiB) copied, 0.0919815 s, 1.5 GB/s
root@rescue ~ # dd if=/dev/zero of=test bs=1M count=1K oflag=dsync
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 0.540522 s, 2.0 GB/s
root@rescue ~ # dd if=/dev/zero of=test bs=8M count=128 oflag=dsync
128+0 records in
128+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 0.960251 s, 1.1 GB/s
root@rescue ~ #
[发帖际遇]: 小樱 在论坛发帖时没有注意,被小偷偷去了 3 樱币. 幸运榜 / 衰神榜
欢迎光临IT技术交流论坛:http://bbs.itzmx.com/
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册论坛 新浪微博账号登陆用百度帐号登录

本版积分规则

手机版|Archiver|Mail me|网站地图|IT技术交流论坛 ( 闽ICP备13013206号-7 )

GMT+8, 2026/2/10 07:02 , Processed in 0.092674 second(s), 20 queries , MemCache On.

Powered by itzmx! X3.4

© 2011- sakura

快速回复 返回顶部 返回列表