Disk partitioning prior to pool creation

New to OpenZFS on OS X (Or ZFS in general)? Ask your questions here!

Disk partitioning prior to pool creation

Postby zisper » Wed Jul 20, 2016 3:27 am


Is it possible to use zpool create one a full disk, whilst specifying the main partition size? My main use case would be to setup the partitions slightly smaller than the entire disk, so that I know any disks of the "same" size that I happen to purchase as replacements later on will be large enough to hold the ZFS partition. Eg, create a main 998Gb partition on 1TB hard disks.
I set a couple of disk up this way manually, formatting with diskutil, and it worked ok but I wasn't convinced that I'd created the partitions correctly. I'd rather have them structured/labelled as per the zpool create command.
I suppose the easier way is just to get the formatting/labelling correct via diskutil - any advice?
For an 8GB memory stick I was using:
Code: Select all
diskutil partitiondisk /dev/disk6 2 GPT ZFS ZFS 7.8G HFS+ Second 0.2G

But I don't know how I should specify the 2nd partition. I don't know where the name (something like 6A945A3B-1DD2-11B2-99A6-080020736631) comes from, or what format it should be, or how to make it occupy the remaining disk space.

Posts: 16
Joined: Wed Jul 20, 2016 2:48 am

Re: Disk partitioning prior to pool creation

Postby lundman » Wed Jul 20, 2016 9:51 pm

If you use zpool create -f POOL diskX and let ZFS partition it for you, it will shave off a little on the end of the disk automatically, to avoid the problem of slightly different sized HDDs.

But if you still want to do it, you can use diskutil to make partitions, then specify the partition in the zpool create command.
User avatar
Posts: 490
Joined: Thu Mar 06, 2014 2:05 pm
Location: Tokyo, Japan

Re: Disk partitioning prior to pool creation

Postby Sharko » Tue Aug 16, 2016 6:50 pm

Lundman's advice is probably the way to go (he should know!), but if you want to control how partitions are set up at the lowest level there is also the option of using the Terminal command 'gpt'. It's very straightforward to use, and you can look it up with 'man gpt'. Here are my notes from when I was setting up my ZFS pool with encrypted 2 TB disks. WARNING: don't apply these commands blindly - the disk you intend to work with might not be disk3, it might be something else!

Setting up partitions, using the example of disk3:

First, unmount any disk partitions on the disk that are currently mounted.

Then destroy the current partition scheme on that disk (WARNING: this command WILL destroy data - do you have backups? Are you sure which disk is which?):

Code: Select all
sudo gpt destroy disk3

Then create a blank partition table:

Code: Select all
sudo gpt create disk3

Then add an EFI partition:

Code: Select all
sudo gpt add -b 40 -s 409600 -t C12A7328-F81F-11D2-BA4B-00A0C93EC93B disk3

Then add an HFS+ partition (we are going to encrypt using coreStorage, so it has to be HFS+):

Code: Select all
sudo gpt add -s 3906250000 -t 48465300-0000-11AA-AA11-00306543ECAC disk3

Then, convert to CoreStorage volume:

Code: Select all
diskutil coreStorage convert /dev/disk3s2

Add encryption (note that disk5 is the logical volume created by the conversion process, visible in the output of the previous command):

Code: Select all
diskutil coreStorage encryptVolume /dev/disk5

The final result, shown by this command:

Code: Select all
$ sudo gpt show disk3
       start        size  index  contents
           0           1         PMBR
           1           1         Pri GPT header
           2          32         Pri GPT table
          34           6         
          40      409600      1  GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
      409640  3906250000      2  GPT part - 6A898CC3-1DD2-11B2-99A6-080020736631
  3906659640      369495         
  3907029135          32         Sec GPT table
  3907029167           1         Sec GPT header

This gives a ZFS partition of exactly 2 TB, with a little cushion at the end in case disks are different sizes.

Posts: 70
Joined: Thu May 12, 2016 12:19 pm

Return to Absolute Beginners Section

Who is online

Users browsing this forum: No registered users and 1 guest