I have a loopback file that contains a single filesystem, let's call it fs.image
. I have another, much larger loopback file, that contains multiple partitions and multiple filesystems, let's call it disk.image
.
fs.image
is exactly the same size as one of the partitions in disk.image
. I would like to copy the data from it into the disk.image
file into the correct location.
I have a script that computes the proper offset, and attempts to do this with dd
. I assumed this would work because it works with a block device, but this isn't the case. disk.image
is truncated at the position immediately following the data that was just written into it.
Is there any way to keep dd
from truncating the file?
fs.image
is compressed as fs.image.bz2
, and the command I'm executing is like this:
bzcat fs.image.bz2 | dd of=disk.image bs=4M seek=$OFFSET
where $OFFSET
is my computed offset.
I've thought about other ways of accomplishing this, but this seems the simplest (if it worked). Once option would be to copy data up to the point of insertion to another file, append the filesystem, and finally append the remainder of the original file. However, this would be slow because I'd be copying a lot of data I don't really need to. I'm open to other options.