web-dev-qa-db-fra.com

Comment choisir les bons paramètres lors de l'utilisation de badblocks?

J'aimerais utiliser badblocks pour rechercher des blocs défectueux sur mon nouveau lecteur, mais je ne suis pas sûr de savoir comment choisir les valeurs pour la taille de bloc et le nombre de blocs à tester en parallèle. La page de manuel dit simplement:

-b block-size Spécifiez la taille des blocs en octets. La valeur par défaut est 1024.

-c number of blocks est le nombre de blocs testés à la fois. La valeur par défaut est 64.

La volonté de tester est de 2 To, aussi j'aimerais utiliser des valeurs qui ne font pas que ce processus prenne plusieurs jours. :-)

FWIW, smartmoontools rapporte:

Taille du secteur: 512 octets logiques, 4096 octets physiques

8
htorque

Étant donné que votre disque a une taille de secteur physique de 4096 octets, vous souhaitez utiliser -b 4096. Je ne pense pas que l'argument -c fasse une grande différence, alors laissez-le tranquille.

De plus, le test SMART interne du lecteur est meilleur et plus rapide que les badblocks. Il est donc préférable d'utiliser smartmontools ou l'utilitaire de disque pour l'exécuter.

5
psusi

J'ai créé un outil de référence pour tester différents paramètres. Le test peut prendre beaucoup de temps et effacer vos données, donc utilisez-le avec précaution.

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

Vous pouvez l'utiliser comme:

./badblocks_benchmark.sh /dev/sdX

Si vous voulez comparer avec seulement 4k blocs, alors:

#!/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

D'après mes tests, utiliser seulement -b 4096 sans -c (par défaut 64) est plutôt bon.

Mes résultats (plus petit est mieux): temps d'exécution en secondes et arguments

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