LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 01-12-2010, 05:08 AM   #1
Raniz
LQ Newbie
 
Registered: Jan 2010
Posts: 5

Rep: Reputation: 0
Testdisk fails to find lost partition


I resized my root partition yesterday to make it include the unused 28GB at the end of my drive, but something went wrong and now I can't mount it again..

I think this has to do with the computer coming with Vista preinstalled and the partitions not being aligned to cylinders.

This is what the partition table looked like before the resize (according to fdisk):
Code:
Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xdec3533c

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1         638     5120000   1c  Hidden W95 FAT32 (LBA)
Partition 1 does not end on cylinder boundary.
/dev/sda2   *         638        4285    29297124    7  HPFS/NTFS
/dev/sda3            4285       19458 
Partition 3 does not end on cylinder boundary.
/dev/sda5            4285        4348
/dev/sda6            4348       15810
/dev/sda7           15810       19458
After the resize it looked like this:
Code:
Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xdec3533c

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1         638     5120000   1c  Hidden W95 FAT32 (LBA)
Partition 1 does not end on cylinder boundary.
/dev/sda2   *         638        4285    29297124    7  HPFS/NTFS
/dev/sda3            4285       19458 
Partition 3 does not end on cylinder boundary.
/dev/sda5            4285        4348
/dev/sda6            4348       19458
And after I removed the extended partition and recreated it it now looks like this:
Code:
Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xdec3533c

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1         638     5120000   1c  Hidden W95 FAT32 (LBA)
Partition 1 does not end on cylinder boundary.
/dev/sda2   *         638        4285    29297124    7  HPFS/NTFS
/dev/sda3            4285       19457
/dev/sda5            4285        4347
/dev/sda6            4348       19457
None of the last two partition schemes works, when I try to mount sda6 I get an error saying that the XFS superblock contains an invalid magic number. I've tried running xfs_repair on it, but even though it found a few secondary superblocks it couldn't verify them.

I've tried running testdisk with the "Cylinder boundary" option set to "no", but it would not find my root partition... The log from the search is here

I don't really care about the other partitions, all I need is my old root partition so that I can copy all the important stuff to another drive and then start from scratch with a new partition table (and remove the recovery partition aswell since I don't need it).

Any ideas as to how I can locate the start of my old partition, mount it and salvage what I need from it?

Last edited by Raniz; 01-15-2010 at 08:55 AM.
 
Old 01-13-2010, 03:53 AM   #2
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,248

Rep: Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321
May be a silly question, but have you tried an fsck --clever-options to stand up the filesystems as they exist?
Testdisk isn't going to do it now, because there isn't missing space. if you delete sda5 and sda6, testdisk will probably find them for you. That is another option. sda5 should end on 4348, not 4347. But you pulled out a partition and reinstated it differently. You're asking a lot of testdisk to find it now.
 
Old 01-13-2010, 05:30 AM   #3
Raniz
LQ Newbie
 
Registered: Jan 2010
Posts: 5

Original Poster
Rep: Reputation: 0
It was like that after I hade resized the partitions, but since that didn't work I removed the entire logical partition and recreated it - and now fdisk won't let me both end sda5 and start sda6 on 4348.

I'm currently trying to salvage what I can with photorec, so I'll try a fsck when that's done (in a day or two...)
 
Old 01-14-2010, 05:06 AM   #4
Raniz
LQ Newbie
 
Registered: Jan 2010
Posts: 5

Original Poster
Rep: Reputation: 0
Well, I'm done with photorec and I've deleted sda5 and sda6 from the partition table, but testdisk still fails to find them...

Any more ideas? I really want to fix this, and I know that the partition exists there... I just don't know where...
 
Old 01-14-2010, 06:47 AM   #5
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Use "fdisk -lu" to list the start and end sectors instead of cylinder boundaries Use this especially for the start of the first partition (which usually starts on sector 63 for Linux/XP a/nd 1024 for Vista) and the partitions that don't start or stop on cylinder boundaries.

Deleting the partitions partitions and recreating them may have made matters worse. Since you didn't backup the data, you probably want to create an image backup of the filesystem or disk device onto an external drive, and use the image file for recovering files. Utilities that might alter the filesystem could make matters worse.

Listing "fdisk -lu /dev/sda" for the current partitioning will help with the next suggestion:
Use losetup to attach /dev/sda to a loop device with an offset . Then use "file" to examine the device.

sudo /sbin/losetup -fs /dev/sda5 -o $((512*<starting sector>))

# If the particular loop device isn't printed, use the next command to learn which loop device was used.
sudo /sbin/losetup -a

# assuming /dev/loop0
sudo file -s /dev/loop0

---

If the starting sector may have changed during the resizing or repartitioning, you can use different offsets when attaching a loop device.
Here is an example using a partition on my laptop:
Code:
sudo /sbin/fdisk -lu /dev/sda

Disk /dev/sda: 200.0 GB, 200049647616 bytes
255 heads, 63 sectors/track, 24321 cylinders, total 390721968 sectors
Units = sectors of 1 * 512 = 512 bytes
Disk identifier: 0xd1b42421

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048     3074047     1536000    7  HPFS/NTFS
Partition 1 does not end on cylinder boundary.
/dev/sda2         3084480   150577244    73746382+   7  HPFS/NTFS
/dev/sda3   *   150577245   372659804   111041280    f  W95 Ext'd (LBA)
/dev/sda4       372666368   390721535     9027584   17  Hidden HPFS/NTFS
/dev/sda5       150577371   154786274     2104452   82  Linux swap / Solaris
/dev/sda6       154786338   216347354    30780508+  83  Linux
/dev/sda7       216347418   372659804    78156193+  83  Linux

for (( num=216347355;num<216347500;num++ )); do  
   echo -en "$num\t"
   sudo /sbin/losetup "$loopdev" /dev/sda -o $((512*$num))
   sudo file -s "$loopdev"
   sudo /sbin/losetup -d "$loopdev"done | grep -v ": data" >~/searchresults

...
216347415       /dev/loop0: DOS executable (device driver)
216347416       /dev/loop0: DOS executable (device driver)
216347417       /dev/loop0: DOS executable (device driver)
216347418       /dev/loop0: Linux rev 1.0 ext3 filesystem data (needs journal recovery) (large files)
216347426       /dev/loop0: shared library
216347466       /dev/loop0: ACB archive data
216347474       /dev/loop0: ACB archive data
216347482       /dev/loop0: ACB archive data
216347490       /dev/loop0: ACB archive data
216347498       /dev/loop0: ACB archive data
This may help you locate the exact sector where the XFS filesystem started. If you find it, use "fdisk -b512" to start your /dev/sda6 partition.
Reading the XFS manpage, it says that there are three groups to the filesystem, but the log part is contained in the data group when using fsck.xfs. Also each data group starts with the superblock. Subsequent data groups start with a copy. Unfortunately, mounting xfs doesn't have a "sb=" option according to the mount manpage.

Some of the other xfs_* utilities may help you as well.

Good Luck.

Last edited by jschiwal; 01-14-2010 at 06:51 AM.
 
1 members found this post helpful.
Old 01-14-2010, 09:39 AM   #6
Raniz
LQ Newbie
 
Registered: Jan 2010
Posts: 5

Original Poster
Rep: Reputation: 0
Thanks for the reply, I'll try that as soon as I can get my hold on some media large enough to hold a system rescue CD (which I guess will contain file). My current USB-stick is too small to fit anything larger than the minimal Gentoo install CD and I haven't got any CD-R at home...
 
Old 01-15-2010, 04:02 AM   #7
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,248

Rep: Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321
Try making sda5 with cfdisk. Then fsck that

If it complains about no superblock, try
e2fsck -b 32768 -fv /dev/sda5
and if that fails
e2fsck -b 32769 -fv /dev/sda5

There's often a copy around there.
 
Old 01-15-2010, 08:54 AM   #8
Raniz
LQ Newbie
 
Registered: Jan 2010
Posts: 5

Original Poster
Rep: Reputation: 0
Thanks a lot jschiwal, your post really helped me fix this.

I found the start of my XFS partition after running the for-loop for about a minute and then recreated everything with fdisk -u /dev/sda. I'm now back on my own computer and I've resized the XFS partition to include the unused space at the end of the drive. Everything is safe and back to normal.

You certainly saved my ass there!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Why won't testdisk let me label partition as extended? CJS Linux - General 10 11-21-2010 09:16 PM
Using testdisk to recover a partition Mark_in_Hollywood Linux - Newbie 6 04-18-2008 07:54 PM
Using testdisk to recover deleted lvm2 partition sstendal Linux - General 2 04-02-2008 09:30 AM
testdisk can't fix my partition table :( dmedhora Linux - General 7 11-28-2007 03:02 AM
testdisk stuff with adding a recovered reiserfs partition wini_g Linux - Software 2 11-07-2003 07:45 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 04:40 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration