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