It's possible, but kinda painful.
First, know that dd
prints its current position in a copy (bytes copied) if sent the USR1 signal. so find the PID of dd
, using either ps
or something like pidof
or pgrep
(not POSIX and not on all unix-y systems IIRC).
A ps
command that works for me (also using awk
, in a debian environment):
ps aux|awk '/dd/ {print $2}'|grep -v awk
grep -v awk
is necessary to prevent the PID of awk
from printing as well.
Having the PID of dd
, send the USR1 signal:
kill -USR1 [pid of dd]
the console window dd
is running in will print how many bytes it's copied. You may now kill dd
for real (ctrl+c, kill -9
, whatever). I don't recall whether dd
reports its progress on abort if killed this way in POSIX, so send the USR1 signal first.
dd
may have now copied a few more bytes since you stopped it, so run:
head -c [number of bytes reported copied from dd] > \
/path/to/drive/you/are/moving/to/filename.bin
to put a truncated copy on the destination disk. Instead of the precise number of bytes, you may want to choose something divisible by your desired block size, to speed up the transfer when you resume the copy. Just make note of whatever you choose, and make sure you are only truncating, not growing, the image.
Once you have this copied to the new drive, run:
dd if=/dev/sdc bs=64M skip=[truncated size divided by block size, e.g. 64000000] \
of=/path/to/part2
If you have space for the remainder of the image on the smaller original disk, delete the non-truncated image you copied to the new disk in part 1 to free space, and have dd
output it to that disk instead. When the transfer is complete, you can run
cat /path/to/part2 >> /path/to/part1
to add part 2 to the end of part 1, creating a complete disk image! Note that you will need at least as much free space on the disk part 1 is located on for all of part two to be appended to it.
If you don't mind doing the whole transfer over, I'd do cat /dev/sdc | gzip -c - > /path/to/imagefile.img.gz
to create a gzip compressed archive. This can be written to a hard disk partition with something like zcat /path/to/imagefile.img.gz > /dev/sdX
.
[copied from my comment into the answer]
additionally, I think (but do not remember for certain) that dd writes to stdout if of= is not specified. If this is true, you can skip writing part2 to a separate file and use:
dd bs=64M skip=[skip-block-count] if=/dev/sdc >> /path/to/part1
@MatijaNalis has rightly suggested using dd_rescue
or ddrescue
(two different programs that accomplish the same task) to copy the disk image. I'd do this if your partition/drive has erroneous sectors or other hardware faults.