spliting files with dd
[Warning: This post is a backup recovery from my previous Wordpress blog. All content was automatically converted accessing a MySQL database using a Python script (details). Mostly are in Portuguese but if you are interest I can translate to English. If you found any problem dont’t hesitate to contact me in comments.]
It's just in case that you don't have* want use split... (that is much easy). Suppose that you have a 20MB ogv movie and you want split in four parts of 5MB. You can just do:
dd if=MOVIE.ogv of=pt1 bs=1M count=5 dd if=MOVIE.ogv of=pt2 bs=1M skip=5 count=5 dd if=MOVIE.ogv of=pt3 bs=1M skip=10 count=5 dd if=MOVIE.ogv of=pt4 bs=1M skip=15
To merge again…
cp pt1 final.ogv # you can ommit this temporary file by using pt1 as final file dd if=pt2 of=final.ogv bs=1M seek=5 count=5 dd if=pt3 of=final.ogv bs=1M seek=10 count=5 dd if=pt4 of=final.ogv bs=1M seek=15
After you can verify the integrity by using some hash generator, md5sum or sha1sum are examples.
$ md5sum final.ogv MOVIE.ogv 71ac8962779dcb733599dba1ce54d783 final.ogv 71ac8962779dcb733599dba1ce54d783 MOVIE.ogv
- this will never happen since both dd and split are on coreutils package.
Code
I wrote a simple proof-of-concept to demonstrate, just:
$ git clone git://gist.github.com/630395.git split-sh