使用Badblocks时如何选择正确的参数?


9

我想badblocks用来检查新驱动器中是否有坏块,但是我不确定如何选择块大小和要并行测试的块数的值。手册页只说:

-b block-size 以字节为单位指定块的大小。默认值为1024。

-c number of blocks是一次测试的块数。默认值为64。

要测试的驱动器大2TB,因此我想使用不会使该过程花费几天时间的值。:-)

FWIW,smartmoontools报告:

扇区大小:逻辑512字节,物理4096字节


1
据估计,我已经使用默认选项在2TB驱动器上进行了坏块扫描,大约花费了6个小时。希望有人能帮助您减少这一损失。
克里斯·哈珀

谢谢,听起来还不错(真的:D)。
htorque 2011年

@ root45差不多就可以了。这是92.6 MB / s的持续吞吐量,这是此类驱动器可以做到的最佳性能。
psusi 2011年

Answers:


5

由于驱动器的物理扇区大小为4096字节,因此您想使用-b 4096。我认为-c参数没有太大区别,所以就别管它了。

而且,驱动器的内部SMART测试比badblocks更好和更快,因此使用smartmontools或磁盘实用程序来运行它是一个更好的主意。


好吧,更快...内部长时间的SMART测试将在运行四个小时后的几分钟内完成。将使用4096字节作为块大小,并尝试使用-c选项。
htorque 2011年

最终,SMART测试花费了六个小时。然后,我测试了要并行测试的块数的不同值,它们似乎根本没有影响时间。因此,我认为仅调整块大小是可以的。
htorque's

3

我创建了一个基准测试工具来测试不同的设置。该测试可能需要很长时间才能删除您的数据,因此请谨慎使用。

badblocks_benchmark.sh:

#!/bin/bash

blocks=4194304      # 2^22, must be dividable by 2^8 (max i) = 256
block_size=512

result=""
for i in {1..8}
do
  block_count=1

  for j in {1..18}
  do
    echo -n "Benchmark with block count: $block_count, block size: $block_size: "
    execution_time=`/usr/bin/time 2>&1 -f "%Es" badblocks >/dev/null -w -b $block_size -c $block_count -t random $1 $blocks`
    status=$?
    if [ $status -eq 0 ]; then
      result=`echo -e "$result""\n""$execution_time: badblocks -b $block_size -c $block_count"`
      echo "$execution_time"
    fi

    block_count=$(( $block_count * 2 ))
  done

  block_size=$(( $block_size * 2 ))
  blocks=$(( $blocks / 2 ))
done

echo "Result:"
echo "$result" | sort --numeric-sort

您可以将其用作:

./badblocks_benchmark.sh /dev/sdX

如果要仅用4k块进行基准测试,则:

#!/bin/bash

blocks=4194304      # 2^22, you can use any 2^x number 
block_size=4096

result=""
block_count=1

for j in {1..18}
do
  echo -n "Benchmark with block count: $block_count, block size: $block_size: "
  execution_time=`/usr/bin/time 2>&1 -f "%Es" badblocks >/dev/null -w -b $block_size -c $block_count -t random $1 $blocks`
  status=$?
  if [ $status -eq 0 ]; then
    result=`echo -e "$result""\n""$execution_time: badblocks -b $block_size -c $block_count"`
    echo "$execution_time"
  fi

  block_count=$(( $block_count * 2 ))
done

echo "Result:"
echo "$result" | sort --numeric-sort

根据我的基准,仅使用-b 4096但不使用-c(默认为64)非常好。

我的结果(越小越好):执行时间(以秒为单位)和参数

0:28.50s: badblocks -b 1024 -c 512
0:28.50s: badblocks -b 4096 -c 1024
0:28.50s: badblocks -b 512 -c 1024
0:28.50s: badblocks -b 65536 -c 8
0:28.51s: badblocks -b 2048 -c 1024
0:28.51s: badblocks -b 32768 -c 16
0:28.51s: badblocks -b 65536 -c 128
0:28.51s: badblocks -b 65536 -c 64
0:28.52s: badblocks -b 32768 -c 128
0:28.52s: badblocks -b 65536 -c 4
0:28.52s: badblocks -b 8192 -c 64
0:28.53s: badblocks -b 16384 -c 512
0:28.53s: badblocks -b 16384 -c 8
0:28.53s: badblocks -b 32768 -c 32
0:28.53s: badblocks -b 32768 -c 4
0:28.53s: badblocks -b 32768 -c 64
0:28.53s: badblocks -b 65536 -c 16
0:28.53s: badblocks -b 8192 -c 512
0:28.54s: badblocks -b 4096 -c 256
0:28.54s: badblocks -b 4096 -c 32
0:28.54s: badblocks -b 4096 -c 64
0:28.54s: badblocks -b 8192 -c 128
0:28.55s: badblocks -b 1024 -c 1024
0:28.55s: badblocks -b 1024 -c 256
0:28.55s: badblocks -b 16384 -c 256
0:28.55s: badblocks -b 2048 -c 128
0:28.55s: badblocks -b 2048 -c 64
0:28.55s: badblocks -b 32768 -c 8
0:28.55s: badblocks -b 4096 -c 16
0:28.55s: badblocks -b 512 -c 2048
0:28.55s: badblocks -b 512 -c 256
0:28.55s: badblocks -b 65536 -c 1
0:28.55s: badblocks -b 8192 -c 1024
0:28.55s: badblocks -b 8192 -c 16
0:28.55s: badblocks -b 8192 -c 256
0:28.55s: badblocks -b 8192 -c 32
0:28.56s: badblocks -b 2048 -c 2048
0:28.56s: badblocks -b 512 -c 512
0:28.57s: badblocks -b 1024 -c 64
0:28.57s: badblocks -b 16384 -c 128
0:28.57s: badblocks -b 16384 -c 4
0:28.57s: badblocks -b 16384 -c 64
0:28.57s: badblocks -b 2048 -c 512
0:28.57s: badblocks -b 2048 -c 8192
0:28.57s: badblocks -b 32768 -c 256
0:28.57s: badblocks -b 4096 -c 128
0:28.57s: badblocks -b 4096 -c 2048
0:28.57s: badblocks -b 512 -c 16384
0:28.57s: badblocks -b 65536 -c 32
0:28.57s: badblocks -b 65536 -c 65536
0:28.57s: badblocks -b 8192 -c 8
0:28.58s: badblocks -b 1024 -c 2048
0:28.58s: badblocks -b 1024 -c 4096
0:28.58s: badblocks -b 16384 -c 16
0:28.58s: badblocks -b 2048 -c 4096
0:28.58s: badblocks -b 4096 -c 512
0:28.58s: badblocks -b 65536 -c 131072
0:28.59s: badblocks -b 1024 -c 8192
0:28.59s: badblocks -b 2048 -c 256
0:28.59s: badblocks -b 2048 -c 32
0:28.59s: badblocks -b 32768 -c 2
0:28.60s: badblocks -b 1024 -c 128
0:28.60s: badblocks -b 1024 -c 16384
0:28.60s: badblocks -b 512 -c 4096
0:28.60s: badblocks -b 65536 -c 2
0:28.62s: badblocks -b 16384 -c 32
0:28.62s: badblocks -b 512 -c 128
0:28.62s: badblocks -b 512 -c 32768
0:28.63s: badblocks -b 512 -c 8192
0:28.65s: badblocks -b 4096 -c 4096
0:28.67s: badblocks -b 16384 -c 1024
0:28.79s: badblocks -b 8192 -c 2048
0:28.80s: badblocks -b 8192 -c 4
0:28.81s: badblocks -b 16384 -c 2048
0:28.83s: badblocks -b 32768 -c 512
0:28.86s: badblocks -b 65536 -c 512
0:28.89s: badblocks -b 2048 -c 16384
0:28.98s: badblocks -b 65536 -c 256
0:29.09s: badblocks -b 8192 -c 4096
0:29.10s: badblocks -b 4096 -c 8192
0:29.10s: badblocks -b 512 -c 65536
0:29.15s: badblocks -b 1024 -c 32768
0:29.15s: badblocks -b 32768 -c 1024
0:29.34s: badblocks -b 4096 -c 8
0:29.35s: badblocks -b 1024 -c 32
0:29.40s: badblocks -b 16384 -c 2
0:29.41s: badblocks -b 32768 -c 1
0:29.41s: badblocks -b 512 -c 64
0:29.45s: badblocks -b 32768 -c 131072
0:29.46s: badblocks -b 2048 -c 16
0:30.10s: badblocks -b 2048 -c 32768
0:30.13s: badblocks -b 1024 -c 65536
0:30.14s: badblocks -b 16384 -c 4096
0:30.16s: badblocks -b 4096 -c 16384
0:30.16s: badblocks -b 512 -c 131072
0:30.22s: badblocks -b 8192 -c 8192
0:30.23s: badblocks -b 65536 -c 1024
0:30.26s: badblocks -b 32768 -c 2048
0:30.38s: badblocks -b 1024 -c 131072
0:30.38s: badblocks -b 2048 -c 65536
0:30.49s: badblocks -b 4096 -c 32768
0:30.50s: badblocks -b 65536 -c 2048
0:30.50s: badblocks -b 8192 -c 16384
0:30.53s: badblocks -b 32768 -c 4096
0:30.64s: badblocks -b 16384 -c 8192
0:31.01s: badblocks -b 2048 -c 131072
0:31.13s: badblocks -b 32768 -c 8192
0:31.14s: badblocks -b 65536 -c 4096
0:31.17s: badblocks -b 16384 -c 16384
0:31.17s: badblocks -b 4096 -c 65536
0:31.17s: badblocks -b 8192 -c 32768
0:32.20s: badblocks -b 4096 -c 131072
0:32.20s: badblocks -b 65536 -c 8192
0:32.21s: badblocks -b 8192 -c 65536
0:32.24s: badblocks -b 32768 -c 16384
0:32.25s: badblocks -b 16384 -c 32768
0:34.42s: badblocks -b 8192 -c 131072
0:34.57s: badblocks -b 16384 -c 65536
0:34.61s: badblocks -b 32768 -c 32768
0:34.71s: badblocks -b 65536 -c 16384
0:39.08s: badblocks -b 4096 -c 4
0:39.23s: badblocks -b 1024 -c 16
0:39.39s: badblocks -b 8192 -c 2
0:39.56s: badblocks -b 16384 -c 1
0:39.60s: badblocks -b 2048 -c 8
0:39.69s: badblocks -b 512 -c 32
1:02.34s: badblocks -b 1024 -c 8
1:02.45s: badblocks -b 4096 -c 2
1:02.50s: badblocks -b 512 -c 16
1:02.57s: badblocks -b 2048 -c 4
1:03.64s: badblocks -b 8192 -c 1
1:10.68s: badblocks -b 512 -c 4
1:10.69s: badblocks -b 1024 -c 2
1:11.07s: badblocks -b 2048 -c 1
1:14.60s: badblocks -b 512 -c 2
1:15.02s: badblocks -b 1024 -c 1
1:22.85s: badblocks -b 512 -c 1
1:47.08s: badblocks -b 1024 -c 4
1:47.21s: badblocks -b 4096 -c 1
1:47.49s: badblocks -b 2048 -c 2
1:47.96s: badblocks -b 512 -c 8

我认为,出于基准测试的目的,最好使用非随机模板,例如-t 0
mmv-ru 18-4-19
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.