bb-test.pl
von linuxCowboy- SNIPPET_TEXT:
-
- #!/usr/bin/perl -w
- #
- # badblocks test [LxC]
- use 5.010;
- ##### start adjust block #####
- $device = "/dev/sdb";
- $blocksize = 4096;
- $blocks_total = 732_566_646; # 3TB
- $percent_to_check = 10;
- $blocks_at_once = 4000; # HDD-Cache
- $reads_total = 100; # 0 to disable
- $blocks_to_check_start_end = 250_000; # 0 to disable
- $randomize_reads = 1; # boolean
- $sleep_between_reads = 60; # seconds, 0 to disable
- # overheat protection: adjust get_temp() for your drive!
- $overheat_protection = 0; # boolean
- $max_temp = 46;
- $cooldown_time = 60;
- #$test = ""; # read-only mode (badblocks default)
- $test = "-w -t 0xff"; # read-write mode
- #$test = "-n -t 0xff"; # non-destructive read-write mode
- $logfile = "/var/log/bb-test.log"; # "" to disable
- ##### end adjust block #####
- if ( $test =~ /w/ ) {
- }
- if ( $logfile ) {
- }
- $start_range = $blocks_per_check - $to_check;
- print "\n$device: ",sep_point( $to_check * $reads_total )." of ",sep_point( $blocks_total )." blocks ($percent_to_check%) ",`date`;
- if ( $blocks_to_check_start_end ) {
- do_scan( 0, $blocks_to_check_start_end, 1, 1 ); # first blocks
- do_scan( ($blocks_total - $blocks_to_check_start_end), ($blocks_total - 1), 1, 1 ); # last blocks
- }
- for ( $start = 0, $read = 0; $read++ < $reads_total; $start += $blocks_per_check ) {
- do_scan( ($start + $rand_start), ($start + $rand_start + $to_check), $read, $reads_total );
- }
- sub do_scan {
- ( $first, $last, $counter, $total ) = @_;
- $size = ($last - $first + 1) * $blocksize / 1024 / 1024;
- $counter, $total, $size, $time, ($time ? $size / $time : 0), $t/60/60, $t/60%60, $t%60;
- last if ( $counter == $total );
- }
- check_temp() if ( $overheat_protection );
- }
- sub check_temp {
- $curr_temp = get_temp();
- if ( $max_temp ) {
- while ( $curr_temp > $max_temp ) {
- }
- $curr_temp = get_temp();
- }
- }
- }
- sub get_temp { # find a way to read your drive!
- for ( `hdparm -H $device 2>/dev/null` ) { # Hitachi only, but fast
- }
- for ( 0..2 ) {
- for ( `smartctl -a -T permissive $device` ) {
- }
- }
- }
- sub sep_point {
- $par;
- }
Quellcode
Hier kannst du den Code kopieren und ihn in deinen bevorzugten Editor einfügen. PASTEBIN_DOWNLOAD_SNIPPET_EXPLAIN