Ledwith94
Ledwith94

Reputation: 25

Bash - How to write a file to a specific address on a disk

I am trying to recreate a disk image manually through bash. I have an empty disk the same size as the original and I am trying to insert each file at same address as the original disk so that both hash's match. However I cant seem to find the commands to do this. I was advised to use DD or DCFLDD but I cant figure out how to do this with the documentation online. I have a disk, image.dmg and the first file is ._.Trashes with an inode of 4 and size of 4096 bytes.

Upvotes: 1

Views: 3664

Answers (1)

Maxim Egorushkin
Maxim Egorushkin

Reputation: 136525

With dd you may like to use the following arguments:

    bs=BYTES
           read and write up to BYTES bytes at a time

    count=N
           copy only N input blocks

    seek=N skip N obs-sized blocks at start of output

    skip=N skip N ibs-sized blocks at start of input

In other words, to copy N bytes at offset X in file A to offset Y in file B, something like the following should do:

dd bs=1 count=N if=A skip=X of=B seek=Y

Upvotes: 1

Related Questions