LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-18-2011, 04:50 PM   #1
cross731
LQ Newbie
 
Registered: Sep 2011
Posts: 2

Rep: Reputation: Disabled
How do you move groups of sectors in a hard drive using the "dd" command?


Hello,

I'm trying to move groups of sectors from one part to another part in the same drive. I have read the "Learn the DD command" post (http://www.linuxquestions.org/questi...ommand-362506/), but I could not find the answer there. Let me bring this all into context.

I used gparted to expand my drive, but it failed. I posted my problem in gparted's forum (http://gparted-forum.surf4.info/viewtopic.php?id=15293) and they told me that I can recover my drive if I move the copied files to its original location. I did some math and I believe I need to move data from sectors 63 - 524350 to sectors 67110912 - 67635199 in the same drive: /dev/sdc1. I understand the dd command can help me do this, but I don't know how to move data between sectors. Thank you for taking the time in reading this.

Last edited by cross731; 09-19-2011 at 06:51 PM. Reason: Changed the title to make the "dd" command clear.
 
Old 09-19-2011, 06:49 PM   #2
cross731
LQ Newbie
 
Registered: Sep 2011
Posts: 2

Original Poster
Rep: Reputation: Disabled
UPDATE:

I bought a bigger hard drive and used 'ddrescue' to make a clone of the drive. I decided to fix the clone, located in /dev/sdb, and leave the original hard drive at the moment. I verified that original disk (/dev/sdc) was copied by doing a 'hexdump' command:
Quote:
hexdump -C -v -s 32256 -n 512 /dev/sdb
Quote:
hexdump -C -v -s 32256 -n 512 /dev/sdc
and looked for the "NTFS" in the dump. 32256 was used because 63 was the new start of my partition (63*512=32256).

The code I used to clone is:
Quote:
ddrescue -f -n /dev/sdc /dev/sdb logfile
The code I used to copy the block of sectors is:
Quote:
dd if=/dev/sdb of=/dev/sdb bs=512 seek=67110912 skip=63 count=524288
The reasons why I used the operands:
Quote:
skip=63
indicates where to start copying the sectors.
Quote:
seek=67110912
indicates the original location of my partition and where I want to "paste" them.
Quote:
count=524288
indicates the amount of sectors that was successfully copied before it failed.

Can someone please let me know if I used the proper operands? What would you have done differently? How can I verify that the sectors were copied to the right location (sector 67110912)? I tried:
Quote:
hexdump -C -v -s 34360786944 -n 512 /dev/sdb
with 34360786944=512*67110912, but the output I received was:
Quote:
hexdump: invalid number '34360786944'

Last edited by cross731; 09-19-2011 at 07:17 PM. Reason: Cleaned up the post and made it easier to understand.
 
Old 09-20-2011, 02:53 AM   #3
zackwasa
Member
 
Registered: Sep 2011
Posts: 52

Rep: Reputation: Disabled
Yes, you used the proper operands. As to how to verify? You can check if the files you moved the data for are working, not sure about another solution

RMI

Last edited by zackwasa; 01-12-2012 at 02:04 AM.
 
Old 09-20-2011, 04:45 PM   #4
jefro
Moderator
 
Registered: Mar 2008
Posts: 15,374

Rep: Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198
It is way more trivial to move the data. I can't begin to imagine all the issues here trying to use the data.

If the drive was raw it would make sense to do that. Your issue is way more complex. How do you propose to select the correct data and not any formatting and then move it to a file that is properly indexed. NTFS is not as easy as fat to fix the file allocation table.

I think I'd run something like unstoppable copier in windows or ddrescue or gddrescue on it or testdisk photorec.
 
Old 09-20-2011, 06:14 PM   #5
redw0lfx
LQ Newbie
 
Registered: Aug 2011
Distribution: FreeBSD 8, Arch Linux, Debian, CentOS 5.4, CentOS 6, Fedora
Posts: 10

Rep: Reputation: Disabled
I think the problem you will have with you approach is that you copied blocks of data from one location to another location, which would be fine if this were a raw data block device like a tape.

However, this is not the case, as all files consist of inodes which is a bit of information that tells the operating system where that file's data exists at and what attributes that file has. The inodes for those files did not get updated when you moved the blocks of data, which means they still point to the old blocks of data, and if there is different data there, those files will now show up as corrupted, or not at all.

I am not very familiar with NTFS file system, but I would imagine that there should be a utility to recover the files in case the inode (or file indexing map) ever got corrupted but the data still existed fine.
 
  


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
[SOLVED] How does one determine a USB hard drive capacity in sectors? Equinn Linux - Software 2 03-25-2011 06:40 AM
load Linux onto a hard drive on one computer then move the hard drive to another Ark9 Linux - Newbie 2 10-06-2008 07:56 PM
Repair Hard Drive Sectors raylhm Linux - Hardware 7 02-05-2008 10:33 AM
Bad sectors in hard drive Johnnio Linux - Hardware 5 07-31-2007 04:38 PM
How to I check a Linux formated hard drive for bad sectors NewtoLinuxWorld Linux - Hardware 1 02-27-2004 04:46 AM


All times are GMT -5. The time now is 02:07 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration