|
Come recuperare dati da un hard disk danneggiato, con danni sui settori
fisici del disco.
Quando un HD fallisce la lettura su qualche settore mentre lavora bene
sul resto dell'hard disk. Si puo' seguire la seguente procedura per recuperare
il filesystem.
Usate un altro pc che disponga spazio libero sufficiente a contenere
il doppio della dimensione del disco danneggiato, da recuperare. Potete
usare il medesimo pc ma dovrete disporre di un ulteriore hard disk con
Linux installato.
Installate l'HD danneggiato sul canale IDE secondario.
L'obiettivo e' di potere recuperare un immagine raw della partizione primaria
dal disco danneggiato, rimontarla nuovamente con l'opzione loop ed infine
copiare i dati su di un nuovo hd.
Il pc per il recupero deve usare il sysop Linux.
L'hard disk danneggiato e' /dev/hdc . La partizione 1 e' il / file system.
La partizione 2 era la partizione usata come swap device. La lettura avverra'
in blocchi da 1024 bytes.
[root@elart /]# cd /tmp
[root@elart /tmp]# dd if=/dev/hdc1 of=1 bs=1024
dd: /dev/hdc1: Input/output error
7332+0 records in
7332+0 records out
La prima parte dell'hard disk e' stata letta. Ovvio che al settore 7333
c'e' un danno.
Provate a riverificate il danno con il comando
dd if=/dev/hdc1 of=tmp bs=1024 skip=7332 count=1
e dovreste ottenere l'errore nuovamente.
Salteremo questo settore e procederemo con l'area del disco rimanente.
[root@elart /tmp]# dd if=/dev/hdc1 of=2 bs=1024
skip=7333
dd: /dev/hdc1: Input/output error
385907+0 records in
385907+0 records out
C'e' un altro settore rovinato. Lo saltiamo, stando attenti al nuovo
valore di skip.
Dobbiamo sommare tutti i precedenti valori di skip ovvero: 7333 + 385908
= 393241
[root@elart /tmp]# dd if=/dev/hdc1 of=3 bs=1024
skip=393241
1219527+0 records in
1219527+0 records out
Abbiamo cosi' ottenuto la lettura fino alla fine dell'hard disk. Abbiamo
ora i tre "pezzi" con due "buchi" in mezzo questi
buchi sono da 1KB. Creeremo quindi 1K di dati come riempitivo.
[root@elart /tmp]# dd if=/dev/zero of=d1 bs=1024
count=1
1+0 records in
1+0 records out
Copiando ed unendo ora tutti i files assieme otteremo una immagine "quasi"
perfetta del nostro disco difettoso.
[root@elart /tmp]# cat 1 d1 2 d1 3 > hdmirror
Dovremo ora eseguire un controllo con fsck sulla immagine appena creata,
sappiamo che dovrebbero esserci almeno 2 errori causati dai 2 blocchi
da 1k pieni di zeri.
[root@elart /tmp]# fsck.ext2 -a hdmirror
hd contains a file system with errors, check forced.
.... with some repair msgs from fsck
Possiamo ora montare questa immagine dell'hard-disk ad esempio in /mnt/oldhd.
[root@elart /tmp]# mkdir /mnt/oldhd
[root@elart /tmp]# mount hdmirror /mnt/oldhd -o
loop
Il nostro nuovo harddisk lo monteremo su /mnt/hdnew. Lo avremo gia' partizionato
con fdisk ed avremo anche creato il filesystem con mke2fs. Dovremo solo
copiare il contenuto dell'immagine recuperata sul nuovo hd. Usiamo a tale
scopo tar cosicche' tutti i file speciali le permission dei files saranno
preservate.
[root@elart /tmp]# (cd /mnt/oldhd; tar c *)|(cd /mnt/hdnew;
tar xv)
Rimane ancora un piccolo problema. Il nuovo hard-disk non sara' capace
di effettuare il boot per il momento. Creiamo un boot disk dalla kernel
image ci serve un floppy pulito. Per sicurezza createne due su due floppy
distinti.
[root@elart /tmp]# cat /mnt/new/vmlinuz > /dev/fd0
Ora dobbiamo impostare il device di boot in modo che sia impostato correttamente
onde eseguire il boot.
Nel nostro caso e' /dev/hda1.
[root@elart /tmp]# rdev /dev/fd0 /dev/hda1
Dovremmo aver finito.
Installiamo il nostro nuovo hard disk nuovamente sul computer originario
ed effettuiamo il boot per una volta dal nostro dischetto di boot.
Dobbiamo scrivere un nuovo settore di boot sul nostro harddisk:
Se usate lilo digitiamo il seguente comando:
/sbin/lilo
Se usate grub
L' installazione dipende molto dalle vostre impostazioni percio' leggete
il manuale
on line dal quale abbiamo copiato sotto un estratto:
If you decide to install GRUB in the native environment, which is definitely
desirable, you'll need to create the GRUB boot disk, and reboot your
computer with it. Otherwise, see *Note Installing GRUB using grub-install::,
for more details.
Once started, GRUB will show the command-line interface.
First, set the GRUB's "root device" to the boot directory, (Note
that GRUB's root device doesn't necessarily mean your OS's root partition;
if you need to specify a root partition for your OS, add the argument
into the command `kernel')
like this:
grub> root (hd0,0)
If you are not sure which partition actually holds these files, use the
command `find' (*note find::), like this:
grub> find /boot/grub/stage1
This will search for the file name `/boot/grub/stage1' and show the devices
which contain the file.
Once you've set the root device correctly, run the command `setup' (*note
setup::):
grub> setup (hd0)
This command will install GRUB on the MBR in the first drive. If you want
to install GRUB into the "boot sector" of a partition instead
of the MBR, specify a partition into which you want to install GRUB:
grub> setup (hd0,0)
If you install GRUB into a partition or a drive other than the first one,
you must chain-load GRUB from another boot loader. Refer to the manual
for the boot loader to know how to chain-load GRUB.
Now you can boot GRUB without a GRUB floppy. See the chapter *NoteBooting::
to find out how to boot your operating systems from GRUB.
Ricordiamoci di rimuovere i files nella directory /tmp del computer che
e' servito per il recupero.
C'e' un tools automatico che fa le operazioni di dd che abbiamo descritto
in precedenza e che vi consigliamo di usare e si trova all'indirizzo:
http://www.garloff.de/kurt/linux/ddrescue/
|