LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-12-2008, 06:43 AM   #1
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092
Blog Entries: 1

Rep: Reputation: 90
Question ntfs partition finder?


Is there a program that can locate "valid" ntfs partitions in a hard drive? Suppose the Partition Table got busted. I think that a program could find the NTFS "partition magic mark" and see (somehow.. using the NTFS partition format) if it's a valid partition and then tell me where it is.
 
Old 12-12-2008, 06:46 AM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,253

Rep: Reputation: 4160Reputation: 4160Reputation: 4160Reputation: 4160Reputation: 4160Reputation: 4160Reputation: 4160Reputation: 4160Reputation: 4160Reputation: 4160Reputation: 4160
testdisk will do most of that if not all.
 
Old 12-12-2008, 06:59 AM   #3
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092

Original Poster
Blog Entries: 1

Rep: Reputation: 90
Thanks man! I'll go check (someone else will work on the drive, but I'm assisting him).
 
Old 12-12-2008, 07:46 AM   #4
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Is this a drive from a Windows XP computer. If so, then the first partition probably starts at block 63.

You can try:
sudo /sbin/losetup -fs -o $((512*63))

to attach a loop device to it and then use
sudo file -s /dev/loop0
to analyse if there is a filesystem there.

If so, then you can mount it with
sudo mount -t ntfs /dev/loop0 /mnt

Once it is mounted you can use "df --block-size 512 /mnt" to determine the size of the filesystem. If there is another partition, it may be located at an offset of the size df returned plus the original 512*63 byte offset. So you can keep going and use losetup on the next partition.
 
Old 12-12-2008, 07:50 AM   #5
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092

Original Poster
Blog Entries: 1

Rep: Reputation: 90
That sounds quite logical. The distance MS sets between partitions is 63 sectors?
 
Old 12-12-2008, 03:53 PM   #6
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
I've also looked at usb drives and they start at sector 63 as well. My newish laptop is from Hitachi & it came with Vista. The first partition starts on Sector 2048. I don't know it this has something to do with Vista, or Hitachi.

When trying to locate or restore a partition, I would recommend using 512 byte sectors in all your tools. E.G. fdisk -lu, df --block-size 512, etc. If you work with cylinder sizes you could cause a rounding error. Especially on the first partition.

You can also use "losetup" and "file" in a for loop, attaching & detaching the loop device inside the loop. If you filter out ": data" results with "grep -v", you will have fewer locations to try out. For the second and later partitions, you could figure out cylinder size and try cylinder boundaries first. That could save a lot of time.

---

I'd also recommend taking an old pendrive, repartition & format it, and add some file. Now try using losetup and df to locate the start and size of the partitions on the pendrive. Use dd to wipe out the partition table and see if you can use losetup, df and fdisk to reconstruct it. This practice may become invaluable in the future.

In my example, in post #4, I used bash to calculate the byte offset. $((512*63)).

Last edited by jschiwal; 12-12-2008 at 04:01 PM.
 
  


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
tricky backup of Linux system to NTFS partition to increase partition size Pandarsson Linux - General 5 07-09-2008 02:35 PM
,dmrc problem after moving /home partition to NTFS partition yeehung Linux - Newbie 1 11-14-2007 06:17 AM
Unable to Resize NTFS partition with 4 different partition editors Alexandrian Linux - Newbie 11 05-19-2006 06:09 PM
Deleted ntfs partition - added linux partition in its place - corrupt! eklhad Linux From Scratch 2 06-28-2005 01:31 AM
resize an ext3 partition with coexisting ntfs partition andy_g Linux - Newbie 1 02-03-2004 05:38 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:32 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