22 February 2013

When ZFS for MAC came out with ZEVO, I did run to get the software and being used for about a year or so..

If you stay away enabling dedup, the filesystem run very good.

Today, I did format a 500gb disk to use for some VM's in my laptop. If those VM's die, it's ok, I usually have VirtualBox appliances, and backup of the software, so I could be able to start from scratch.

However, I will like to protect the whole disk file without having to backup, in case I drop the hdd (again), and some blocks came corrupted.

I did use the zfs option to have more copies stored on disk, in this case 2.

Disk just formatted

retina:~ mirandaa$ zfs get copies NAME PROPERTY VALUE SOURCE zfs500gb copies 1 local

Enable the option copy=2

retina:~ mirandaa$ zfs set copies=2 zfs500gb retina:~ mirandaa$ zfs get copies NAME PROPERTY VALUE SOURCE zfs500gb copies 2 local

let's write some data

100MB

retina:~ mirandaa$ df -h /Volumes/zfs500gb/
Filesystem   Size   Used  Avail Capacity iused     ifree %iused  Mounted on
/dev/disk2  457Gi  354Ki  457Gi     1%      70 957873343    0%   /Volumes/zfs500gb
retina:~ mirandaa$ dd if=/dev/zero of=/Volumes/zfs500gb/file bs=1024000 count=100
100+0 records in
100+0 records out
102400000 bytes transferred in 0.067305 secs (1521435685 bytes/sec)
retina:~ mirandaa$ df -h /Volumes/zfs500gb/
Filesystem   Size   Used  Avail Capacity iused     ifree %iused  Mounted on
/dev/disk2  457Gi  196Mi  457Gi     1%      71 957472837    0%   /Volumes/zfs500gb
retina:~ mirandaa$ ls -alh /Volumes/zfs500gb/file 
-rw-r--r--  1 mirandaa  staff    98M 22 Feb 13:31 /Volumes/zfs500gb/file

1GB

retina:~ mirandaa$ dd if=/dev/zero of=/Volumes/zfs500gb/file bs=1024000 count=1000
1000+0 records in
1000+0 records out
1024000000 bytes transferred in 32.551312 secs (31458025 bytes/sec)
retina:~ mirandaa$ df -h /Volumes/zfs500gb/
Filesystem   Size   Used  Avail Capacity iused     ifree %iused  Mounted on
/dev/disk2  457Gi  1.9Gi  455Gi     1%      71 953981891    0%   /Volumes/zfs500gb
retina:~ mirandaa$ ls -alh /Volumes/zfs500gb/file 
-rw-r--r--  1 mirandaa  staff   977M 22 Feb 13:32 /Volumes/zfs500gb/file
retina:~ mirandaa$ 

The system, is transparent, just just get more used space, and less free space:

This is an excerpt from an oracle post https://blogs.oracle.com/relling/entry/zfs_copies_and_data_protection

Using Copies

To change the numbers of data copies, set the copies property. For example, suppose I have a zpool named "zwimming." The default number of data copies is 1. But you can change that to 2 quite easily.

# zfs set copies=2 zwimming

The copies property works for all new writes, so I recommend that you set that policy when you create the file system or immediately after you create a zpool.

You can verify the copies setting by looking at the properties.

# zfs get copies zwimming
NAME      PROPERTY  VALUE     SOURCE
zwimming  copies    2         local

ZFS will account for the space used. For example, suppose I create three new file systems and copy some data to them. You can then see that the space used reflects the number of copies. If you use quotas, then the copies will be charged against the quotas, too.

# zfs create -o copies=1 zwimming/single
# zfs create -o copies=2 zwimming/dual
# zfs create -o copies=3 zwimming/triple
# cp -rp /usr/share/man1 /zwimming/single
# cp -rp /usr/share/man1 /zwimming/dual
# cp -rp /usr/share/man1 /zwimming/triple
# zfs list -r zwimming                                                       
NAME              USED  AVAIL  REFER  MOUNTPOINT
zwimming         48.2M   310M  33.5K  /zwimming
zwimming/dual    16.0M   310M  16.0M  /zwimming/dual
zwimming/single  8.09M   310M  8.09M  /zwimming/single
zwimming/triple  23.8M   310M  23.8M  /zwimming/triple

This makes sense. Each file system has one, two, or three copies of the data and will use correspondingly one, two, or three times as much space to store the data.

  • zfs 1
  • data protection 1