I had 43GB of JPEGs to copy from one disk to another. Each file has two
directory entries i.e. two hardlinks which I want preserved (because I didn't
want to copy 86GB of data to the destination disk). For bulk copying of
data, I tend to do
find * | cpio -pmd destdir
Another option is to use cp -a (I'm using find | cpio for years, something I
started to do on Unices which didn't have a -a option to cp) and another is
tar cf - * | (cd destdir; tar xfBp -)
which I used to use before I started using find | cpio.
However, both the cp and cpio methods failed for me here - they didn't
maintain the symlinks and filled the destination disk. What's curious is
that I knew this was an issue and I did a test run without about 1GB of data
and that worked fine - the files were copied c/w hard links.
I was about to try using the tar method when Paul Kelly suggested using
rsync (a great program, and one I use a lot for syncing remote and local
files, and also for syncing two local disks - but I don't tend to think of
it for simple copying) and a quick perusal of the manual showed that it had
a specific command line option (-H) to preserve hardlinks.
To cut a long story short, rsync did the business. The whole thing however
leaves a sour taste in my mouth WRT cp and cpio though. I find it very
strange and disturbing that these programs will work in two different ways
depending on how much data is being copied.
OK - just had a quick look at the cpio source - it maintains a hash of
filenames and inode numbers. I'm no algorithm expert but I suspect that
perhaps this hash implementation falls over when presented with ~100000
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!