LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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 09-05-2020, 01:16 AM   #1
platypo
Member
 
Registered: Sep 2015
Distribution: Debian, Archlinux
Posts: 140

Rep: Reputation: Disabled
Partition size


I want to rescue a 1 TB partition from an external hd to an internal 1TB drive using ddrescue. The external hd /dev/sdc has a damaged ntfs partition /dev/sdc1 wich i want to rescue.

Gparted indicates 1953523312 sectors for /dev/sdc1 and it can't be checked/repaired nor mounted ("can't have a partition outside the disk").

lsblk -b shows:
Code:
/dev/sda:                                100020 4886016 bytes
/dev/sda1 (currently formatted as ext2): 100020 3091968 bytes
/dev/sdc:                                100020 4885504 bytes
/dev/sdc1 (the damaged ntfs partition):  100020 3836928 bytes
I successfully used ddrescue /dev/sdc to /dev/sda including the partition table, resulting in two equal volumes with the same errors, but showing that it would be technically possible.

Writing /dev/sdc1 to /dev/sda1 formatted as ntfs failed because /dev/sda1 was somewhat 750000 bytes short.

I have formatted the internal 1TB hd serveral times now. Besides not having the time for trial and error i am afraid of damaging either of the devices.

My question is: what partition type provides the most available space of a device so i can get more than 1000203836928 bytes out of it, and: could someone maybe rule out or confirm by the numbers above wether or not this whole plan technically could work?

Last edited by platypo; 09-05-2020 at 01:26 AM.
 
Old 09-05-2020, 01:35 AM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,163

Rep: Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125
It's not a matter of partition type, but maybe alignment - the newer versions of the tools align for performance which the older versions didn't. This leaves "holes" of unallocatable space between the partitions. Can be avoided, but what about simply not using a partition at all - that way you get all the space of the disk. So ddrescue /dev/sdc1 to /dev/sda and simply mount the latter - or attempt to. Do your recovery from /dev/sda.
 
Old 09-05-2020, 01:39 AM   #3
platypo
Member
 
Registered: Sep 2015
Distribution: Debian, Archlinux
Posts: 140

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by syg00 View Post
It's not a matter of partition type, but maybe alignment - the newer versions of the tools align for performance which the older versions didn't. This leaves "holes" of unallocatable space between the partitions. Can be avoided, but what about simply not using a partition at all - that way you get all the space of the disk. So ddrescue /dev/sdc1 to /dev/sda and simply mount the latter - or attempt to. Do your recovery from /dev/sda.
Before i try, wouldn't the recovered image need to be mounted and thus have a partition table in order to perform any further action?
 
Old 09-05-2020, 01:56 AM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,163

Rep: Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125
No, recovery/forensic tools read the disk directly - they specifically don't want/need them mounted as mounting can cause the journal to be applied, potentially changing the disk. If it was me I'd simply recover what you have - either from sdc1 directly, or (better) from an image of it. You'll need yet another disk to write the recovered data to - can be /dev/sda? if you recovery directly from /dev/sdc1. Tools such as photorec (does much more than just photos) handle NTFS just fine, even if broken. Other options also exist.
 
Old 09-05-2020, 02:28 AM   #5
platypo
Member
 
Registered: Sep 2015
Distribution: Debian, Archlinux
Posts: 140

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by syg00 View Post
No, recovery/forensic tools read the disk directly - they specifically don't want/need them mounted as mounting can cause the journal to be applied, potentially changing the disk. If it was me I'd simply recover what you have - either from sdc1 directly, or (better) from an image of it. You'll need yet another disk to write the recovered data to - can be /dev/sda? if you recovery directly from /dev/sdc1. Tools such as photorec (does much more than just photos) handle NTFS just fine, even if broken. Other options also exist.
So basically you suggest moving the failing /dev/sdc1 directly to /dev/sda. Scince i most likely won't get a mountable volume out of this i'll have to use forensic tools to copy contents to be found back to a newly formatted /dev/sdc1.

Scince i haven't found any compareable example anywhere, are there maybe some specific guesses on what the outcome of 'ddrescue -f /dev/sdc1 /dev/sda' could look like? Are there any risks?

Thanks so far for your efforts.

Last edited by platypo; 09-05-2020 at 02:29 AM.
 
Old 09-05-2020, 09:32 PM   #6
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
Quote:
Originally Posted by platypo View Post
So basically you suggest moving the failing /dev/sdc1 directly to /dev/sda. Scince i most likely won't get a mountable volume out of this i'll have to use forensic tools to copy contents to be found back to a newly formatted /dev/sdc1.

Scince i haven't found any compareable example anywhere, are there maybe some specific guesses on what the outcome of 'ddrescue -f /dev/sdc1 /dev/sda' could look like? Are there any risks?

Thanks so far for your efforts.
A very good guide for using ddrescue is here.

I am not sure about copying /dec/sdc1 to /dev/sda because you are putting the contents of a partition containing a formatted NTFS filesystem with its contents on a raw device. I would suspect problems with that approach especially since the new copy would not have a partition table to manage its contents, allow mounting, etc.
Copying sdc directly to sda would copy the partition table but the drawback there would be that it would also copy the bad block table, and the filesystem damaaged blocks to the physical device as well.

What I would try would be to create an image of sdc1 as a file onto a filesystem located on a larger drive, such as a 3TB drive, and then try fixing that image instead of mucking with the original. I recently got a 3TB drive for ~$80.

The image probably could be mounted, allowing you to copy off any files that are still good, repair the filesystem, etc. without risking further damage to the original disk. The extra space would give you room to do repairs, make a second copy, etc. as well.

Note that ddrescue works similar to (Uses?) dd in that it copies block by block from source to destination. That is why a slightly smaller destination will not work.

Last edited by computersavvy; 09-05-2020 at 09:37 PM.
 
Old 09-06-2020, 02:02 AM   #7
platypo
Member
 
Registered: Sep 2015
Distribution: Debian, Archlinux
Posts: 140

Original Poster
Rep: Reputation: Disabled
Thanks. As @syg00 recommended i got myself the testdisk package and let photorec run directly on the external hd over night. I now have the raw output on the internal drive wich is well smaller than 1TB and will now try to follow these instructions to get the parts together again.
Scince that was what i hoped ddrescue could somehow magically do in the first place i mark this thread as solved.

Last edited by platypo; 09-06-2020 at 02:04 AM.
 
  


Reply



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
How to re-size root partition without loosing any data if the root partition is immediately followed by swap partition thebiggiantmouse Linux - Hardware 16 09-25-2019 12:06 PM
Linux Virtual Memory size; Page size; Resident Data Size; DB2Database; Explanation ANanalanalyzer Linux - Newbie 1 09-28-2018 04:50 PM
file system size larger than fysical size:superblock or partition table corrupt klizon Linux - General 0 06-18-2004 04:18 PM
Total partition size - User partition size is not equals to Free partition size navaneethanj Linux - General 5 06-14-2004 12:55 PM
fdisk partition size differs from mounted partition size jimieee Linux - General 3 10-15-2003 03:10 AM

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

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