You are on page 1of 41

Oracle Solaris 11 Hands On Lab #

Oracle Solaris 11 ZFS File System


1 Introduction
Oracle Solaris ZFS is a revolutionary file system that changes the way we manage
storage. Participants in this lab will gain awareness through example of devices,
storage pools, and performance and availability. We will learn about the various
types of ZFS datasets and when to use each type. We will examine snapshots,
cloning, allocation limits, and recovering from common errors.
We will cover the following areas around ZFS:
-

Zpools
Vdevs
ZFS datasets
Snapshots / Clones
ZFS properties
ZFS updates

These exercises are meant to provide a primer into the value and flexibility of Oracle
Solaris 11 ZFS for the enterprise. Upon completion of this lab, the learner will
understand the simplicity and power of the ZFS file system and how it can help
address business requirements with Oracle Solaris 11 storage technology and will
be well on their way to mastering this powerful technology.

2 Overview
ZFS is the default file system in Oracle Solaris 11. This lab will follow the basic
system administration duties revolving around storage in a basic system. As in any
installation or implementation well follow a basic path for building our storage
infrastructure
1) Hardware setup and initial storage connection and assignment. (VirtualBox,
virtual disks, and files)
2) Creating pools. Storage devices in ZFS are grouped into pools. A pool
provides all of the storage allocations that are used by the file systems and
volumes that an installation will require.
3) Creating file systems which can be assigned to users and applications and
For Oracle employees and authorized partners only. Do
not distribute to third parties.
2011 Oracle Corporation

Page 1 of 41

Oracle Solaris 11 Hands On Lab #


manipulated to fit the needs of each.
4) Details around each of the above resulting in a complete storage picture for
Oracle Solaris 11 from which the learner can begin to develop more
expertise.
5) We will use the VirtualBox application to create virtual SAS disks that Oracle
Solaris 11 can work with just like real disks.
6) We will create files within the operating system to work with for simplicity.
The files are treated just like disks and working with them would be no
different than working with a large storage array connected to a customer
system.

3 Pre-requisites
This lab requires the use of the following elements:

A current laptop with at least 3GB memory and 100GB free disk space
Oracle VirtualBox Software (4.0.16 with Extension Pack installed)
Oracle Solaris 11 11/11 PreBuilt VM for Oracle VM VirtualBox

The following assumptions have been made regarding the environment where this
lab is being performed:
1. Network connectivity to the Internet is not necessary
2. We will only work with a single Solaris 11 Virtual Instance

4 Lab Setup
4.1 Oracle VirtualBox Hypervisor Software basics
Your system should already have Oracle VirtualBox hypervisor software installed
and ready to use. For this lab we will require a GUI interface and will be using the
pre-built Oracle Solaris 11 VM image. We only need to acquire it and import it to
get running quickly.
Download Virtual Box
VirtualBox Installation Notes:

VirtualBox mouse capture can sometimes be frustrating in the way it handles


mouse interaction between VBox and your OS. Use the right control key on
your keyboard to return mouse control back to your default environment.
You can change this in VirtualBox preferences.

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2011 Oracle Corporation

Page 2 of 41

Oracle Solaris 11 Hands On Lab #


4.2 Oracle Solaris 11 VM Image installation

Make sure that you have the Oracle Solaris 11 VM Image copied to your
laptop hard disk.
Unzip the Solaris 11 image to your hard disk
In the VirtualBox Manager Screen click New
Click Next on the welcome screen
Click on the File Menu and
choose Import Appliance

Welcome to the Appliance


Import Wizard! Click the
Choose button.

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2011 Oracle Corporation

Page 3 of 41

Oracle Solaris 11 Hands On Lab #


Navigate to the folder
where you downloaded or
copied the Oracle Solaris 11
PreBuilt image and click
Open. The file is named
OracleSolaris11_11-11.ovf.
The .ovf extension indicates
that its a virtual box export.

Next to the Choose button


it will indicate the file
youve chosen to import.
Click Next >

Youll be presented with the


Appliance Import settings.
We will accept the defaults.
Click Import.

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2011 Oracle Corporation

Page 4 of 41

Oracle Solaris 11 Hands On Lab #


The progress bar will show
the import progress.
Usually looks slow in the
beginning but this shouldnt
take more than a few
minutes.
Your new image has been
imported and is ready for
use. Lets just make some
simple changes, add some
disks, and well be ready for
the labs.

Make sure your new image


is selected and choose
Settings, Storage

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2011 Oracle Corporation

Page 5 of 41

Oracle Solaris 11 Hands On Lab #


On the bottom of the
Storage Tree section click
on the green plus sign to
Add a new SAS controller
to our virtual image.

Click on the disk icon to the


right of the SAS controller
you just added to add a new
hard disk.

In the resulting dialog box,


choose Create new disk

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2011 Oracle Corporation

Page 6 of 41

Oracle Solaris 11 Hands On Lab #


The virtual disk creation
wizard will start up. Choose
the default selection of VDI
and click Next >

Click Next > for Dynamically


Allocated

Name the disk 4GBDisk1


and either choose 4GB with
the slider or type in the
number 4.00 GB into the
text box. Choose Next >

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2011 Oracle Corporation

Page 7 of 41

Oracle Solaris 11 Hands On Lab #


Youll receive a Summary of
your disk selection. If all
looks good, click Create.

After your disk is created


you should now have a
virtual disk named
4GBDisk1 underneath your
new SAS controller.

Repeat the above steps to


create 3 more 4GB virtual
disks under the same SAS
controller and name them
4GBDisk2, 4GBDisk3, and
4GBDisk4 respectively.
Verify your settings match
the scre
en to the left.

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2011 Oracle Corporation

Page 8 of 41

Oracle Solaris 11 Hands On Lab #

4.3 Install and Configure Oracle Solaris 11 Virtual Image


In this lab we are utilizing a pre-built Oracle Solaris Image. This image is based on
the desktop version and we will be running in the Gnome environment. Even
though the system has been pre-installed, we still have to answer the basic
installation questions in order to get things running for the ZFS lab. The system will
run through the basic set up dialog as illustrated below.
Upon startup youll be
presented with the GRUB
menu. Select Oracle Solaris
11 11/11 and press the
return/enter key

After a few minutes you


should see the SCI welcome
screen where youll answer a
few simple questions in
order to bring the system up.
You should recognize this
step from earlier installation
labs. Press the <F2> key.

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2011 Oracle Corporation

Page 9 of 41

Oracle Solaris 11 Hands On Lab #


In the next screen well name
our system and choose how
we want to configure
networking. Name your
system zfslab and choose
Automatically for network
configuration. We will not
use any networking for this
lab so dont worry about this
selection.

The next screens will ask


about your region, time zone,
etc. Choose UTC/GMT to
avoid the time zone screens
or select your local time
zone.

The next screen will ask for


the Root password, and to
create a user account. Use
the below values if you wish
for consistency in the labs.
Root password: solaris11
Your real name: Lab User
Username: labuser
User password: solaris11

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2011 Oracle Corporation

Page 10 of 41

Oracle Solaris 11 Hands On Lab #


You should see a
confirmation screen. Review
and press <F2> to proceed
with configuration.

The System Configuration


Tool will exit and the system
will come up with your new
configuration parameters.
Wait for the GNOME login
screen and login as labuser,
password, solaris11.

Well do our labs from


terminal windows within the
Oracle Solaris 11 GUI.
Congratulations, youre up
and running! Now lets get
started with ZFS.

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2011 Oracle Corporation

Page 11 of 41

Oracle Solaris 11 Hands On Lab #


5 Working with Pools
5.1 Verifying the SAS and flat file disk devices
Its easier to work as root during the labs, remember to su - to root when first
logging in because root is a role and not a user. Lets su to root, confirm our
environment, and create some disk files before we get started with ZFS.
su to root,
to confirm that our 4 SAS disks are available to the system. cd to the /dev/dsk
directory and create 4 disk files using the mkfile command.
# format < /dev/null
# cd /dev/dsk
# mkfile 200m disk1 disk2 disk3 disk4
# ls l disk*

Confirm youve created the four disk files.

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2011 Oracle Corporation

Page 12 of 41

Oracle Solaris 11 Hands On Lab #


5.2 Creating and destroying pools
To create your first pool
# zpool create datapool raidz disk1 disk2 disk3 disk4
That's all there is to it. We can use zpool status to see what our first pool looks like.
# zpool status datapool

Note from this output that the pool names datapool has a single ZFS virtual device
(vdev) called raidz1-0. That vdev is comprised of our four disk files that we created
in the previous step.
The RAIDZ1-0 type vdev provides single device parity protection, meaning that if
one device develops an error, no data is lost because it can be reconstructed using
the remaining disk devices. This organization is commonly called a 3+1, 3 data disks
plus one parity.
ZFS provides additional types of availability: raidz2 (2 device protection), raidz3 (3
device protection), mirroring and none. We will look at some of these in later
exercises.
Before continuing, let's take a look at the currently mounted file systems.
# zfs list

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2011 Oracle Corporation

Page 13 of 41

Oracle Solaris 11 Hands On Lab #

One thing to notice in the ZFS makes things easier category is that when we created
the ZFS pool with one simple command, ZFS also created the first file system and
also mounted it. The default mountpoint is derived from the name of the pool but
can be changed easily.
Note:
Things we no longer have to do with ZFS are
Create a filesystem
Make a directory to mount the filesystem
Add entries to /etc/vfstab
Weve decided that we need a different type of vdev for our datapool example. Lets
destroy this pool and create another.
# zpool destroy datapool
# zfs list

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2011 Oracle Corporation

Page 14 of 41

Oracle Solaris 11 Hands On Lab #

All file systems in the pool have been unmounted and the pool has been destroyed.
The devices in the vdev have also been marked as free so they can be used again.
Notice how easy it is to destroy and theres no destroy? Are you sure? warning.
Next, lets create a simple pool using a 2 way mirror instead of raidz.
# zpool create datapool mirror disk1 disk2

Now the vdev name has changed to mirror-0 to indicate that data redundancy is
provided by mirroring (redundant copies of the data).
What happens if you try to use a disk device that is already being used by another
pool?
# zpool create datapool2 mirror disk1 disk2

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2011 Oracle Corporation

Page 15 of 41

Oracle Solaris 11 Hands On Lab #

The usage error indicates that /dev/dsk/disk1 has been identified as being part of an
existing pool called datapool. The -f flag to the zpool create command can override
the failsafe in case datapool is no longer being used, but use that option with
caution.

5.3 Adding capacity to a pool


Our application has made it necessary to add more space the the datapool. The
next exercise will show you how simple it is to add capacity to an existing pool.
# zpool list datapool
# zpool add datapool mirror disk3 disk4
# zpool status datapool

Note that a second vdev (mirror-1) has been added to the pool.
To see if your pool has actually grown, do another # zfs list command.
# zfs list datapool

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2011 Oracle Corporation

Page 16 of 41

Oracle Solaris 11 Hands On Lab #

Datapool has grown from 195MB to 358MB


Notice that you don't have to grow file systems when the pool capacity increases.
File systems can use whatever space is available in the pool, subject to quota
limitations, which we will examine in a later exercise.

5.4 Importing and exporting pools


ZFS zpools can also be exported, allowing all of the data and associated
configuration information to be moved from one system to another. For this
example, use the two SAS disks (c4t0d0 and c4t1d0).
# zpool create pool2 mirror c4t0d0 c4t1d0
# zpool status pool2

As before, we have created a simple mirrored pool of two disks. In this case, the disk
devices are real disks, not files. We've told ZFS to use the entire disk (no slice
number was included) and if the disk was not labeled, ZFS will write a default label.
ZFS Storage pools can be exported in order to migrate them easily to other system.
Storage pools should be explicitly exported to indicate that they are ready to be
migrated. This operation flushes any unwritten data to disk, writes data to the disk
indicating that the export was done, and removes all knowledge of the pool from the
system.
Lets export pool2 so that another system can use it.

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2011 Oracle Corporation

Page 17 of 41

Oracle Solaris 11 Hands On Lab #


# zpool list

# zpool export pool2


# zpool list

Note that our pool, pool2 is no longer in our list of available pools.
The next step will be to import the pool, again showing how easy ZFS is to use.
# zpool list

# zpool import pool2


# zpool list

Notice that we didn't have to tell ZFS where the disks were located. All we told ZFS
was the name of the pool. ZFS looked through all of the available disk devices and
reassembled the pool, even if the device names had been changed.
If you dont know the name of the pool ZFS will provide the names of available
For Oracle employees and authorized partners only. Do
not distribute to third parties.
2011 Oracle Corporation

Page 18 of 41

Oracle Solaris 11 Hands On Lab #


pools.
# zpool export pool2
# zpool import

Import your pool.


# zpool import pool2
Without an argument, ZFS will look at all of the disks attached to the system and will
provide a list of pool names that it can import. If it finds two pools of the same name,
the unique identifier can be used to select which pool you want imported.

5.5 Pool properties


There are many pool properties that can be customized for your environment. To
see a list of these properties type the following command.
# zpool get all pool2

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2011 Oracle Corporation

Page 19 of 41

Oracle Solaris 11 Hands On Lab #

Pool properties are described in the zpool(1M) man page. Pool properties provide
information about the pool, effect performance, security, and availability. To set a
pool property, use zpool set. Note that not all properties can be changed (ex.
version, free, allocated).
Set the listsnapshot property to on. The listsnapshot (also listsnaps) controls
whether information about snapshots is displayed when the zfs list command is
run without the t option. The default value is off.
# zpool set listsnapshots=on pool2
# zpool get listsnapshots pool2

5.6 Upgrading pools


As with any software package, ZFS goes through upgrades over time. Lets take a
look at how we can find the zpool version number, features provided by that
version, and how we can potentially upgrade, or even downgrade our ZFS Pool
version to accommodate potential compatibility scenarios. To find out what
features have been added over time, use the below command.
# zpool upgrade -v

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2011 Oracle Corporation

Page 20 of 41

Oracle Solaris 11 Hands On Lab #

When you patch or upgrade Oracle Solaris, a new version of zpool may be available.
It is simple to upgrade or downgrade an existing pool. Well create a pool using an
older version number, and then upgrade the pool.
# zpool destroy pool2
# zpool create -o version=17 pool2 mirror c4t0d0 c4t1d0
# zpool get version pool2

Note that your pool is now at version 17.


The next step would be to upgrade the old pool to the latest version. Execute the

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2011 Oracle Corporation

Page 21 of 41

Oracle Solaris 11 Hands On Lab #


following commands.
# zpool upgrade pool2

Its that simple. Now you can use features provided in the newer zpool version, like
log device removal (19), snapshot user holds (18), etc.
This concludes the section on pools. There is a wealth of features that we havent
explored yet. Check out the man page for many other features that you can take
advantage of.
Lets clean up before proceeding to the next lab.
# zpool destroy pool2
# zpool destroy datapool

5.1 ZFS split command


A mirrored ZFS storage pool can be quickly cloned as a backup pool by using the
zpool split command.
First lets create a mirrored ZFS pool named pool3 with two of our SAS disks.
# format < /dev/null
# zpool create pool3 mirror c4t2d0 c4t3d0
# zpool status pool3

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2011 Oracle Corporation

Page 22 of 41

Oracle Solaris 11 Hands On Lab #

Remember that our pool is automatically mounted so lets go ahead and create some
data and store it in the resulting file system.
# ps fe > /pool3/psfile.txt
# ls l /pool3

First lets check the status of the file system for size and then lets split the pool and
create our instant backup copy. We will provide a name for the resulting second
pool and call it pool4.
#
#
#
#

zfs list pool3


zpool split pool3 pool4
zpool status
zfs list pool3

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2011 Oracle Corporation

Page 23 of 41

Oracle Solaris 11 Hands On Lab #

Note that our pool now only contains a single disk but the size is still the same. And
running the ls command shows that our file is still there and has not come to any
harm.

Our new pool doesnt show up in the list because it still needs to be imported. Lets
do that now.
# zpool import pool4
# zpool status pool3 pool4

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2011 Oracle Corporation

Page 24 of 41

Oracle Solaris 11 Hands On Lab #

That confirms our split pools. Now lets verify that our file has been duplicated in
the filesystem.
# ls l /pool3
# ls l /pool4

Now just for the heck of it, lets put the mirror back together. If this were a
production system you would ensure that complete and proper backups were done
before playing with splits and joins like this in a filesystem no matter how
trustworthy the software may be.
First well need to destroy pool4 because it has the disk we want to put back into the
mirror. Then well use the attach subcommand to bring a new disk into our
nonredundant single disk pool as a mirror. With the attach command you need to
list the existing device first and then the device you wish to join into the mirror.
# zpool destroy pool4

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2011 Oracle Corporation

Page 25 of 41

Oracle Solaris 11 Hands On Lab #


# zpool status pool3 pool4
# zpool attach pool3 c4t2d0 c4t3d0
# zpool status pool3

The mirrored pool is now back to normal and the file it contained is still intact.
# ls l /pool3

6 Working with datasets (file systems and volumes)


Now that we understand pools, the next topic is file systems. We will use the term
datasets because a zpool can provide many different types of access, not just
through traditional file systems.
As we saw in the earlier exercise, a default dataset (file system) is automatically
created when creating a zpool. Unlike other file system and volume managers, ZFS

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2011 Oracle Corporation

Page 26 of 41

Oracle Solaris 11 Hands On Lab #


provides hierarchical datasets (peer, parents, children), allowing a single pool to
provide many storage choices.
ZFS datasets are created, destroyed and managed using the zfs(1M) command.

6.1 Dataset lab setup


To begin working with datasets, let's create a simple pool, again called datapool and
4 additional datasets called bob joe fred and pat. Execute the following commands
on your system
#
#
#
#
#

zpool create datapool mirror c4t0d0 c4t1d0


zfs create datapool/bob
zfs create datapool/joe
zfs create datapool/fred
zfs create datapool/pat

Use the zfs list r datapool command to confirm your work.

By using zfs list -r datapool, we are listing all of the datasets in the pool
named datapool. As in the earlier exercise, all of these datasets (file systems) have
been automatically mounted.
If this was a traditional file system, you might think there was 19.55 GB (3.81 GB x
5) available for datapool and its 4 datasets, but the 4GB in the pool is shared across
all of the datasets. To see an example of this behavior, type the following
commands:
# mkfile 1024m /datapool/bob/bigfile
# zfs list -r datapool

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2011 Oracle Corporation

Page 27 of 41

Oracle Solaris 11 Hands On Lab #

Notice that in the USED column, datapool/bob shows 1GB in use. The other datasets
show just the metadata overhead (31k), but their available space has been reduced
to 2.95GB, the amount of free space available to them after the consumption of 1GB
by the datapool/bob dataset.

6.2 Hierarchical datasets


A dataset can have children, just as a directory can have subdirectories. For
datapool/fred, let's create a dataset for documents, and then underneath that,
additional datasets for pictures, video and audio. Execute the following commands:
#
#
#
#

zfs
zfs
zfs
zfs

create
create
create
create

datapool/fred/documents
datapool/fred/documents/pictures
datapool/fred/documents/video
datapool/fred/documents/audio

# zfs list -r datapool

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2011 Oracle Corporation

Page 28 of 41

Oracle Solaris 11 Hands On Lab #


6.3 ZFS dataset properties
ZFS datasets are flexible and can be manipulated with a myriad of properties. The
next short exercise will examine some ZFS dataset properties and how to
manipulate them and why.

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2011 Oracle Corporation

Page 29 of 41

Oracle Solaris 11 Hands On Lab #


As you can see, there are many dataset properties that can be set. For a complete
explanation of each property, consult the zfs(1M) man page. Well outline a few
examples in the following exercise.

6.4 Quotas and reservations


ZFS dataset quotas are used to limit the amount of space consumed by a dataset
and all of its children. Reservations are used to guarantee that a dataset has an
allocated amount of storage that cant be consumed by other datasets in use.
To set quotas and reservations, use the zfs set command.
# zfs set quota=2g datapool/fred
# zfs set reservation=1.5G datapool/fred
# zfs list -r datapool

The first thing to notice is that the available space for datapool/fred and all of its
children is now 2GB, which was the quota we set with the command above. Also
notice that the quota is inherited by all of the children.
The reservation is a bit harder to see.
Original pool size 3.91GB
In use by datapool/bob 1.0GB
Reservation by datapool/fred 1.5GB
So, datapool/joe should see 3.91GB - 1.0GB - 1.5GB = 1.4GB available.

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2011 Oracle Corporation

Page 30 of 41

Oracle Solaris 11 Hands On Lab #


6.5 Changing the mountpoint
With a traditional UNIX file systems changing a mountpoint would require a few
steps, including

Unmounting the file system


Making a new directory
Editing /etc/vfstab
Mounting the new file system

With ZFS it can be done with a single command. In the next example, let's move
datapool/fred to a directory just called /fred. First lets look at the current
mountpoint.
# zfs list -r datapool

Now lets change it.


# zfs set mountpoint=/fred datapool/fred
And look at it again.
# zfs list -r datapool

Notice that not only did the command change datapool/fred, but also all of its

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2011 Oracle Corporation

Page 31 of 41

Oracle Solaris 11 Hands On Lab #


children, in one single command.

6.6 ZFS Volumes (zvols)


Lets look at another type of dataset, the zvol and what it can do.
Volumes, or zvols, provide a block level (raw and cooked) interface into the zpool.
Instead of creating a file system where you place files and directories, a single object
is created and then accessed as if it were a real disk device. This would be used for
things like raw database files, virtual machine disk images and legacy file systems.
Oracle Solaris also uses this for the swap and dump devices when installed into a
zpool.
# zfs list r rpool

In this example, rpool/dump is the dump device for Solaris and it 516MB.
rpool/swap is the swap device and it is 1GB. As you can see, you can mix files and
devices within the same pool.
Unlike a file system dataset, you must specifically designate the size of the device
when you create it, but you can change it later if needed. It's just another dataset
property. Create a volume.
# zfs create -V 500m datapool/vol1
This creates two device nodes: /dev/zvol/dsk/datapool/vol1 (cooked) and
/dev/zvol/rdsk/datapool/vol1 (raw). These can be used like any other raw or
cooked device. We can even put a UFS file system on it.
# newfs /dev/zvol/rdsk/datapool/vol1

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2011 Oracle Corporation

Page 32 of 41

Oracle Solaris 11 Hands On Lab #

Expanding a volume is just a matter of setting the dataset property volsize to a new
value. Be careful when lowering the value as this will truncate the volume and you
could lose data. In this next example, let's grow our volume from 500MB to 1GB.
Since there is a UFS file system on it, we'll use growfs to make the file system use the
new space.
# zfs set volsize=1g datapool/vol1
# growfs /dev/zvol/rdsk/datapool/vol1

6.7 Snapshots and clones


ZFS provides the ability to preserve the contents of a dataset through the use of
snapshots. And snapshots are easy to create and take up virtually no space when
theyre first created. Type the below commands to create some snapshots.
# zfs snapshot datapool/bob@now
The value after the @ denotes the name of the snapshot. Any number of snapshots
can be taken.
# zfs snapshot datapool/bob@later
# zfs snapshot datapool/bob@waylater
# zfs list -r -t all datapool/bob

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2011 Oracle Corporation

Page 33 of 41

Oracle Solaris 11 Hands On Lab #

Note that the snapshots take up zero bytes.


Delete these snapshots as they wont be needed for the actual lab.
# zfs destroy datapool/bob@waylater
# zfs destroy datapool/bob@later
# zfs destroy datapool/bob@now
And verify that theyre gone
# zfs list r t all datapool/bob

We can use our point in time snapshots to create new datasets called clones Clones
are datasets, just like any other, but start off with the contents from the snapshot.
Clones and snapshots make efficient use of storage. Clones only require space for
the data that's different than the snapshot. That means that if 5 clones are created
from a single snapshot, only 1 copy of the common data is required.
Remember that datapool/bob has a 1GB file in it? Let's take a snapshot of the
datapool and then create some clones.
#
#
#
#
#

zfs
zfs
zfs
zfs
zfs

snapshot datapool/bob@original
clone datapool/bob@original datapool/newbob
clone datapool/bob@original datapool/newfred
clone datapool/bob@original datapool/newpat
clone datapool/bob@original datapool/newjoe

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2011 Oracle Corporation

Page 34 of 41

Oracle Solaris 11 Hands On Lab #

Use zfs list r o space datapool to illustrate whats going on.

We can see that there's a 1GB file in datapool/bob. Right now, that's the dataset
being charged with the copy, although all of the clones can use it.
Now let's delete it in the original file system, and all of the clones, and see what
happens.
# rm /datapool/*/bigfile
# zfs list r o space datapool

Notice that the 1GB has not been freed (avail space is still 382M), but the USEDSNAP
value for datapool/bob has gone from 0 to 1GB, indicating that the snapshot is

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2011 Oracle Corporation

Page 35 of 41

Oracle Solaris 11 Hands On Lab #


now holding that 1GB of data. To free that space you will have to delete the
snapshot. In this case you would also have to delete any clones that are derived from
it.
# zfs destroy datapool/bob@original
# zfs destroy R datapool/bob@original

# zfs list r o space datapool

The 1GB file that we deleted has been freed because the last snapshot holding it has
been deleted.
You can also take a snapshot of a dataset and all of its children. A recursive
snapshot is atomic, meaning that it is a consistent point in time picture of the
contents of all of the datasets. Use -r for a recursive snapshot.
# zfs snapshot -r datapool/fred@now
# zfs list -r -t all datapool/fred

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2011 Oracle Corporation

Page 36 of 41

Oracle Solaris 11 Hands On Lab #

Snapshosts can also be destroyed recursively using -r.


# zfs destroy r datapool/fred@now

The last item well cover is a new command in Oracle Solaris 11, the ZFS diff
command. The diff command enables a system administrator to determine the
differences between different ZFS snapshots.
Lets start by creating some snapshots and adding files to a users home directory.
Assuming you have the labuser in your Solaris instance lets use that home
directory for our example.
# zfs list r t all rpool/export
Create a text file in the users home directory and take a snapshot call the snapshot
snap1
# ps fe >> /export/home/labuser/psfile.txt
# zfs snapshot rpool/export/home/labuser@snap1

Verify your snapshot

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2011 Oracle Corporation

Page 37 of 41

Oracle Solaris 11 Hands On Lab #


# zfs list r t all rpool/export

Now lets create another file


# svcs -a >> /export/home/labuser/svcsfile.txt
Take another snapshot, call it snap2, and confirm your snapshots again.
# zfs snapshot rpool/export/home/labuser@snap2
# zfs list r t all rpool/export

Now lets run the diff command and see what happens.
# zfs diff rpool/export/home/labuser@snap1 \
rpool/export/home/labuser@snap2

Note: I planned this lab to just incorporate the files we created but since were on a
laptop the profile-5000-charging.csv file kind of popped in there, you may or may not
have that file in your output.

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2011 Oracle Corporation

Page 38 of 41

Oracle Solaris 11 Hands On Lab #


The output on the diff command indicates that the file or directory has been
modified with the M at the left side. The - indicates that the file or directory is
present in the older snapshot but not in the newer one. The + sign indicates that
the file or directory is present in the more recent snapshot but not in the older
snapshot. You might also see an R indicating that a file has been renamed in
between snapshots.

6.8 Compression
Compression is a useful feature integrated with the ZFS file system. ZFS allows both
compressed and noncompressed data to coexist. By turning on the compression
property, all new blocks written will be compressed while the existing blocks will
remain in their original state.
Lets create a 500MB file we can do some compression on. Type the following
commands:
# zfs list datapool/bob
# mkfile 500m /datapool/bob/bigfile
# zfs list datapool/bob

Now let's turn on compression for datapool/bob and copy the original 500MB file.
Verify that you now have 2 separate 500MB files when this is done.
Type the following commands:
# zfs set compression=on datapool/bob
# cp /datapool/bob/bigfile /datapool/bob/bigcompressedfile
# ls -la /datapool/bob

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2011 Oracle Corporation

Page 39 of 41

Oracle Solaris 11 Hands On Lab #

# zfs list datapool/bob


There are now 2 different 500MB files in /datapool/bob, but the ls command only
says 500MB is used. It turns out that mkfile creates a file filled with zeroes. Those
compress extremely well - too well, as they take up no space at all.
That concludes this lab on the ZFS File system, run this command to clean up the
work we did during the course of the lab.
# zpool destroy f datapool

7 Summary
In this lab you learned about the power of the ZFS File System in Oracle Solaris 11.
We discussed and performed exercises to familiarize you with zpools and virtual
devices (vdevs). We learned about ZFS datasets like snapshots and clones. You
were also exposed to the myriad of ZFS properties and ways that ZFS can easily be
updated.
The exercises were meant to provide initial exposure to these features and
hopefully a basis for continued learning and eventual expertise in this powerful
storage technology thats an integral part of Oracle Solaris 11.

8 Resources
For more information and next steps, please consult additional resources: Click the
hyperlinks to access the resource.
Oracle Solaris 11 ZFS Technology Page articles whitepapers, and more on ZFS
Oracle Solaris Admin: ZFS File Systems documentation on ZFS
ZFS Best Practices Guide excellent real world reference for all things ZFS
ZFS Evil Tuning Guide great resource for detailed tuning and hard to find
For Oracle employees and authorized partners only. Do
not distribute to third parties.
2011 Oracle Corporation

Page 40 of 41

Oracle Solaris 11 Hands On Lab #


parameters
Oracle Solaris 11 ZFS Administration Oracle University 4 day ILT training on ZFS

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2011 Oracle Corporation

Page 41 of 41

You might also like