Page 1 of 1

FreeBSD filesystem/partition recovery

Posted: 08 Aug 2012, 05:09
by mnavarre
Hello,
I lost a drive on my PC-BSD box after a reboot. I hadn't done anything to the drive other than normal use, but after rebooting I was unable to mount the file systems.

The disk has two DOS primary partitions on it, each containing a single UFS2 file system. I think the physical drive may be failing (but it's still spinning and accessable, testdisks' Deeper Search option finds both partitions but freezes and panics the computer arond 80%), so I made an image file on another drive using dd to work with.

Here's a testdisk log file from the image after using Quick Search and writing the Partition table:
Tue Aug 7 20:25:34 2012
Command line: TestDisk -log ./ada1_backup

TestDisk 6.12, Data Recovery Utility, May 2011
Christophe GRENIER <grenier@cgsecurity.org>
http://www.cgsecurity.org
OS: FreeBSD, kernel 9.0-RELEASE-p3 (FreeBSD 9.0-RELEASE-p3 #0: Tue Jun 12 02:52:29 UTC 2012 root@a
Compiler: GCC 4.2
Compilation date: 2012-08-04T02:08:10
ext2fs lib: none, ntfs lib: none, reiserfs lib: none, ewf lib: none
Geometry from i386 MBR: head=255 sector=63
Hard disk list
Disk ./ada1_backup - 160 GB / 149 GiB - CHS 19458 255 63, sector size=512

Partition table type (auto): None
Disk ./ada1_backup - 160 GB / 149 GiB
Partition table type: Intel
Geometry from i386 MBR: head=255 sector=63

Analyse Disk ./ada1_backup - 160 GB / 149 GiB - CHS 19458 255 63
Geometry from i386 MBR: head=255 sector=63
get_geometry_from_list_part_aux head=255 nbr=4
get_geometry_from_list_part_aux head=8 nbr=1
get_geometry_from_list_part_aux head=16 nbr=1
get_geometry_from_list_part_aux head=32 nbr=1
get_geometry_from_list_part_aux head=64 nbr=1
get_geometry_from_list_part_aux head=128 nbr=1
get_geometry_from_list_part_aux head=240 nbr=1
get_geometry_from_list_part_aux head=255 nbr=4
Current partition structure:
1 P FreeBSD 0 1 1 10442 254 63 167766732
2 P FreeBSD 10443 0 1 19456 254 63 144809910
No partition is bootable
Ask the user for vista mode
Geometry from i386 MBR: head=255 sector=63
Allow partial last cylinder : Yes
search_vista_part: 1

search_part()
Disk ./ada1_backup - 160 GB / 149 GiB - CHS 19458 255 63
FreeBSD 0 1 1 10442 254 62 167766731
FreeBSD 10443 0 1 19456 254 62 144809909
get_geometry_from_list_part_aux head=255 nbr=4
get_geometry_from_list_part_aux head=8 nbr=1
get_geometry_from_list_part_aux head=16 nbr=1
get_geometry_from_list_part_aux head=32 nbr=1
get_geometry_from_list_part_aux head=64 nbr=1
get_geometry_from_list_part_aux head=128 nbr=1
get_geometry_from_list_part_aux head=240 nbr=1
get_geometry_from_list_part_aux head=255 nbr=4

interface_write()
1 * FreeBSD 0 1 1 10442 254 63 167766732
2 P FreeBSD 10443 0 1 19456 254 63 144809910
simulate write!
No extended partition

TestDisk exited normally.
I'd already written the Partition table to the file before this run.

Here's what testdisk -log /dev/ada1 shows:
Tue Aug 7 20:50:42 2012
Command line: TestDisk -log /dev/ada1

TestDisk 6.12, Data Recovery Utility, May 2011
Christophe GRENIER <grenier@cgsecurity.org>
http://www.cgsecurity.org
OS: FreeBSD, kernel 9.0-RELEASE-p3 (FreeBSD 9.0-RELEASE-p3 #0: Tue Jun 12 02:52:29 UTC 2012 root@a
Compiler: GCC 4.2
Compilation date: 2012-08-04T02:08:10
ext2fs lib: none, ntfs lib: none, reiserfs lib: none, ewf lib: none
Hard disk list
Disk /dev/ada1 - 160 GB / 149 GiB - CHS 310098 16 63, sector size=512

Partition table type (auto): None
Disk /dev/ada1 - 160 GB / 149 GiB
Partition table type: Intel

Analyse Disk /dev/ada1 - 160 GB / 149 GiB - CHS 310098 16 63
Geometry from i386 MBR: head=255 sector=63
get_geometry_from_list_part_aux head=16 nbr=1
get_geometry_from_list_part_aux head=8 nbr=1
get_geometry_from_list_part_aux head=16 nbr=1
get_geometry_from_list_part_aux head=32 nbr=1
get_geometry_from_list_part_aux head=64 nbr=1
get_geometry_from_list_part_aux head=128 nbr=1
get_geometry_from_list_part_aux head=240 nbr=1
get_geometry_from_list_part_aux head=255 nbr=4
Current partition structure:
1 * FreeBSD 0 1 1 166435 4 63 167766732

Warning: Bad ending head (CHS and LBA don't match)
2 * FreeBSD 166435 5 1 310095 14 63 144809910

Warning: Bad starting head (CHS and LBA don't match)
Only one partition must be bootable
Ask the user for vista mode
Computes LBA from CHS for Disk /dev/ada1 - 160 GB / 149 GiB - CHS 310099 16 63
Allow partial last cylinder : Yes
search_vista_part: 1

search_part()
Disk /dev/ada1 - 160 GB / 149 GiB - CHS 310099 16 63
FreeBSD 0 1 1 166435 4 62 167766731
FreeBSD 166435 5 1 310095 14 62 144809909
get_geometry_from_list_part_aux head=16 nbr=1
get_geometry_from_list_part_aux head=8 nbr=1
get_geometry_from_list_part_aux head=16 nbr=1
get_geometry_from_list_part_aux head=32 nbr=1
get_geometry_from_list_part_aux head=64 nbr=1
get_geometry_from_list_part_aux head=128 nbr=1
get_geometry_from_list_part_aux head=240 nbr=1
get_geometry_from_list_part_aux head=255 nbr=4
Warning: the current number of heads per cylinder is 16 but the correct value may be 255.

interface_write()

No partition found or selected for recovery
simulate write!
No extended partition

TestDisk exited normally.

I've tried using FreeBSDs loopback device to mount the filesystems, but the only device entry I get is /dev/md0, I should be seeing md0, md0s1 and md0s2.

The manual for the drive says this is the disk geometry:
Guaranteed Sectors: 312,581,808
bytes per sector: 512
Sectors per track: 63
Heads: 16
Sectors: 16383

Any ideas? Because I think I'm out of my depth here

Thanks,
Matt