web-dev-qa-db-ja.com

badblocksを使用するときに適切なパラメーターを選択するにはどうすればよいですか?

badblocksを使用して新しいドライブの不良ブロックをチェックしたいのですが、ブロックサイズと並行してテストするブロック数の値を選択する方法がわかりません。マニュアルページには次のように記載されています。

-b block-sizeブロックのサイズをバイト単位で指定します。デフォルトは1024です。

-c number of blocksは、一度にテストされるブロックの数です。デフォルトは64です。

テストするドライブは2TB大きいため、このプロセスに数日かかることのない値を使用したいと思います。 :-)

FWIW、smartmoontoolsレポート:

セクターサイズ:論理512バイト、物理4096バイト

8
htorque

ドライブの物理セクターサイズは4096バイトなので、-b 4096を使用します。 -c引数が大きな違いを生むとは思わないので、そのままにしておきます。

また、ドライブの内部SMARTテストはbadblocksよりも優れているため、smartmontoolsまたはディスクユーティリティを使用して実行することをお勧めします。

5
psusi

さまざまな設定をテストするベンチマークツールを作成しました。テストには時間がかかり、データが削除される可能性があるため、注意して使用してください。

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

私のベンチマークに基づいて、-c(デフォルト64)なしで-b 4096のみを使用するのはかなり良いです。

私の結果(小さいほうが良い):秒単位の実行時間と引数

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
3
mattty