ZFS What is the difference between gpart and other tools?

I'm trying to format my external disk with ZFS filesystem. I've search and found several guides using different tools. Since sysutils/gpart is used in handbook, it seems FreeBSD prefer it than other tools. So, I'd like to know what's the difference and I'd like to make sure the commands I used are correct.

Code:
# dd < /dev/zero > /dev/da0 count=1
# fdisk -I /dev/da0
# glabel label mydisk da0s1
# zpool create mydisk /dev/label/mydisk

Code:
# gpart destroy -F da0
# gpart create -s GPT da0
# glabel label mydisk da0p1
# gpart add -t freebsd-zfs -a 1M -l mydisk da0
# zpool create mydisk /dev/label/mydisk

Are those two sets of commands have the same functionality? What are the differences?

Update - 1: glabel command is added in the second set.
 
I'm trying to format my external disk with ZFS filesystem.

neither gpart nor the ancient/obsolete fdisk will format anything (ZFS or other filesystems). Those are purely for partitioning.

To use the external disk as a ZFS-pool, you might even want to remove all partitioning schemes from it and just use the whole disk by issueing zpool create directly on the device (e.g. /dev/da0)
 
Code:
…
# gpart add -t freebsd-zfs -a 1M -l mydisk da0
# zpool create mydisk /dev/label/mydisk

Was /dev/label created manually?

Here, with a test device at da2:

Code:
root@mowa219-gjp4-8570p-freebsd:~ # gpart destroy -F da2
da2 destroyed
root@mowa219-gjp4-8570p-freebsd:~ # gpart create -s GPT da2
da2 created
root@mowa219-gjp4-8570p-freebsd:~ # gpart add -t freebsd-zfs -a 1M -l mydisk da2
da2p1 added
root@mowa219-gjp4-8570p-freebsd:~ # lsblk da2
DEVICE         MAJ:MIN SIZE TYPE                                          LABEL MOUNT
da2              0:136 965M GPT                                               - -
  <FREE>         -:-   1.0M -                                                 - -
  da2p1          0:138 963M freebsd-zfs                              gpt/mydisk <ZFS>
  <FREE>         -:-   1.0M -                                                 - -
root@mowa219-gjp4-8570p-freebsd:~ # zpool create mydisk /dev/label/mydisk
cannot resolve path '/dev/label/mydisk'
root@mowa219-gjp4-8570p-freebsd:~ # file /dev/label
/dev/label: cannot open `/dev/label' (No such file or directory)
root@mowa219-gjp4-8570p-freebsd:~ # uname -KU
1400053 1400053
root@mowa219-gjp4-8570p-freebsd:~ #
 
To use the external disk as a ZFS-pool, you might even want to remove all partitioning schemes from it and just use the whole disk by issueing zpool create directly on the device (e.g. /dev/da0)
I actually respectfully disagree with this advice. I would always put a gpart label on the disk. And in the label, give the disk a meaningful text label, which you can decode later. For example "20220225_backups_2of4", if you're creating a 4-disk Zvol for backups. Why? One of these days, the disk may be separated from the system, and a while later, you find a handful of drives on your workbench. It's nice to be able to just connect it to a random computer, say "gpart list", and know what it is. Otherwise, you have to guess the file system type and version, find the correct OS, mount it, and see what happens. Along the same lines: If you have lots of disks around, use a paper labels or tape to it, and write on it what it is: "Ralph 20220225 Backup Zvol 2 of 4".
 
neither gpart nor the ancient/obsolete fdisk will format anything
How can I properly do it on FreeBSD? Which tool do I have to use?
just use the whole disk by issueing zpool create
If I have a HDD which is NTFS by default, can I just zpool create mydisk /dev/label/mydisk without doing other steps? I'm a newbie. Could you show the set of commands for that?
Was /dev/label created manually?
Actually I run the command twice and that directory /dev/label/mydisk is the leftover of the glabel label mydisk da0p1. After testing, I did zpool destroy -f mydisk and I thought this could revert the changes. Sorry for the confusion. I'll also update in the post. Btw, how to delete that directory? I mean I know rmdir but is there anything to take care of?
Try /dev/gpt/mydisk.
Thanks. But what is the advantage over glabel(8)?
 
Back
Top