While re-installing my system with a Ubuntu derivative I decided that my old partitions could be slightly different than before. I made a smaller / directory, removed swap and made a new one at the end of the root partition, and wanted to keep my /home intact. Stupid enough, I wanted to resize it on the fly, which resulted in growing it in the wrong direction. I noticed, but made the stupid mistake to just go on anyway.
After reboot, my homedir wasn't quite the same anymore

In the past I have managed to rescue data on my mom's computer with Testdisk/Photorec, so I burnt the latest System Rescue CD and started trying to recover the lost partition. Luckily, I have a 1TB hdd lying around for use in a htpc-to-be which I temporarily installed in my home pc for the recovery. Sadly, my /home is not recoverable, so Testdisk says after Deeper Search:
Disk /dev/sda - 500 GB / 465 GiB - CHS 60801 255 63
The harddisk (500 GB / 465 GiB) seems too small! (< 736 GB / 685 GiB)
Check the harddisk size: HD jumpers settings, BIOS detection...
The following partition can't be recovered:
Partition Start End Size in sectors
> Linux 31821 1 1 89538 78 56 927228512
[ Continue ]
EXT4 Large file Sparse superblock Recover, 474 GB / 442 GiB
I tried to figure out how to solve this, and found a promising thread:
http://forum.cgsecurity.org/phpBB3/post ... imit#p3435
It seems I need to calculate the right amount of cylinders, but I'm sort of mediocre at calculations

My installation is pretty straightforward with 3 partitions: root ext4, swap and one big /home, also ext4. During my attempts to rescue the partition, I deleted the newly created almost-empty one by the OS in the hope I would be able to recover after all, but no

So it seems I need to change the number of cylinders to fool the partition table and be able to recover the partition with its whole directory/file structure. I'm stuck at what number to fill out here:
Disk /dev/sda - 500 GB / 465 GiB - CHS 60801 255 63, sector size=512
Because these numbers change the way that TestDisk looks for partitions
and calculates their sizes, it's important to have the correct disk geometry.
PC partitioning programs often make partitions end on cylinder boundaries.
A partition's CHS values are based on disk translations which make them
different than its physical geometry. The most common CHS head values
are: 255, 240 and sometimes 16.
Enter the number of cylinders: 60801
Any help would be a life saver! I never found it necessary to keep regular external backups, since my data have been on this disk for ages, and have partially even been copied over from other hdd's from ancient computers. I've never lost anything important in over 10 years. The last 48 hours have tought me differently.
Thanks in advance, I hope someone has an answer soon. And if it's not too much to ask, a step-by-step calculation included would be really great! I'd love to understand how to do this.
Kind regards,
Irene
Here's my Testdisk logfile:
Thu Jan 31 01:20:47 2013
Command line: TestDisk
TestDisk 6.13, Data Recovery Utility, November 2011
Christophe GRENIER <grenier@cgsecurity.org>
http://www.cgsecurity.org
OS: Linux, kernel 3.4.27-std330-amd64 (#2 SMP Tue Jan 22 23:33:56 UTC 2013) x86_64
Compiler: GCC 4.4
Compilation date: 2013-01-24T08:48:40
ext2fs lib: 1.42.6, ntfs lib: libntfs-3g, reiserfs lib: 0.3.1-rc8, ewf lib: none
/dev/sda: LBA, HPA, LBA48, DCO support
/dev/sda: size 976773168 sectors
/dev/sda: user_max 976773168 sectors
/dev/sda: native_max 976773168 sectors
/dev/sda: dco 976773168 sectors
/dev/sdb: LBA, HPA, LBA48, DCO support
/dev/sdb: size 1953525168 sectors
/dev/sdb: user_max 1953525168 sectors
/dev/sdb: native_max 1953525168 sectors
/dev/sdb: dco 1953525168 sectors
Warning: can't get size for Disk /dev/mapper/control - 0 B - CHS 1 1 1, sector size=512
Warning: can't get size for Disk /dev/md0 - 0 B - CHS 1 2 4, sector size=512
/dev/sr0 is not an ATA disk
Hard disk list
Disk /dev/sda - 500 GB / 465 GiB - CHS 60801 255 63, sector size=512 - SAMSUNG HD502IJ, S/N:S13TJ90Q877546, FW:1AA01113
Disk /dev/sdb - 1000 GB / 931 GiB - CHS 121601 255 63, sector size=512 - WDC WD10EARS-00Y5B1, S/N:WD-WCAV55641205, FW:80.00A80
Disk /dev/sr0 - 385 MB / 367 MiB - CHS 188329 1 1 (RO), sector size=2048 - HL-DT-ST RW/DVD GCC-4520B, FW:1.00
Partition table type (auto): Intel
Disk /dev/sda - 500 GB / 465 GiB - SAMSUNG HD502IJ
Partition table type: Intel
Analyse Disk /dev/sda - 500 GB / 465 GiB - CHS 60801 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=2
get_geometry_from_list_part_aux head=16 nbr=2
get_geometry_from_list_part_aux head=32 nbr=2
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=2
get_geometry_from_list_part_aux head=255 nbr=4
Current partition structure:
1 * Linux 0 1 1 1823 254 63 29302497
2 P Linux Swap 2678 0 1 3083 254 63 6522390
Ask the user for vista mode
Allow partial last cylinder : No
search_vista_part: 0
search_part()
Disk /dev/sda - 500 GB / 465 GiB - CHS 60801 255 63
recover_EXT2: s_block_group_nr=0/111, s_mnt_count=2/4294967295, s_blocks_per_group=32768, s_inodes_per_group=8176
recover_EXT2: s_blocksize=4096
recover_EXT2: s_blocks_count 3662109
recover_EXT2: part_size 29296872
Linux 0 1 1 1823 165 45 29296872
EXT4 Large file Sparse superblock, 14 GB / 13 GiB
Linux Swap 2678 0 1 3083 254 41 6522368
SWAP2 version 1, 3339 MB / 3184 MiB
recover_EXT2: s_block_group_nr=0/3537, s_mnt_count=3/4294967295, s_blocks_per_group=32768, s_inodes_per_group=8192
recover_EXT2: s_blocksize=4096
recover_EXT2: s_blocks_count 115903564
recover_EXT2: part_size 927228512
Linux 3084 0 1 60801 77 56 927228512
EXT4 Large file Sparse superblock, 474 GB / 442 GiB
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
Results
* Linux 0 1 1 1823 254 63 29302497
EXT4 Large file Sparse superblock, 15 GB / 13 GiB
P Linux Swap 2678 0 1 3083 254 63 6522390
SWAP2 version 1, 3339 MB / 3184 MiB
P Linux 3084 0 1 60801 254 63 927239670
EXT4 Large file Sparse superblock, 474 GB / 442 GiB
dir_partition inode=2
P Linux 3084 0 1 60801 254 63 927239670
EXT4 Large file Sparse superblock, 474 GB / 442 GiB
Directory /
2 drwxr-xr-x 0 0 4096 30-Jan-2013 01:21 .
2 drwxr-xr-x 0 0 4096 30-Jan-2013 01:21 ..
11 drwx------ 0 0 16384 30-Jan-2013 01:17 lost+found
9437185 drwxr-xr-x 1000 1000 4096 30-Jan-2013 02:56 irene
dir_partition inode=9437185
P Linux 3084 0 1 60801 254 63 927239670
EXT4 Large file Sparse superblock, 474 GB / 442 GiB
Directory /irene
9437185 drwxr-xr-x 1000 1000 4096 30-Jan-2013 02:56 .
2 drwxr-xr-x 0 0 4096 30-Jan-2013 01:21 ..
9437186 -rw-r--r-- 1000 1000 675 30-Jan-2013 01:21 .profile
9437187 drwxr-xr-x 1000 1000 4096 30-Jan-2013 02:56 .config
9437208 -rw-r--r-- 1000 1000 3102 30-Jan-2013 01:21 .bashrc
9437209 drwxr-xr-x 1000 1000 4096 30-Jan-2013 01:21 .local
9437213 -rw-r--r-- 1000 1000 220 30-Jan-2013 01:21 .bash_logout
9437214 drwxr-xr-x 1000 1000 4096 30-Jan-2013 01:21 .e
9437221 -rw------- 1000 1000 337625 30-Jan-2013 02:56 .xsession-errors
9437222 -rw------- 1000 1000 53 30-Jan-2013 01:29 .Xauthority
9437223 drwx------ 1000 1000 4096 30-Jan-2013 01:29 .dbus
9437244 drwxr-xr-x 1000 1000 4096 30-Jan-2013 02:49 .cache
9437261 drwxr-xr-x 1000 1000 4096 30-Jan-2013 02:49 Desktop
9437312 drwx------ 1000 1000 4096 30-Jan-2013 01:32 .gvfs
9437315 drwx------ 1000 1000 4096 30-Jan-2013 02:38 .gconf
9437316 -rw-r----- 1000 1000 0 30-Jan-2013 02:28 .gksu.lock
9437348 drwxrwxr-x 1000 1000 4096 30-Jan-2013 02:48 .gstreamer-0.10
9437258 drwx------ 1000 1000 4096 30-Jan-2013 02:02 .mozilla
9437522 drwx------ 1000 1000 4096 30-Jan-2013 02:02 .gnome2
9437523 drwx------ 1000 1000 4096 30-Jan-2013 02:02 .gnome2_private
9437650 -rw-r--r-- 0 0 15748 30-Jan-2013 02:54 testdisk.log
9437706 -rw-rw-r-- 1000 1000 139577344 30-Jan-2013 02:40 gparted-live-0.14.1-6-i486.iso
9437736 -rw-rw-r-- 1000 1000 385693696 30-Jan-2013 02:44 systemrescuecd-x86-3.3.0.iso
9437322 -rw------- 1000 1000 49 30-Jan-2013 02:56 .bash_history
Directory /
2 drwxr-xr-x 0 0 4096 30-Jan-2013 01:21 .
2 drwxr-xr-x 0 0 4096 30-Jan-2013 01:21 ..
11 drwx------ 0 0 16384 30-Jan-2013 01:17 lost+found
9437185 drwxr-xr-x 1000 1000 4096 30-Jan-2013 02:56 irene
interface_write()
1 * Linux 0 1 1 1823 254 63 29302497
2 P Linux Swap 2678 0 1 3083 254 63 6522390
search_part()
Disk /dev/sda - 500 GB / 465 GiB - CHS 60801 255 63
recover_EXT2: s_block_group_nr=0/111, s_mnt_count=2/4294967295, s_blocks_per_group=32768, s_inodes_per_group=8176
recover_EXT2: s_blocksize=4096
recover_EXT2: s_blocks_count 3662109
recover_EXT2: part_size 29296872
Linux 0 1 1 1823 165 45 29296872
EXT4 Large file Sparse superblock, 14 GB / 13 GiB
block_group_nr 3
recover_EXT2: "e2fsck -b 98304 -B 4096 device" may be needed
recover_EXT2: s_block_group_nr=3/111, s_mnt_count=0/4294967295, s_blocks_per_group=32768, s_inodes_per_group=8176
recover_EXT2: s_blocksize=4096
recover_EXT2: s_blocks_count 3662109
recover_EXT2: part_size 29296872
Linux 0 1 1 1823 165 45 29296872
EXT4 Large file Sparse superblock Backup superblock, 14 GB / 13 GiB
Linux Swap 2678 0 1 3083 254 41 6522368
SWAP2 version 1, 3339 MB / 3184 MiB
recover_EXT2: s_block_group_nr=0/3537, s_mnt_count=3/4294967295, s_blocks_per_group=32768, s_inodes_per_group=8192
recover_EXT2: s_blocksize=4096
recover_EXT2: s_blocks_count 115903564
recover_EXT2: part_size 927228512
Linux 3084 0 1 60801 77 56 927228512
EXT4 Large file Sparse superblock, 474 GB / 442 GiB
block_group_nr 3
recover_EXT2: "e2fsck -b 98304 -B 4096 device" may be needed
recover_EXT2: s_block_group_nr=3/3537, s_mnt_count=0/4294967295, s_blocks_per_group=32768, s_inodes_per_group=8192
recover_EXT2: s_blocksize=4096
recover_EXT2: s_blocks_count 115903564
recover_EXT2: part_size 927228512
Linux 3084 0 1 60801 77 56 927228512
EXT4 Large file Sparse superblock Backup superblock, 474 GB / 442 GiB
recover_EXT2: s_block_group_nr=0/3537, s_mnt_count=2/4294967295, s_blocks_per_group=32768, s_inodes_per_group=8192
recover_EXT2: s_blocksize=4096
recover_EXT2: s_blocks_count 115903564
recover_EXT2: part_size 927228512
Linux 31821 1 1 89538 78 56 927228512
EXT4 Large file Sparse superblock Recover, 474 GB / 442 GiB
This partition ends after the disk limits. (start=511204428, size=927228512, end=1438432939, disk end=976773168)
Disk /dev/sda - 500 GB / 465 GiB - CHS 60801 255 63
Check the harddisk size: HD jumpers settings, BIOS detection...
The harddisk (500 GB / 465 GiB) seems too small! (< 736 GB / 685 GiB)
The following partition can't be recovered:
Linux 31821 1 1 89538 78 56 927228512
EXT4 Large file Sparse superblock Recover, 474 GB / 442 GiB
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
Results
* Linux 0 1 1 1823 254 63 29302497
EXT4 Large file Sparse superblock, 15 GB / 13 GiB
P Linux Swap 2678 0 1 3083 254 63 6522390
SWAP2 version 1, 3339 MB / 3184 MiB
P Linux 3084 0 1 60801 254 63 927239670
EXT4 Large file Sparse superblock, 474 GB / 442 GiB
dir_partition inode=2
Linux 3084 0 1 60801 254 63 927239670
EXT4 Large file Sparse superblock, 474 GB / 442 GiB
Directory /
2 drwxr-xr-x 0 0 4096 30-Jan-2013 01:21 .
2 drwxr-xr-x 0 0 4096 30-Jan-2013 01:21 ..
11 drwx------ 0 0 16384 30-Jan-2013 01:17 lost+found
9437185 drwxr-xr-x 1000 1000 4096 30-Jan-2013 02:56 irene
dir_partition inode=9437185
Linux 3084 0 1 60801 254 63 927239670
EXT4 Large file Sparse superblock, 474 GB / 442 GiB
Directory /irene
9437185 drwxr-xr-x 1000 1000 4096 30-Jan-2013 02:56 .
2 drwxr-xr-x 0 0 4096 30-Jan-2013 01:21 ..
9437186 -rw-r--r-- 1000 1000 675 30-Jan-2013 01:21 .profile
9437187 drwxr-xr-x 1000 1000 4096 30-Jan-2013 02:56 .config
9437208 -rw-r--r-- 1000 1000 3102 30-Jan-2013 01:21 .bashrc
9437209 drwxr-xr-x 1000 1000 4096 30-Jan-2013 01:21 .local
9437213 -rw-r--r-- 1000 1000 220 30-Jan-2013 01:21 .bash_logout
9437214 drwxr-xr-x 1000 1000 4096 30-Jan-2013 01:21 .e
9437221 -rw------- 1000 1000 337625 30-Jan-2013 02:56 .xsession-errors
9437222 -rw------- 1000 1000 53 30-Jan-2013 01:29 .Xauthority
9437223 drwx------ 1000 1000 4096 30-Jan-2013 01:29 .dbus
9437244 drwxr-xr-x 1000 1000 4096 30-Jan-2013 02:49 .cache
9437261 drwxr-xr-x 1000 1000 4096 30-Jan-2013 02:49 Desktop
9437312 drwx------ 1000 1000 4096 30-Jan-2013 01:32 .gvfs
9437315 drwx------ 1000 1000 4096 30-Jan-2013 02:38 .gconf
9437316 -rw-r----- 1000 1000 0 30-Jan-2013 02:28 .gksu.lock
9437348 drwxrwxr-x 1000 1000 4096 30-Jan-2013 02:48 .gstreamer-0.10
9437258 drwx------ 1000 1000 4096 30-Jan-2013 02:02 .mozilla
9437522 drwx------ 1000 1000 4096 30-Jan-2013 02:02 .gnome2
9437523 drwx------ 1000 1000 4096 30-Jan-2013 02:02 .gnome2_private
9437650 -rw-r--r-- 0 0 15748 30-Jan-2013 02:54 testdisk.log
9437706 -rw-rw-r-- 1000 1000 139577344 30-Jan-2013 02:40 gparted-live-0.14.1-6-i486.iso
9437736 -rw-rw-r-- 1000 1000 385693696 30-Jan-2013 02:44 systemrescuecd-x86-3.3.0.iso
9437322 -rw------- 1000 1000 49 30-Jan-2013 02:56 .bash_history
Directory /
2 drwxr-xr-x 0 0 4096 30-Jan-2013 01:21 .
2 drwxr-xr-x 0 0 4096 30-Jan-2013 01:21 ..
11 drwx------ 0 0 16384 30-Jan-2013 01:17 lost+found
9437185 drwxr-xr-x 1000 1000 4096 30-Jan-2013 02:56 irene
interface_write()
1 * Linux 0 1 1 1823 254 63 29302497
2 P Linux Swap 2678 0 1 3083 254 63 6522390
simulate write!
write_mbr_i386: starting...
write_all_log_i386: starting...
No extended partition
New options :
Dump : No
Cylinder boundary : Yes
Allow partial last cylinder : No
Expert mode : Yes
Interface Advanced
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=2
get_geometry_from_list_part_aux head=16 nbr=2
get_geometry_from_list_part_aux head=32 nbr=2
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=2
get_geometry_from_list_part_aux head=255 nbr=4
1 * Linux 0 1 1 1823 254 63 29302497
EXT4 Large file Sparse superblock, 15 GB / 13 GiB
2 P Linux Swap 2678 0 1 3083 254 63 6522390
SWAP2 version 1, 3339 MB / 3184 MiB
Interface Advanced
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=2
get_geometry_from_list_part_aux head=16 nbr=2
get_geometry_from_list_part_aux head=32 nbr=2
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=2
get_geometry_from_list_part_aux head=255 nbr=4
1 * Linux 0 1 1 1823 254 63 29302497
EXT4 Large file Sparse superblock, 15 GB / 13 GiB
2 P Linux Swap 2678 0 1 3083 254 63 6522390
SWAP2 version 1, 3339 MB / 3184 MiB
dir_partition inode=2
1 * Linux 0 1 1 1823 254 63 29302497
EXT4 Large file Sparse superblock, 15 GB / 13 GiB
Directory /
2 drwxr-xr-x 0 0 4096 30-Jan-2013 01:58 .
2 drwxr-xr-x 0 0 4096 30-Jan-2013 01:58 ..
11 drwx------ 0 0 16384 30-Jan-2013 00:58 lost+found
130817 drwxr-xr-x 0 0 4096 30-Jan-2013 01:18 home
261633 drwxr-xr-x 0 0 4096 30-Jan-2013 02:56 etc
523265 drwxr-xr-x 0 0 4096 2-Jan-2013 21:36 media
654081 drwxr-xr-x 0 0 4096 30-Jan-2013 01:56 bin
130818 drwxr-xr-x 0 0 4096 30-Jan-2013 02:00 boot
523266 drwxr-xr-x 0 0 4096 28-Dec-2012 03:53 cdrom
261635 drwxr-xr-x 0 0 4096 30-Jan-2013 01:21 dev
654082 drwxr-xr-x 0 0 4096 30-Jan-2013 01:55 lib
654083 drwxr-xr-x 0 0 4096 30-Jan-2013 01:56 lib64
130819 drwxr-xr-x 0 0 4096 2-Jan-2013 21:36 mnt
523267 drwxr-xr-x 0 0 4096 6-Jun-2012 16:36 opt
8177 drwxr-xr-x 0 0 4096 2-Jan-2013 21:36 proc
8178 drwx------ 0 0 4096 30-Jan-2013 01:22 root
16353 drwxr-xr-x 0 0 4096 30-Jan-2013 01:21 run
16354 drwxr-xr-x 0 0 12288 30-Jan-2013 01:57 sbin
24529 drwxr-xr-x 0 0 4096 5-Mar-2012 17:54 selinux
24530 drwxr-xr-x 0 0 4096 6-Jun-2012 16:36 srv
32705 drwxr-xr-x 0 0 4096 2-Jan-2013 21:36 sys
32706 drwxrwxrwt 0 0 4096 30-Jan-2013 02:56 tmp
40881 drwxr-xr-x 0 0 4096 6-Jun-2012 16:36 usr
40882 drwxr-xr-x 0 0 4096 30-Jan-2013 02:56 var
13 lrwxrwxrwx 0 0 29 30-Jan-2013 01:58 vmlinuz
14 lrwxrwxrwx 0 0 31 30-Jan-2013 01:22 initrd.img.old
1815 lrwxrwxrwx 0 0 33 30-Jan-2013 01:58 initrd.img
X 12 lrwxrwxrwx 0 0 28 30-Jan-2013 01:22 vmlinuz.27382
12 lrwxrwxrwx 0 0 28 30-Jan-2013 01:22 vmlinuz.old
dir_partition inode=130817
1 * Linux 0 1 1 1823 254 63 29302497
EXT4 Large file Sparse superblock, 15 GB / 13 GiB
Directory /home
130817 drwxr-xr-x 0 0 4096 30-Jan-2013 01:18 .
2 drwxr-xr-x 0 0 4096 30-Jan-2013 01:58 ..
Directory /
2 drwxr-xr-x 0 0 4096 30-Jan-2013 01:58 .
2 drwxr-xr-x 0 0 4096 30-Jan-2013 01:58 ..
11 drwx------ 0 0 16384 30-Jan-2013 0