[CentOS] Need a Centos 6 USB hard drive recovery procedure

Sat Jun 1 10:25:01 UTC 2013
Louis Lagendijk <louis at fazant.net>

On Sat, 2013-06-01 at 04:18 +0000, Rock wrote:
> On Sat, 11 May 2013 22:28:53 +0200, Louis Lagendijk wrote:
> 
> > here is a quick list of what to do:
> Thanks. I needed this step-by-step procedure; and I'll report back.
> I bought a new 2TB disk, named "My Passport".
> I will test the procedure with a spare 500GB disk, named "Signature Mini".
> 
> > 1) connect your spare disk (USB) (not the bad disk!!!!!) and as root
> > check what device id it got (tail /var/log/messages) look for detected
> > partitions there or do 
> > fdisk -l /dev/sdx where the sdx is what you found from /var/log/messages
> 
> 0. $ sudo tail -f /var/log/messages
> 1. I plugged in the 2TB new disk.
> ==> May 31 20:52:37 ntfs-3g[4213]: Mounted /dev/sdb1 (Read-Write, label "My Passport", NTFS 3.1)
> 2. $ sudo fdisk -l /dev/sdb
> ==> Disk /dev/sdb: 2000.4 GB, 2000365289472 bytes
> ==> /dev/sdb1 1 243198 1953480704 7 HPFS/NTFS
> 
> > 2) As root Mount the disk:
> > mount /devsdxy /mnt 
> > (where y is the partion number you want to mount)
> 
> 3. $ sudo mount /dev/sdb1 /mnt
> ==> Mount is denied because the NTFS volume is already exclusively opened.
> ==> The volume may be already mounted, or another software may use it which
> ==> could be identified for example by the help of the 'fuser' command.
> 
> > if mounted goto 3
> > This may fail if it is ntfs
> > 2B) If it fails format the disk as ext4:

> > mkfs /dev/sdxy
> > and then mount it as under 2
> 
> Should I now format the 2TB disk using this command?
>  $ sudo mkfs /dev/sdb1

You could try without reformatting it: just check where it is mounted:
mount |grep sdb1 
this will show where the disk got mounted.


> And then mount it as:
>  $ sudo mount /dev/sdb1 /mnt
> 
> > 3) I assume here that your bad disk is already connected (as sdz check
> > first what the real name is)
> 
> At this point, I connect the 500GB test disk and this shows up
> in the tail of /var/log/messages:
> May 31 21:02:39 ntfs-3g[4787]: Mounted /dev/sdc1 (Read-Write, label "SignatureMini", NTFS 3.1)

Check whee it got mounted 
mount |grep sdc1
and umount it to be sure

> > dd if=/dev/sdz of=/mnt/image.dd bs=1M
> > This will copy the contents of your bad disk to image.dd
> 
this now becomes:
dd if=/dev/sdc1 of=<path to the mount point for the new disk/image.dd

> Is this the correct command given the test information above:
>   $ sudo dd if=/dev/sdc of=/mnt/image.dd bs=1M
>  
> > 4) just to be sure, make the image read-only
> > chmod uog=r /mnt/image.dd
> 
> I presume I do this after the previous dd command finishes.
>   $ sudo chmod uog=r /mnt/image.dd
>  
Correct

> > 5) install testdisk from the epel repo
> > yum install testdisk
> 
>   $ sudo yum --enablerepo epel install testdisk -y
>   ==> Installed: testdisk.x86_64 0:6.12-2.el6                                                                                                                        
>   ==> Dependency Installed: libewf.x86_64 0:20100226-1.el6 
>   Note: This apparently installs /usr/bin/photorec  
> 
> > 6) now run photorec from a directory where you have sufficient space,
> > ifg your usb disk is big enough do it there (hint create a sub-directory
> > mdkdir /mnt/recover
> > cd /mnet/recover
> 
>   You probably mean "mkdir", so is this what I run:
>   $ sudo mkdir /mnt/recover
>   $ cd /mnt/recover
> 
Indeed, I am a lousy typer and even more lousy at proofreading....

> > but any dorectory would do
> > photorec /mnt/image.dd
> 
>   $ sudo photorec /mnt/image.dd
> 
> Q: Is this the recommended procedure as written after your comments?

Yes, doing it this way makes sure you do not destroy the content of the
old disk as you are working from a copy

Louis