View previous topic :: View next topic |
Author |
Message |
malern Apprentice
Joined: 19 Oct 2006 Posts: 170
|
Posted: Thu Oct 06, 2011 2:38 pm Post subject: [solved] Recover files from corrupt disk |
|
|
I'm using Amazons cloud services and I've just had a VM die and leave me with a corrupted virtual disk. I've attached the disk to a new VM but fdisk reports "Disk /dev/sdf doesn't contain a valid partition table". I've tried creating a new partition (on a snapshot of the disk), but then it doesn't detect a filesystem.
This disk had a bunch of files that users of my webapp had uploaded. Typically I've now discovered I've been backing up symlinks rather than the actual files, so this disk potentially holds my only copy of those files. I'm not really sure where to start with trying to recover these files.
I believe the filesystem was ext3. All the files had filenames in the format "attach_[a-z0-9]{16}" and could have been any sort of file (e.g. images, videos, random project files). The files arn't any use to me without the filename (as I can't put them back into my webapp), so I don't think file carving programs like app-forensics/foremost or app-forensics/scapel will help.
Do I have any chance of getting these files back? Is there an easy way to check if there is a filesystem still on this disk?
Edit: just found app-admin/testdisk, which seemed liked my best hope, but it didn't find anything, so I'm assuming I'm pretty much boned
Last edited by malern on Fri Oct 07, 2011 2:41 pm; edited 1 time in total |
|
Back to top |
|
|
NeddySeagoon Administrator
Joined: 05 Jul 2003 Posts: 54407 Location: 56N 3W
|
Posted: Thu Oct 06, 2011 5:28 pm Post subject: |
|
|
malern,
Run testdisk on the image. It will scan the entire disk surface and make a list of possible partitions, then optionally, write a partition table for you.
IF you are more cautious, you can make a list of the starts and calculate offset= values to go in the command below.
How was the disk partitioned ?
Can you remember *exacty* ?
What tool did you use to make the partitions ?
Code: | mount -o offset=32256,ro /dev/... /mnt/<someplace> | might just work.
If the disk image is in a file, then its a bit harder.
Code: | mount -o offset=32256,ro,loop /path/to/file... /mnt/<someplace> |
The above commands attempt to mount the filesystem starting 32256 bytes from the start of the drive or drive image, which is the default location for the first filesystem on a PC using MSDOS disklabels. The partition table is not used, so it /dev/sda (whole drive) or whatever, not /dev/sda1 (partition 1)
The -ro is essential, you must not mount a damaged fs read/write, it might get worse. Theres lots more to try.
If it works, it may not be the partition you want but given the filesystem size we can guess the offset=value for the next filesystem.
If the mount fails, the error messages are essential to knowing what to try next _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
|
malern Apprentice
Joined: 19 Oct 2006 Posts: 170
|
Posted: Thu Oct 06, 2011 7:32 pm Post subject: |
|
|
Thanks for the useful advice. I'm pretty sure the disk was partitioned using fdisk, with a single linux (id 83) partition spanning the entire disk (10GB).
I've tried running testdisk on it and it didn't managed to find any partitions (even after the deep search). Running the mount command returned
Code: | mount: you must specify the filesystem type |
I'm starting to think the data is pretty much gone |
|
Back to top |
|
|
NeddySeagoon Administrator
Joined: 05 Jul 2003 Posts: 54407 Location: 56N 3W
|
Posted: Thu Oct 06, 2011 9:33 pm Post subject: |
|
|
malern,
You may just have lost the superblock. However, the extX filesystems stashes backup all over the place, to the next thing to try is one of those.
man mount: | sb=n Instead of block 1, use block n as superblock. This could be useful when the filesystem has
been damaged. (Earlier, copies of the superblock would be made every 8192 blocks: in block 1,
8193, 16385, ... (and one got thousands of copies on a big filesystem). Since version 1.08,
mke2fs has a -s (sparse superblock) option to reduce the number of backup superblocks, and
since version 1.15 this is the default. Note that this may mean that ext2 filesystems created
by a recent mke2fs cannot be mounted r/w under Linux 2.0.*.) The block number here uses 1k
units. Thus, if you want to use logical block 32768 on a filesystem with 4k blocks, use
"sb=131072". |
So add in sb=131072 to the options in the mount command as you will have 4k blocks.
If this fails, emerge sleuthkit which is a full blown forensics kit. It will not recover data but it will show the remains as far as it can.
Code: | mount -o offset=32256,ro,sb=131072 /dev/... /mnt/<someplace> |
Its harmless to test the above on a working system, with or without the sb=131072 just to check you are giving the right command.
On a single drive Gentoo default install, it would mount /boot _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
|
malern Apprentice
Joined: 19 Oct 2006 Posts: 170
|
Posted: Fri Oct 07, 2011 9:27 am Post subject: |
|
|
I still got the same error as before using the sb=n mount option, so I decided to give sleuthkit a try like you recommended. I ran tsk_recover on the disk image and it managed to extract all my files! I couldn't believe it
It's a fantastic tool, thanks for recommending it. I really appreciate all your help and advice, I owe you one! |
|
Back to top |
|
|
NeddySeagoon Administrator
Joined: 05 Jul 2003 Posts: 54407 Location: 56N 3W
|
Posted: Fri Oct 07, 2011 9:22 pm Post subject: |
|
|
malern,
That is extracted all your files it good but it says nothing about the file content that was recovered.
What was recovered was whatever was in the space pointed to by the metadata.
There is no other way than checking the files one by one to establish that the file content is correct. _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
|
malern Apprentice
Joined: 19 Oct 2006 Posts: 170
|
Posted: Mon Oct 10, 2011 8:35 am Post subject: |
|
|
Ok, that's good to know. Unfortunately there's too many files to be able to check them all. Plus some might have been corrupted to start with as this is a support site and we've had people upload broken files as examples. I've checked a few of the restored files and they've been fine, so I'm happy it's at least partially restored.
I'll be double checking my backups are working correctly in the future |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|