SUMMARY: Comparing two directories

From: Trevor Osatchuk <Trevor.Osatchuk_at_pscl.com>
Date: Wed, 05 Sep 2001 09:49:48 -0600

After reading the responses I received, I did a df -k on both /mnt and
/usr/newpartition and redirected the output to files. What I found after
doing a diff on these files was that the discrepancies could be accounted
for by comparing sizes of directories, not regular files. All of the file
sizer were identical. As was explained to me by Brad Bell:

        If you have a directory on the old partition that contained more
        files at one time, which have since been deleted, the directory
        space will have a larger disk allocation - but it will be mostly
        empty space. When the files are copied to the new partition, the
        new directory will take up less space, because the empty directory
        entries are not copied.

It seems that directories will grow as you add files to them, but do not
shrink unless removed and then remade. As there were no size differences in
any of the files, only in directories, so I would have to guess that this is
the reason I saw my discrepancy. I would also like to thank James
Sainsbury, Cathy Chandra and Tom Blinn for their input.

Orignial post below:


> This should be a pretty simple one. I had a partition on a 4.0f box that
> I wanted to copy over to a 4.0d box. I want to use the disk on the 4.0f
> box for something else so I made a partition on the 4.0d box, mounted the
> 4.0f partition to /mnt via nfs and ran:
>
> tar -cvpf - /mnt | ( cd /usr/newpartition && tar -xvpf - )
>
> This copied everything over to the new partition. Now, I want to be sure
> that everything got copied over and that the integrity of the data in
> intact. I did a df -k and got:
>
> Filesystem 1024-blocks Used Available Capacity Mounted on
> /dev/rz1a 244891 54461 165940 25% /
> /proc 0 0 0 100% /proc
> /dev/rz1g 3914988 1796681 1726808 51% /usr
> /dev/rz0g 4054823 2473054 1176286 68% /usr/stuff
> /dev/rz6c 4102391 1222772 2469379 34%
> /usr/newpartition
> 4.0fAlpha:/mnt 7091761 1222781 5159803 20% /mnt
>
> as you can see, the /usr/newpartition and the /mnt partition differ in
> size by 9 Kbytes. I ran a diff and got:
>
> /> diff -r /mnt /usr/newpartition
> File /mnt/data/socket/trv is a unknown while file
> /usr/newpartition/data/socket/trv is a regular file
> File /mnt/data/socket/uoa is a unknown while file
> /usr/newpartition/data/socket/uoa is a regular file
>
> So then I did:
>
> /mnt/data/socket> ls -l /mnt/data/socket
> total 0
> srw-rw---- 1 root system 0 Jan 7 2000 trv
> srw-rw---- 1 root system 0 Jan 12 2000 uoa
> /mnt/data/socket> ls -l /usr/newpartition/data/socket
> total 0
> -rw-rw---- 1 root system 0 Jan 7 2000 trv
> -rw-rw---- 1 root system 0 Jan 12 2000 uoa
>
> Now, these are the only files that showed up after the diff and they don't
> have any size difference. So, why is there the discrepancy in size? Does
> this have to do with dissimilar disk geometry? I also did df -k on the
> 4.0f machine in case nfs was the culprit, but it reported the same size.
> Can anyone explain to me why the difference? Was there a better way to
> copy the partition data? Is there a better way to compare the directory
> structures?
>
> Thanks!
>
> Trevor Osatchuk
> Process Solutions Canada Ltd.
> Support and Integration Analyst
> (780) 452-2227 Ext. 286
> trevor.osatchuk_at_pscl.com
>
> Any man whose errors take ten years to correct is quite a man.
> - J. Robert Oppenheimer, speaking of Albert Einstein
>
Received on Wed Sep 05 2001 - 15:56:30 NZST

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:42 NZDT