0

Source harddisk: Size 500G. 210G of data. Used hexdump to check beyond 280G are all zeroes.

hexdump -C /dev/sdd2 --skip 280G --length 10G    # all zeroes

Destination harddisk: Size 600G. Used hexdump to check beyond 250G are all zeroes (or useless data).

hexdump -C /dev/sdc3 --skip 250G --length 10G    # all zeroes

I would like to copy all data from /dev/sdd2 to /dev/sdc3 with 250G offset in destination.

FYI: After mount, it is showing no files in destination. But I do not want to overwrite the first 250G, such that I might be possible to recover some files from there.

dd if=/dev/sdd2 of=/dev/sdc3 skip=0G seek=250K bs=1M count=280K status=progress

I tried using the dd command above. It should have done the job. But, after mount, no files in shown in the destination drive. I guess it is because the copied "file index table" is messing up with the original "file index table".

midnite
  • 601

2 Answers2

1

The content of a partition with a filesystem is... well, the filesystem. In general you cannot take a part of a filesystem, place it in another partition at random offset and expect it to mount when you pass the target partition to the mount command.

Note: I assume your "G" means "GiB".

The right way is like:

  1. Shrink the source filesystem on /dev/sdd2 to 280 GiB or less. Use a tool proper to the filesystem.

  2. Move the start of /dev/sdc3 (the partition, not the filesystem therein if any) 250 GiB to the right. This can be done by deleting the partition table entry and creating a new entry with recomputed start sector and the same end sector.

  3. Copy the content of /dev/sdd2 to the new /dev/sdc3 (with dd, or whatever). I assume the new partition is large enough for the (shrunk) filesystem.

    Alternatively create a new filesystem on the new /dev/sdc3, mount both filesystems and copy files from one filesystem to the other (e.g. with cp -a or rsync).

The data will be put 250 GiB after the start of the original /dev/sdc3, but within the new /dev/sdc3 it will be where the filesystem should be with respect to the beginning of the current partition. So now it should be mountable.

There will be unallocated space before /dev/sdc3 and this is where data you hope to recover is (according to you).

r2d3
  • 4,050
0

You can't do it that way.

On disk 2 create a 249gb partition of any kind at the front of the drive.

Now it would be better to use a tool like gparted. Copy and paste the desired partition from drive 1 to drive 2.

Hit apply

Wait till its done. Delete the bogus partition we created earlier.

cybernard
  • 14,924