Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

How to use "testdisk" for recovery "/home"?

Graphical Environments, Managers, Multimedia & Desktop questions.
Post Reply
Message
Author
hack3rcon
Posts: 746
Joined: 2015-02-16 09:54
Has thanked: 48 times

How to use "testdisk" for recovery "/home"?

#1 Post by hack3rcon »

Hello,
Can I use "testdisk" tool to recover specific location? For example, in my PC the "/home" location mounted on:

Code: Select all

# mount
/dev/sda3 on /home type ext4 (rw,relatime)
And:

Code: Select all

Disk: /dev/sda
             Size: 465.8 GiB, 500107862016 bytes, 976773168 sectors
          Label: gpt, identifier: C40840DC-B308-4919-B387-E2BD0C61DD5F

    Device             Start        End    Sectors    Size Type
>>  /dev/sda1           2048    1368063    1366016    667M EFI System           
    /dev/sda2        1368064  177930239  176562176   84.2G Microsoft basic data
    /dev/sda3      177930240  959180799  781250560  372.5G Microsoft basic data
    /dev/sda4      959180800  976771071   17590272    8.4G Linux swap
    Free space     976771072  976773134       2063      1M
but when I use test disk like below show me an error:

Code: Select all

$ sudo testdisk /home/
TestDisk 7.0, Data Recovery Utility, April 2015
Christophe GRENIER <grenier@cgsecurity.org>
http://www.cgsecurity.org

Unable to open file or device /home/: Inappropriate ioctl for device
I don't like to recover all of "sda3".

Thank you.

L_V
Posts: 1477
Joined: 2007-03-19 09:04
Been thanked: 11 times

Re: How to use "testdisk" for recovery "/home"?

#2 Post by L_V »

TestDisk: Partition scanner and disk recovery tool.
TestDisk checks the partition and boot sectors of your disks.

PhotoRec: file recovery tool (included in testdisk package).
Then try with

Code: Select all

photorec

hack3rcon
Posts: 746
Joined: 2015-02-16 09:54
Has thanked: 48 times

Re: How to use "testdisk" for recovery "/home"?

#3 Post by hack3rcon »

I got the same error:

Code: Select all

$ sudo photorec /home/
PhotoRec 7.0, Data Recovery Utility, April 2015
Christophe GRENIER <grenier@cgsecurity.org>
http://www.cgsecurity.org

Unable to open file or device /home/: Inappropriate ioctl for device

L_V
Posts: 1477
Joined: 2007-03-19 09:04
Been thanked: 11 times

Re: How to use "testdisk" for recovery "/home"?

#4 Post by L_V »

The partition is /dev/sda3
'/home' is just a linux mountpoint or directory that testdisk or photorec do not understand as command parameter.
PhotoRec Step By Step

Code: Select all

/dev/sda3      177930240  959180799  781250560  372.5G Microsoft basic data
Not sure to understand what is " Microsoft basic data". You should clarify this first.

Code: Select all

lsblk -f

hack3rcon
Posts: 746
Joined: 2015-02-16 09:54
Has thanked: 48 times

Re: How to use "testdisk" for recovery "/home"?

#5 Post by hack3rcon »

I don't like to recover all of "/dev/sda3". Can I use block for recovery?

Code: Select all

~$ lsblk -f
NAME FSTYPE LABEL UUID                                 FSAVAIL FSUSE% MOUNTPOINT
sda                                                                   
├─sda1
│                                                                     
├─sda2
│    ext3         81f957de-2a93-4b9c-a07e-49f0fda0848b   59.7G    23% /
├─sda3
│    ext4         8530ffc3-a825-495c-80ec-2f5ed3d94c97  175.7G    47% /home
└─sda4
     swap         d012ba9c-e563-48ee-8d52-d41e21880479                [SWAP]
sdb                                                                   
├─sdb1
│    ntfs   New Volume
│                 B0689675689639D4                        3.3G    98% /mnt/Test1
└─sdb2
     ext4         ea13704a-d326-4414-9afd-d99ba129cc6f   11.2G    91% /mnt/test2
sr0                                                                   

L_V
Posts: 1477
Joined: 2007-03-19 09:04
Been thanked: 11 times

Re: How to use "testdisk" for recovery "/home"?

#6 Post by L_V »

I've never used photorec (or may be once), but I think you can select recovery by file types.
https://www.cgsecurity.org/wiki/File_Fo ... y_PhotoRec

You can mount your home partition.
Then what happened exactly to your home partition ?

v&n
Posts: 624
Joined: 2015-02-04 02:57

Re: How to use "testdisk" for recovery "/home"?

#7 Post by v&n »

Haven't done it myself, but I think you can create a partial image of your partition with ddrescue (gddrescue, telling it 'Bytes to SKIP' + 'Size to copy' - see 'man ddrescue'), then run photorec on that partial disk image.

This will work only if you are sure about the area on which your files needing recovery are located. If your are not sure about that, your files or parts of them may reside anywhere on the disk depending on the availability of free space at the the time of their creation, regardless of 'When' they were created/copied to the disk - thus the need to read entire disk to make sure no files/parts are missing during recovery.

And Yes, @L_V, photorec can recover files by their types, although it is not perfect in guessing the filetypes that are being recovered. I think it makes the guess based on the 'header' of the file-blocks that are being recovered, and can easily get confused, assigning wrong extension names to the recovered files/fragments.

Also, most of the recovered 'files' may be corrupt as they are only fragments. The job of finding/verifying the required files in this huge debris of recovered 'junk' is left to the user of course. Furthermore, it cannot restore their names/directory-structure. It just dumps the recovered data into folders named 'recup.####', naming them after the blocks they were found in (e.g. f001234.txt).

Post Reply