Dec 312013
 

Interessante articolo sulla gestione dei bad blocks, pubblicato su http://virtualprivateserver.castlegem.co.uk/

L’hardware si rompe, è un fatto. Al giorno d’oggi, i dischi rigidi sono piuttosto affidabili, ma comunque ogni tanto vedremo degli errori occasionali nei drive o fargli fare qualche singhiozzo. Utilizzare smartcl/smartd per monitorare i dischi è una buona cosa, di seguito parleremo di come alcuni problemi minori possono essere gestiti senza effettivamente dover riavviare il sistema – è ancora a propria discrezione di un amministratore di sistema il giudicare le circostanze correttamente e valutare se gli errori del disco sono un incidente di una volta o indicano che il disco si sta rompendo del tutto.


Diamo un’occhiata a un tipico output del comando smartcl -a DEVICE:

# smartctl -a /dev/sda

...
ID# ATTRIBUTE_NAME          .... RAW_VALUE
197 Current_Pending_Sector  .... 2
...

Ok, quindi abbiamo un problema qui. Vediamo di scoprire cosa sta succedendo:

# smartctl –test=short /dev/sda

Questo richiederà un tempo molto breve, un paio di minuti al massimo, ad esempio:

Please wait 2 minutes for test to complete.
Test will complete after Sat Feb  2 16:25:10 2013

Ora, con un numero di current pending sector > 0 avremo probabilmente un warning dopo il completamento della prova:

Num  ..  Status                  Remaining  ..  LBA_of_first_error
...
# 2  ..  Completed: read failure 90%        ..  1825221261
...

LBA conta settori in unità di 512 byte e comincia a 0, quindi abbiamo ora bisogno di scoprire dove si trova effettivamente il 1825221261:

# fdisk -lu /dev/sda

visualizzerà alcune informazioni sul dispositivo in questione:

   Device Boot      Start         End      Blocks   Id  System
...
/dev/sda3        31641600  1953523711   960941056   83  Linux
...

Ovviamente, 1825221261 è in / dev/sda3, quindi. Ora abbiamo bisogno di determinare il blocco del file system per la nostra LBA in questione, quindi dobbiamo prima ottenere la dimensione del blocco:

# tune2fs -l /dev/sda3 | grep Block

Block count:              240235264
Block size:               4096
Blocks per group:         32768

OK, 4096 byte. Quindi, il numero di blocco effettivo sarà:

(LBA – PARTITION_START_SECTOR) * (512 / BLOCKSIZE)

Nel nostro caso, si tratta:

(1825221261 – 31641600) * (512 / 4096) = 224197457.625

Abbiamo solo bisogno la parte intera, la frazione ci dice solo che siamo nel settore 6° su otto che compone questo blocco di file system.

E’ buona pratica per scoprire quale inode/file è stato colpito utilizzando debugfs (le operazioni possono impiegare un po’ di tempo con questo strumento):
# debugfs

debugfs:  open /dev/sda3
debugfs:  icheck BLOCK (224197457 in our case)
Block   Inode number
224197457       56025154
debugfs:  ncheck 56025154
Inode   Pathname
56025154        /some/path/to/file

Ora, se questo file non è niente di fondamentale, possiamo iniziare a correggere le cose:

# dd if=/dev/zero of=/dev/sda3 bs=4096 count=1 seek=BLOCK
(224197457 here)
# sync

smartctl -a ora mostrerà un nuovo numero di settore in attesa di aggiornamento, e si può ri-eseguire un test smartctl short.

Popular Posts:

Flattr this!

  6 Responses to “Hard Disks: Bad Block HowTo”

  1. Please wait 2 minutes for test to complete.
    Test will complete after Sat Feb 2 16:25:10 2013

    Where is output file?
    I cant find it anywhere, not in pwd or home?

    • Run smartctl -a /dev/sda again – the test results will be there, nearer the end.

      • I get this:
        SMART Error Log Version: 1
        No Errors Logged

        SMART Self-test log structure revision number 1
        Num Test_Description Status Remaining LifeTime(hours) LBA_of_first_error
        # 1 Short offline Completed without error 00% 6353 –
        # 2 Short offline Completed without error 00% 6333 –
        # 3 Short offline Completed without error 00% 6331 –
        # 4 Short offline Completed without error 00% 3014 –

        So, no error on my hdd?
        How can I see particular 1-5 alone, not just last one?
        And where are this log files in filesystem?
        I search everywhere and can’t find it.

  2. Please wait 2 minutes for test to complete.
    Test will complete after Sat Feb 2 16:25:10 2013

    Where is output file?

  3. smartctl –test=short /dev/sda

    Should be smartctl –test=short /dev/sda

Leave a Reply to darkduck Cancel reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

*