ZFS Basics: Pools and File Systems

You can do the exercises described below on any Oracle Solaris 11 machine, but we recommend using The Easiest Way to Start Learning About Oracle Solaris.

Exercise Z.1: ZFS Pools

Task: You have several disks to use for your new file system. Create a new disk pool and a file system on top of it.

Lab: We will check the status of disk pools, create our own pool and expand it.

Our Solaris 11 installation already has a ZFS pool. It's your root file system. Check this:

root@solaris:~# zpool list 
NAME    SIZE  ALLOC   FREE  CAP  DEDUP  HEALTH  ALTROOT
rpool  15.9G  5.64G  10.2G  35%  1.00x  ONLINE  -

This is our root system ZFS pool. In Solaris 11 the root file system must be ZFS created on top of ZFS pool. What do we know about this pool?

root@solaris:~# zpool status rpool 
  pool: rpool
 state: ONLINE
  scan: none requested
config:

	NAME        STATE     READ WRITE CKSUM
	rpool       ONLINE       0     0     0
	  c3t0d0s0  ONLINE       0     0     0

errors: No known data errors

Let's now create our own ZFS pool. What do we need for that? Just several disks and one command. We will create several files in /dev/dsk directory and they will act as disks in our lab. Note that in the command below we are using the bash(1) expansion to create 10 files with names from disk0 to disk9.

root@solaris:~# cd /dev/dsk 
root@solaris:~# mkfile 200m disk{0..9}

We'll take four disks and create a ZFS pool with RAID-Z protection:

root@solaris:~# zpool create labpool raidz disk0 disk1 disk2 disk3 

That was easy, wasn't it? And fast, too! Check our ZFS pools again:

root@solaris:~# zpool list 
NAME      SIZE  ALLOC   FREE  CAP  DEDUP  HEALTH  ALTROOT
labpool   780M   194K   780M   0%  1.00x  ONLINE  -
rpool    15.9G  7.57G  8.30G  47%  1.00x  ONLINE  -

By the way, the file system was also created and mounted automatically:

root@solaris:~# zfs list labpool 
NAME                     USED  AVAIL  REFER  MOUNTPOINT
labpool                 97.2K   551M  44.9K  /labpool

Do you need more space? Adding disks to the existing ZFS pool is as easy as creating it:

root@solaris:~# zpool add labpool raidz disk4 disk5 disk6 disk7 

Check it again:

root@solaris:~# zfs list labpool 
NAME      USED  AVAIL  REFER  MOUNTPOINT
labpool  97.2K  1.11G  44.9K  /labpool

Note the increased file system's size. Also note there are two disk groups in this pool both protected with RAID-Z. ZFS has many options to protects your data, you can learn and experiments with them later.

Exercise Z.2: ZFS File Systems

Task: You have to create home directories for your users; use file system quota to limit their space.

Lab: We'll create a user "joe" and set a disk quota for him.

Creating a user is pretty similar to most Unix/Linux systems. What's different is what's going on behind the scenes.

root@solaris:~# useradd -m joe 
root@solaris:~# passwd joe 
New Password: oracle1 
Re-enter new Password: oracle1
passwd: password successfully changed for joe

In Solaris 11 behind the scenes we create a separate ZFS file system for the user (parameter -m) in /export/home. Check it:

root@solaris:~# zfs list
NAME                     USED  AVAIL  REFER  MOUNTPOINT
labpool                 97.2K  1.11G  44.9K  /labpool
rpool                   7.65G  7.97G    39K  /rpool
rpool/ROOT              5.59G  7.97G    31K  legacy
rpool/ROOT/solaris      5.59G  7.97G  5.17G  /
rpool/ROOT/solaris/var   330M  7.97G   183M  /var
rpool/dump              1.03G  8.01G  1.00G  -
rpool/export            1.48M  7.97G    32K  /export
rpool/export/home       1.44M  7.97G    33K  /export/home
rpool/export/home/joe    686K  7.97G   686K  /export/home/joe
rpool/export/home/lab    760K  7.97G   760K  /export/home/lab
rpool/swap              1.03G  8.01G  1.00G  -

What does it mean for us, system administrators? That means we can use all kinds of ZFS features (compression, deduplication, encryption) on a per-user basis. We can create snapshots and perform rollbacks on a per-user basis. More about that later. Now we'll set a disk quota for joe's home directory.

root@solaris:~# zfs set quota=200m rpool/export/home/joe

Now change user to "joe" and check how much space you can use:

root@solaris:# su - joe 
joe@solaris$ mkfile 110m file1 
joe@solaris$ cp file1 file2 

First file was created OK, but with the second one we've got an error: "Disk quota exceeded".

Change the quota for joe in the other window:

root@solaris:~# zfs set quota=300m rpool/export/home/joe 

Then change back to the joe's window and try again:

joe@solaris$ cp file1 file2 

Success! As you can see, it's pretty easy to create and manage ZFS filesystems. Remember, as soon as creating file systems with ZFS costs you nothing, by default Oracle Solaris 11 creates a separate ZFS file system for each user. This gives you ability to make individual snapshots of users' home file systems, set compression, deduplication and encryption parameters on per-user basis. More about these cool ZFS features in the future labs.

Comments:

Post a Comment:
Comments are closed for this entry.
About

"I hear and I forget; I see and I remember; I do and I understand" -- Confucius

Search

Categories
Archives
« July 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  
       
Today