On Tue, Jul 10, 2012 at 6:29 AM, Jordi Espasa Clofent
<jespa...@minibofh.org> wrote:
> Thanks for you explanation Fajar. However, take a look on the next lines:
>
> # available ZFS in the system
>
> root@sct-caszonesrv-07:~# zfs list
>
> NAME                         USED  AVAIL  REFER  MOUNTPOINT
> opt                          532M  34.7G   290M  /opt
> opt/zones                    243M  34.7G    32K  /opt/zones
> opt/zones/sct-scw02-shared   243M  34.7G   243M  /opt/zones/sct-scw02-shared
> static                       104K  58.6G    34K  /var/www/
>
> # creating a file in /root (UFS)
>
> root@sct-caszonesrv-07:~# dd if=/dev/zero of=file.bin count=1024 bs=1024
> 1024+0 records in
> 1024+0 records out
> 1048576 bytes (1.0 MB) copied, 0.0545957 s, 19.2 MB/s
> root@sct-caszonesrv-07:~# pwd
> /root
>
> # enable compression in some ZFS zone
>
> root@sct-caszonesrv-07:~# zfs set compression=on opt/zones/sct-scw02-shared
>
> # copying the previos file to this zone
>
> root@sct-caszonesrv-07:~# cp /root/file.bin
> /opt/zones/sct-scw02-shared/root/
>
> # checking the file size in the origin dir (UFS) and the destination one
> (ZFS with compression enabled)
>
> root@sct-caszonesrv-07:~# ls -lh /root/file.bin
> -rw-r--r-- 1 root root 1.0M Jul 10 13:21 /root/file.bin
>
> root@sct-caszonesrv-07:~# ls -lh /opt/zones/sct-scw02-shared/root/file.bin
> -rw-r--r-- 1 root root 1.0M Jul 10 13:22
> /opt/zones/sct-scw02-shared/root/file.bin
>
> # the both files has exactly the same cksum!
>
> root@sct-caszonesrv-07:~# cksum /root/file.bin
> 3018728591 1048576 /root/file.bin
>
> root@sct-caszonesrv-07:~# cksum /opt/zones/sct-scw02-shared/root/file.bin
> 3018728591 1048576 /opt/zones/sct-scw02-shared/root/file.bin
>
> So... I don't see any size variation with this test.

ls(1) tells you how much data is in the file - that is, how many bytes
of data that an application will see if it reads the whole file.
du(1) tells you how many disk blocks are used.  If you look at the
stat structure in stat(2), ls reports st_size, du reports st_blocks.

Blocks full of zeros are special to zfs compression - it recognizes
them and stores no data.  Thus, a file that contains only zeros will
only require enough space to hold the file metadata.

$ zfs list -o compression ./
COMPRESS
      on

$ dd if=/dev/zero of=1gig count=1024 bs=1024k
1024+0 records in
1024+0 records out

$ ls -l 1gig
-rw-r--r--   1 mgerdts  staff    1073741824 Jul 10 07:52 1gig

$ du -k 1gig
0       1gig

-- 
Mike Gerdts
http://mgerdts.blogspot.com/
_______________________________________________
zfs-discuss mailing list
zfs-discuss@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/zfs-discuss

Reply via email to