# ZFS Questions



## markfisher (Jul 12, 2013)

Hi, 

I'm very new to ZFS and I want to move from UFS to ZFS. There are lots of tutorials in this forum about ZFS and encryption. I always slice my hard drive for /home, /usr, ... when I'm using UFS. Tutorials I found here on ZFS are using 2 slices, one for /boot and one for the rest.

My questions about ZFS are:

In ZFS, is it right and efficient to slice the hard drive the way I used to for UFS?
How easy would be to add a new hard drive to an existing ZFS pool?

Thanks*.*


----------



## kpa (Jul 12, 2013)

With ZFS you can create datasets (filesystems in the usual lingo) on the fly and use them as you wish by setting the mountpoint properties for them. There is no need to "partition" the disks in the usual sense other than allocating space on the disk that makes up the ZFS pool.

Adding a new disk to a ZFS pool is just a `zpool add pool newvdev` operation. A vdev is a ZFS concept that can be a single disk or it can be a mirror or RAID-Z array of disks that has built in redundancy.


----------



## markfisher (Jul 12, 2013)

@kpa,

Thanks for your reply. Do you know by any chance what kernel option(s) do I need for ZFS? Also is it safe to remove UFS kernel options (my concern is swap partition)?

Thanks again for your help.


----------



## kpa (Jul 12, 2013)

ZFS is included by default in the GENERIC kernel but only as a loadable module zfs.ko because of licensing.  I wouldn't remove anything related to UFS from the kernel. The savings would be very minimal and you lose the ability to create UFS filesystems on for example md(4) RAM disks.


----------



## ShelLuser (Jul 12, 2013)

markfisher said:
			
		

> Do you know by any chance what kernel option(s) do I need for ZFS?


You basically need to load the ZFS module. Here is a very good thread which gives more details on how you could set up FreeBSD with only using ZFS. As you can see you basically need to specify that you want ZFS loaded (in /boot/loader.conf) and started (in /etc/rc.conf) and that's basically it. Though it helps to tune your system a little as well of course.



			
				markfisher said:
			
		

> Also is it safe to remove UFS kernel options (My concern is swap partition)?


That depends a little what your goal is. If you want to use a ZFS only system then this should be perfectly doable. You can create a ZFS filesystem in the ZFS pool and then tell FreeBSD to use it for swapspace. As also mentioned in the thread I posted above; all you'd need for that is to specify the org.freebsd:swap ZFS filesystem option.


----------



## Sylhouette (Jul 12, 2013)

I use this guide for root on ZFS.

This way you create an extra partition for the swap, and mount it through fstab like a regular UFS machine. Do not ask me why I prefer this but I did read about issues with swap on ZFS somewhere so I started to create the swap partitions separately. I have no trouble what so ever with this setup.

Do not add disks to the system without any redundancy. On a single disk system this is fine, you know the risk, disk crash is bye bye data, but if you add more disks to the pool without redundancy the whole pool will be destroyed if a single disk fails. I can not imagine that you want that and with each single disk vdev you add to the pool the risk of a failure and thereby loosing the whole pool gets bigger.

A zpool is made out of vdevs, and a vdev is a single disk (no redundancy what so ever) a mirrored disk pair or a RAID-Z, RAID-Z2 or RAID-Z3 set of disks, you can create a vdev from a set of USB disks or even a set of files if you like. a RAID-Z1 vdev needs at least three disks, and you can loose one disk, a RAID-Z2 vdev needs at least four disks but it can withstand a loss of two disks, a RAID-Z3 vdev can withstand a loss of three disks.

If you don't mind loosing ALL your data, adding a singe disk vdev is fine. If however you do not like to loose all data you need a pool that can survive disk loss.

You can create a new pool with a mirrored vdev or add a RAID-Z1, -Z2 or -Z3 vdev. This way you can loose the operating system when the root pool disk crashes, but your other data is protected by the mirrored or RAID-Z vdev. Reinstall the OS on a new disk, import the data pool and you are back in business

If however you do not want to loose your OS, then you need to mirror it later on. You can ATTACH a disk to the already available disk. This way your root pool is mirrored. Then you can ADD another vdev to the SAME pool. You cannot create a RAID-Z form a already active vdev, it is also not possible to add disks to a RAID-Z(x) vdev. You can create mirrors from single disks vdevs by attaching a disk to the single disk vdev.

I hope it helps and I hope I did not make things more difficult. 

*R*egards
Johan


----------



## kpa (Jul 12, 2013)

Before I forget, one warning about ZFS. Think in advance and test everything you're going to do on a test/virtual machine. You can't for example remove a vdev from the pool once it has been added. It's permanent and the only way to undo the addition is to redo the pool from scratch. One of the common mistakes with ZFS is to `zpool add` a single disk to a pool that is otherwise composed of redundant vdevs (mirrors or raidzs). Adding the single disk throws away all redundancy in the pool because data is now striped (in RAID0 fashion) between the redundant vdevs and the new non-redundant single disk vdev.


----------



## markfisher (Jul 13, 2013)

@kpa, and @Sylhouette

Thank you guys so much for all th_at_ information.


----------



## Sylhouette (Jul 13, 2013)

@kpa

If you make that mistake by adding a single disk vdev, and you cannot destroy the pool. Then you can add redundancy by attaching a second disk to the single disk vdev. It will become a mirrored vdev.

Regards
Johan


----------

