AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / unix / 问题 / 790680
Accepted
gcb
gcb
Asked: 2025-02-07 00:50:17 +0800 CST2025-02-07 00:50:17 +0800 CST 2025-02-07 00:50:17 +0800 CST

我应该在 LUKS 中使用物理还是逻辑扇区大小?

  • 772

我有一个外部硬盘 (不是固态硬盘),它报告:

Sector Sizes:     512 bytes logical, 4096 bytes physical

我应该使用 --sector-size 512还是 --sector-size 4096使用cryptosetup LuksFormat?使用默认参数(不确定它是否会尝试自动检测或始终使用 512)最终得到 512。

如果重要的话,设置将是[disk]->[gpt]->[physical partition]->[LUKSv2]->[btrfs]


继续使用这两种方式来收集基准:

512

# sysbench fileio prepare
2147483648 bytes written in 34.28 seconds (59.75 MiB/sec).

# sysbench fileio --file-test-mode=rndrw run
Extra file open flags: (none)
128 files, 16MiB each
2GiB total file size
Block size 16KiB
Number of IO requests: 0
Read/Write ratio for combined random IO test: 1.50
Periodic FSYNC enabled, calling fsync() each 100 requests.
Calling fsync() at the end of test, Enabled.
Using synchronous I/O mode
Doing random r/w test
Initializing worker threads...

Threads started!


File operations:
    reads/s:                      14.42
    writes/s:                     9.62
    fsyncs/s:                     31.25

Throughput:
    read, MiB/s:                  0.23
    written, MiB/s:               0.15

General statistics:
    total time:                          12.4778s
    total number of events:              562

Latency (ms):
         min:                                    0.00
         avg:                                   17.84
         max:                                  365.73
         95th percentile:                       84.47
         sum:                                10024.98

Threads fairness:
    events (avg/stddev):           562.0000/0.00
    execution time (avg/stddev):   10.0250/0.00


# sysbench fileio --file-test-mode=seqrewr run
Extra file open flags: (none)
128 files, 16MiB each
2GiB total file size
Block size 16KiB
Periodic FSYNC enabled, calling fsync() each 100 requests.
Calling fsync() at the end of test, Enabled.
Using synchronous I/O mode
Doing sequential rewrite test
Initializing worker threads...

Threads started!


File operations:
    reads/s:                      0.00
    writes/s:                     815.93
    fsyncs/s:                     1045.19

Throughput:
    read, MiB/s:                  0.00
    written, MiB/s:               12.75

General statistics:
    total time:                          10.0488s
    total number of events:              18576

Latency (ms):
         min:                                    0.00
         avg:                                    0.54
         max:                                  433.66
         95th percentile:                        0.02
         sum:                                 9996.57

Threads fairness:
    events (avg/stddev):           18576.0000/0.00
    execution time (avg/stddev):   9.9966/0.00

4096年

# sysbench fileio prepare
2147483648 bytes written in 28.85 seconds (70.99 MiB/sec).


# sysbench --test=fileio --file-test-mode=rndrw run
File operations:
    reads/s:                      26.17
    writes/s:                     17.45
    fsyncs/s:                     58.35

Throughput:
    read, MiB/s:                  0.41
    written, MiB/s:               0.27

General statistics:
    total time:                          11.4636s
    total number of events:              1041

Latency (ms):
         min:                                    0.00
         avg:                                    9.63
         max:                                  370.49
         95th percentile:                       44.98
         sum:                                10021.97

Threads fairness:
    events (avg/stddev):           1041.0000/0.00
    execution time (avg/stddev):   10.0220/0.00



# sysbench fileio --file-test-mode=seqrewr run
File operations:
    reads/s:                      0.00
    writes/s:                     1229.02
    fsyncs/s:                     1574.44

Throughput:
    read, MiB/s:                  0.00
    written, MiB/s:               19.20

General statistics:
    total time:                          10.0071s
    total number of events:              27929

Latency (ms):
         min:                                    0.00
         avg:                                    0.36
         max:                                  471.49
         95th percentile:                        0.02
         sum:                                 9997.75

Threads fairness:
    events (avg/stddev):           27929.0000/0.00
    execution time (avg/stddev):   9.9978/0.00

对于人工小文件,4K 的读取速度似乎快两倍,写入速度快 0.25 倍。


另一次编辑。进行了同样的测试,但复制了 110G 的文件包,大小从 2.5Mb(95%tile)到 300Mb 不等。

512 和 4096 格式化驱动器均耗时 20 分 30 秒 +-4 秒

filesystems
  • 1 1 个回答
  • 41 Views

1 个回答

  • Voted
  1. Best Answer
    Stephen Harris
    2025-02-07T02:41:15+08:002025-02-07T02:41:15+08:00

    具有 4K 扇区但报告 512 字节逻辑扇区的磁盘称为“高级格式”(AF) 驱动器。它们模拟512 字节扇区。但它们以低效的方式执行此操作;例如,要写出 512 字节扇区,驱动器必须读取现有的 4k 数据,更新必要的数据,然后写出结果。这是一个额外的“读取”步骤,如果写出 4K 扇区,则不需要此步骤。

    您可以在测试中看到结果;4K 测试速度要快得多。

    注意,这也适用于对磁盘进行分区fdisk;确保您的分区是 4K 对齐的,否则操作系统的每次写入都可能影响 2 个扇区! 类似工具会警告这种错位。

    使用 4K 扇区的缺点是,您最终可能会失去有用的空间;例如,如果您创建一个 300 字节的文件,它将占用磁盘上的 4K,而使用 512 字节扇区则仅占用 512 字节。我认为这是速度优势的公平权衡。

    因此,对于您而言,我会使用带有 cryptsetup 的 4K 扇区。

    • 1

相关问题

  • 我应该在 NAS 的 SD 卡中使用哪个文件系统?

  • 如何提前知道 .zip 内部是否有父目录

  • Virtualbox 动态分配磁盘 *.vdi 不断增长

  • du/df 和 ls 报告不同的磁盘使用情况

  • Linux 内核开发人员如何处理数百万行代码的工作?他们是一种方法吗?[关闭]

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    模块 i915 可能缺少固件 /lib/firmware/i915/*

    • 3 个回答
  • Marko Smith

    无法获取 jessie backports 存储库

    • 4 个回答
  • Marko Smith

    如何将 GPG 私钥和公钥导出到文件

    • 4 个回答
  • Marko Smith

    我们如何运行存储在变量中的命令?

    • 5 个回答
  • Marko Smith

    如何配置 systemd-resolved 和 systemd-networkd 以使用本地 DNS 服务器来解析本地域和远程 DNS 服务器来解析远程域?

    • 3 个回答
  • Marko Smith

    dist-upgrade 后 Kali Linux 中的 apt-get update 错误 [重复]

    • 2 个回答
  • Marko Smith

    如何从 systemctl 服务日志中查看最新的 x 行

    • 5 个回答
  • Marko Smith

    Nano - 跳转到文件末尾

    • 8 个回答
  • Marko Smith

    grub 错误:你需要先加载内核

    • 4 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Martin Hope
    user12345 无法获取 jessie backports 存储库 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl 为什么大多数 systemd 示例都包含 WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll systemctl 状态显示:“状态:降级” 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim 我们如何运行存储在变量中的命令? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S 为什么 /dev/null 是一个文件?为什么它的功能不作为一个简单的程序来实现? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 如何从 systemctl 服务日志中查看最新的 x 行 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - 跳转到文件末尾 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla 为什么真假这么大? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve