0

I got a new external disk to replace an older one that has shown signs of trouble. I used rsync to copy the contents of the old disk to the new one. To check if the copying had worked properly, I've done things like compare disk usage using du and df and done diffs. I noticed that the disk space usage on the new disk is significantly less than on the old one. This shows up for example doing (/backup is old disk, /backup1 is new disk):

> du -s /backup/laptop
5400764 /backup/laptop
> du -s /backup1/laptop
5308428 /backup1/laptop

but if I do diff -r /backup/laptop /backup1/laptop I get nothing. The only thing I see that could account for the differences is that the old disk uses the ext3 filesystem and the new one ext4. If anyone can shed any light on this, I'd appreciate it.

Thanks, Jon

1
  • The most likely reason is different block sizes, as shown by sudo fdisk -l with the description I/O size (minimum/optimal).
    – AFH
    May 25, 2018 at 23:32

1 Answer 1

0

Two possibilities come to mind. One is that rsync's --sparse file option, it's possible that files that contained zero blocks were written as sparse files, which would take up less space on disk.

The other (and more likely) potential cause is that like many Unix file systems, ext3 and ext4 do not compress directories after deleting entries from them. For example:

% mkdir test
% cd test
% ls -aldg .
drwxr-xr-x 2 tytso 4096 May 26 15:25 ./
% seq 1 10000 | xargs touch
% ls -aldg .
drwxr-xr-x 2 tytso 159744 May 26 15:26 ./
% rm -f *
% ls -aldg .
drwxr-xr-x 2 tytso 159744 May 26 15:26 .

Once this directory is copied to the destination file system, it will take 4k again.

You must log in to answer this question.