In the last section of this lab, you recovered lost data using zfs snapshot. Now, we will get to know another very useful function of ZFS: filesystem cloning.

2.3. Clone Filesystems using ZFS

Open your browser and navigate to your share.
The fastest way to get there is by clicking shares in the top menu and then do a double click on your share. On the new page, go to snapshot.

To clone your filesystem, you first have to take a snapshot. We already did this in the last section, so you can use this and go straight to the cloning.

Hover with your mouse over mysnap2 and again the three icons should appear on the right side. This time, click the one in the middle (a plus sign).
ZFSAttack_02_16_clone1
Enter a name of your choosing and click apply.
ZFSAttack_02_17_clone2
And that’s it.

Notice the “1” in the clone column of mysnap2. If you hover over mysnap2, there should appear a show next to this 1. Click on this link to open a popup with information for all the clones of that snapshot.
ZFSAttack_02_18_clone3
You can see the entry from the clone, you just created.

Next, go to shares in the top menu and you should see both shares, the original one and the clone.
ZFSAttack_02_19_clone4
Notice the mountpoint of the clone, which is automatically set to /export/myclone
also notice the size of the two filesystem. Although both contain exactly the same data, the clone is a lot smaller, than the original. That is because for a clone ZFS stores only those data blocks on disk, that have changed since the clone was taken.

Now, go to your database machine (login as root), open a shell and mount the new share.

[root@localhost ~]# mkdir /mnt/clone
mount 192.168.56.100:/export/myclone /mnt/clone/

check, that both mounts are in place

[root@localhost ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
192.168.56.100:/export/myshare
                       20G     0   20G   0% /mnt/zfsapp
192.168.56.100:/export/myclone
                       20G     0   20G   0% /mnt/clone

You should also see the important.txt inside the new share.

[root@localhost ~]# cd /mnt/clone/
[root@localhost clone]# ls -la
total 11
drwx------+ 3 nobody     bin           3 Aug 19  2013 .
drwxr-xr-x  6 root       root       4096 Aug 19 04:55 ..
-rw-r--r--+ 1 nobody     nobody       18 Aug 19  2013 important.txt
dr-xr-xr-x+ 4 root       root          4 Aug 19  2013 .zfs
[root@localhost clone]# cat important.txt 
do not loose this

As you can see, this is the same data, as in the original filesystem.

That concludes the second lab of this workshop. In lab 3, we will take a look at replication between two ZFS Appliances.

<-- back to the beginning | go to next lab –>

Leave a Reply

Your email address will not be published. Required fields are marked *