29

I am making zpools on FreeBSD machine. While creating zpools I observe these two cases:

  1. If I take raw disks and create zpool then I am able to form zpools and they are working perfectly.

  2. If I format disks using gpart in freebsd-zfs format and then make zpool then also they are working perfectly.

What I am confused in, is which approach is better for creation of zpools?

1

4 Answers 4

14

It's better to use whole-disks with ZFS, when possible.
There's no need to partition in your use case.

8
  • 7
    What do you mean by your use case. Can you give some case where partitioning might be useful?
    – shivams
    Sep 15, 2014 at 15:54
  • 9
    But why is it better to use whole-disks? Dec 18, 2014 at 3:16
  • 2
    @leetNightshade It is not better.
    – Grogi
    Nov 10, 2016 at 11:17
  • 3
    @Grogi Any good evidence to back that up? Nov 10, 2016 at 19:28
  • 9
    When I set up ZFS for the first time, reading this answer gave me a misleading impression about the cost/risk of partitioning, so I decided to use whole disks. In fact my "esoteric" configuration (mirroring drives of different sizes) would have benefited from the use of partitions, and it seems from the other answers that there is no cost – "using whole disks" just means that ZFS automatically partitions them for you.
    – sjy
    Nov 16, 2019 at 0:42
17

Use one slice/partition dedicated for ZFS per physical disc and leave some space unpartitioned. That way if you ever need to replace a drive and the replacement is 10 sectors smaller, you'll still be able to do it (http://www.freebsddiary.org/zfs-with-gpart.php).

That's what Solaris automatically does, that's what FreeNAS does (https://forums.freenas.org/index.php?threads/zfs-on-partitioned-disks.37079/) and that's what ZoL does when you give it a whole disk ( it will partition it)...

The overhead to translate the position on the partition to the position on the actual device is negligible. So once the partition is correctly aligned to the physical sector boundary, there is no reason for it to behave differently than whole block device.

With ZoL, the only difference I am aware are is that ZoL will switch the disk scheduler to noop when whole disk was given to the vdev. Nothing stopping you from setting it manually.

There are some don't though... Don't create more partitions for ZFS per disk and if you decide to ignore the advice above, never ever build vdevs from them in same zpool. This will basically kill the performance, as ZFS will slice the data between the vdevs and sequential iops will turn into seek-nightmare...

6
  • 1
    Can you put some more light on zfs behaviour about seek-nightmare with disk slices being shared/used? Aug 16, 2018 at 16:04
  • Simplest scenario - you build a pool from two vdevs, each a partition on the same harddisk. Now, you want to write a data chunk big enough that spans across both vdevs. Despite sequentially writing data, the drive has to seek between two separate locations to save it.
    – Grogi
    Aug 17, 2018 at 17:32
  • Is this behaviour same if Pool_A uses(sda1,sdb1,sdc3) and Pool_B uses (sda2,sdb2,sdc3) Aug 19, 2018 at 14:51
  • 1
    Regarding With ZoL, the only difference I am aware are is that ZoL will switch the disk scheduler to noop when whole disk was given to the vdev. Nothing stopping you from setting it manually., may I ask if it is still true in 2022? How to check this? And how to set it manually? Thanks a lot.
    – midnite
    Jun 20, 2022 at 4:43
  • 1
    @midnite - you can check the current scheduler by reading /sys/block/{disk}/queue/scheduler.
    – Grogi
    Jan 10, 2023 at 14:03
5

People here claim you need to use whole disks to get disk write cache advantages, but that's not true. What is true is that ZFS will try to enable the disk write cache for you if you give it the whole disk. However, even if you just give it a single partition, nobody stops you from enabling the disk write cache yourself, in which case ZFS will detect that and honor it exactly the same was as if it had enabled the cache itself. So it's not a requirement to use whole disks getting write cache advantages, it only safes you the work to enable disk write cache yourself.

People here claim that disk access is faster if you give it the whole disk. While this statement is technically true, the speed difference is so tiny that it is entirely neglectable. If your ZFS setup is too slow, it will still be too slow if you only use entire disks. And if it is doing well with entire disk, it would do equally well with just single partitions.

One reason for not using the whole disk is that disk sizes do vary. Imagine the following case: You create a RAIDZ with 3 identical disks, each of them is 4 TB and you always use the full disk. After 3 years, one of the disk fails. No problem, you just buy a replacement but meanwhile that disk has a new hardware revision and the new 4 TB model is smaller by just 256 KB. It won't work! You cannot use it as replacement because it must have exactly the same size as your other two disks or be even bigger. If it is smaller, no matter by how little bytes, it won't work.

That's why I always create a partition and leave maybe 10 MB of the disk unused. Losing 10 MB per disk is close to nothing (0.00025% in case of 4 TB disks) and it means that a replacement disk could be up to 10 MB smaller and it would still work (or have up to 10 MB of bad sectors, etc.)

2
  • When you say "Use the full disk", do you mean that the disk is 100% full of data, or also if the disk is only 50% full of data?
    – Cwista
    Jan 25, 2023 at 21:53
  • 1
    @Ecker00 It has nothing to do with storage but how ZFS is accessing the disk. ZFS can either access the disk raw, in which case it directly accesses the storage blocks of the disk and the disk won't have a partition table at all or it can access the disk like any other filesystem through a partition table. In the first case, ZFS will use the entire disk as there is no way anyone else can use any portion of it, so all storage blocks of the disk at once belong to ZFS, in the second case only storage blocks assigned to the used partition are used by ZFS.
    – Mecki
    Jan 26, 2023 at 0:50
1

in my head this question arises because of doubt if i late can designate, what is on that disk... so when you create pool on whole drive (yes, with -f option, if needed), zpool practically create gpt partition table and partitions of Solaris, like this:

(fdisk -l ...)
...
Disklabel type: gpt
Disk identifier: 4CBE587E-23AF-8E4B-A7F0-B44AD6083171

Device          Start        End    Sectors  Size Type
/dev/sdd1        2048 3907010559 3907008512  1,8T Solaris /usr & Apple ZFS
/dev/sdd9  3907010560 3907026943      16384    8M Solaris reserved 1

so there really is no need to create partitions manually...

1
  • I do not consider what solaris does best practice on freebsd. For example in case of mirrors you can replace disks with a bigger ones and expand the pool size on the fly with one command or even automatically if configured as such.
    – cstamas
    Nov 25, 2018 at 0:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .