Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 09-18-2011, 03:50 PM   #1
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?


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 (, 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 ( 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 05:51 PM. Reason: Changed the title to make the "dd" command clear.
Old 09-19-2011, 05:49 PM   #2
LQ Newbie
Registered: Sep 2011
Posts: 2

Original Poster
Rep: Reputation: Disabled

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:
hexdump -C -v -s 32256 -n 512 /dev/sdb
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:
ddrescue -f -n /dev/sdc /dev/sdb logfile
The code I used to copy the block of sectors is:
dd if=/dev/sdb of=/dev/sdb bs=512 seek=67110912 skip=63 count=524288
The reasons why I used the operands:
indicates where to start copying the sectors.
indicates the original location of my partition and where I want to "paste" them.
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:
hexdump -C -v -s 34360786944 -n 512 /dev/sdb
with 34360786944=512*67110912, but the output I received was:
hexdump: invalid number '34360786944'

Last edited by cross731; 09-19-2011 at 06:17 PM. Reason: Cleaned up the post and made it easier to understand.
Old 09-20-2011, 01:53 AM   #3
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


Last edited by zackwasa; 01-12-2012 at 01:04 AM.
Old 09-20-2011, 03:45 PM   #4
Registered: Mar 2008
Posts: 18,550

Rep: Reputation: 2778Reputation: 2778Reputation: 2778Reputation: 2778Reputation: 2778Reputation: 2778Reputation: 2778Reputation: 2778Reputation: 2778Reputation: 2778Reputation: 2778
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, 05:14 PM   #5
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.


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 05: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 06:56 PM
Repair Hard Drive Sectors raylhm Linux - Hardware 7 02-05-2008 09:33 AM
Bad sectors in hard drive Johnnio Linux - Hardware 5 07-31-2007 03:38 PM
How to I check a Linux formated hard drive for bad sectors NewtoLinuxWorld Linux - Hardware 1 02-27-2004 03:46 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:53 PM.

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