Getting Started with ZFS on Solaris

If you have been following along with my series on the SunFire V100 you know that I have installed Solaris 10 Core 8/7 onto it (adding in SSH and BASH packages to make it actually useful in the real world) and have put the root volume under the control of the Solaris Volume Manager or SVM which has mirrored it under RAID 1. Now the final task for disk management is to create the ZFS storage that will exist on the large, remaining section of the disks.

Getting Starting – Prepping the Disks

Since we are not working with dedicated drive devices to use for ZFS we need to prepare some slices that we will be assigning to our ZFS pool or zpool. To complete the use of my disk space I use the format command to add a 106.44GB partition (that is block 10822 – 65533) to slice 5 on both of my drives. Now we have the space ready to be added to our first zpool.

Creating the ZPool

A zpool refers to a group of virtual (or physical) devices that will be incorporated together as a single entity under ZFS. The zpool system is analogous to logical volume management and is used instead of SVM for ZFS. Since we are working with just two drives here – as that is all that can be held by the entry-level V100 server – we are limited to working with mirrored pools. If we had three or more devices then we could opt to use RAIDZ. RAIDZ is SUN’s ZFS answer to RAID 5 but with better performance. Read Jeff Bonwick’s post for more detailed information. He explains it best.

For our simple mirroring purposes, we just use the zpool create command and select our zpool name, I chose “datapool”, and list your two slices. If you are following along on a V100 then everything should be exactly the same as mine. Feel free to use any name that makes sense for your pool.

# zpool create datapool mirror c0t0d0s5 c0t2d0s5

If all goes well you should now have your very first zpool. You can learn more about the state of your pool using zpool list and zpool status.

Creating a ZFS Filesystem

Creating our first ZFS filesystem is very easy. For my needs, I am only looking to create a single ZFS filesystem which spans the entire available space and will be eventually mounted simply as /data. For this I just need to use the simple zfs create command. Since we will probably want to be able to work with this new filesystem in the traditional manner using the commands mount and umount and by making a simple entry in the /etc/vfstab then we also need to complete the additional step of setting the mountpoint property to “legacy”. And, of course, make your mountpoint while you are at it.

# zfs create datapool/data
# zfs set mountpoint=legacy datapool/data
# mkdir /data

Add Your New ZFS Filesystem to /etc/vfstab

All that needs to be done is to open up your /etc/vfstab and add in the following line and ask Solaris to re-read the filesystem table.

datapool/data - /data zfs - yes -
# mount /data

That’s it. Now it is time to enjoy your new ZFS filesystem. Go ahead and move some shiny new files on there and try it out. Unless you are like me and would like to compress the files going onto your new partition in which case we have one last task to perform. Let’s issue the zfs set command to set our compress to on. This is very simple and straightforward.

# zfs set compress=on datapool/data

Okay, you did it. Now your filesystem is ready to be used. Enjoy.

ZFS Resources:

Leave a Reply