The underlying raw disk blocks that a file uses can be seen with command filefrag. And in the example below I could use dd to copy all 11 chunks and cat them together to construct an exact copy of sample.avi.
I'm thinking there should already be a tool that does this but I could not find one. Is there such a tool? Or how would you reconstruct a file from it's block pieces programmatically?
# filefrag -b512 -v '/mnt/Shared Videos/sample.avi'
Filesystem type is: ef53
File size of /mnt/Shared Videos/sample.avi is 1425879476 (2784928 blocks of 512 bytes)
ext: logical_offset: physical_offset: length: expected: flags:
0: 0.. 262143: 15990784.. 16252927: 262144:
1: 262144.. 524287: 16252928.. 16515071: 262144:
2: 524288.. 786431: 16515072.. 16777215: 262144:
3: 786432.. 1048575: 17039360.. 17301503: 262144: 16777216:
4: 1048576.. 1310719: 17301504.. 17563647: 262144:
5: 1310720.. 1572863: 17563648.. 17825791: 262144:
6: 1572864.. 1835007: 17825792.. 18087935: 262144:
7: 1835008.. 2097151: 18087936.. 18350079: 262144:
8: 2097152.. 2359295: 18350080.. 18612223: 262144:
9: 2359296.. 2621439: 18612224.. 18874367: 262144:
10: 2621440.. 2784927: 18874368.. 19037855: 163488: last,eof
/mnt/Shared Videos/sample.avi: 2 extents found