On Sat, 29 Jan 2011 17:45:30 +0100 Alex Schuster <wo...@wonkology.org> wrote:
> Ah, now I get it. There's a -c missing after the sh command. Right, thans for spotting it. > > I should have added that, to do it safely, the target should reside > > higher than the source in the hierarchy, or it should be on a different > > filesystem and in that case -xdev should be specified to find > > (otherwise an recursive loop would result). > > Right, but not important in my case. I want to mount my backup drive to > /mnt, cd /mnt, and duplicate all stuff soemwhere else, without taking up > much space. Then I can remove the backup drive and I only have to mount > it again when I need a file's content, but not for finding out which > files there are and how much space they take. Well, the space already is > in the file created by du -m, but I'd like to directly navigate around. Oh, I see now: you want the files to *look like* the real ones (eg when doing ls -l etc.), but be sparse so they don't take up space? > Sparse files would be nice because then I do not only have the same > logical structure, the files also appear to have the same size as the > originals, instead of having a size of 0. I could navigate and explore > the directory structure with mc, and with du --apparent-size I could find > out how much space a subdirectory takes. Again, my du -m file already has > this information, but while navigating in the directory tree, being able > to use du would be nice. Ok, one way to create a sparse file of, say, 1 megabyte is using dd: # dd if=/dev/null of=sparsefile bs=1 seek=1M 0+0 records in 0+0 records out 0 bytes (0 B) copied, 2.5419e-05 s, 0.0 kB/s # ls -l sparsefile -rw-r--r-- 1 root root 1048576 Jan 29 11:57 sparsefile # du -B1 sparsefile 0 sparsefile Another way, already suggested, is by using truncate, eg # truncate -s 1M sparsefile