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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
12-12-2008, 06:43 AM
|
#1
|
Senior Member
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092
Rep:
|
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.
|
|
|
12-12-2008, 06:46 AM
|
#2
|
LQ Veteran
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,253
|
testdisk will do most of that if not all.
|
|
|
12-12-2008, 06:59 AM
|
#3
|
Senior Member
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092
Original Poster
Rep:
|
Thanks man! I'll go check (someone else will work on the drive, but I'm assisting him).
|
|
|
12-12-2008, 07:46 AM
|
#4
|
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733
|
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.
|
|
|
12-12-2008, 07:50 AM
|
#5
|
Senior Member
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092
Original Poster
Rep:
|
That sounds quite logical. The distance MS sets between partitions is 63 sectors?
|
|
|
12-12-2008, 03:53 PM
|
#6
|
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733
|
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.
|
|
|
All times are GMT -5. The time now is 12:32 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|