ZFS How to use "gpart" on devices created on ZFS with "volmode=dev"?

Most likely I'm missing something obvious, I thought this should be straight forward:
Code:
# zfs create -V256G -o volmode=dev zroot/ubuntu
# gpart create -s gpt /dev/zvol/zroot/ubuntu
# gpart: arg0 'zvol/zroot/ubuntu': Invalid argument
Then I used sysutils/gdisk, successfully created the corresponding GPT geometry and tried gpart again with no luck:
Code:
# gpart show /dev/zvol/zroot/ubuntu
# gpart: No such geom: /dev/zvol/zroot/ubuntu
Thanks for directions!
 
volmode=default|full|geom|dev|none
This property specifies how volumes should be exposed to the OS. Setting it to full exposes volumes as fully fledged block devices, providing maximal functionality. The value geom is just an alias for full and is kept for compatibility. Setting it to dev hides its partitions. Volumes with property set to none are not exposed outside ZFS, but can be snapshotted, cloned, replicated, etc, that can be suitable for backup purposes. Value default means that volumes exposition is controlled by system-wide tunable zvol_volmode, where full, dev and none are encoded as 1, 2 and 3 respectively. The default value is full.
 
Sometimes diskid can mess things up . Pls show the gpart show output (with specifying provider).

edit: i misread your original question. Not to spam too much all over this thread I'll update what I thought first when I didn't read your Q with comprehension. Just today I was little bit irritated by my dev box where I had to shuffle physical disks around and sync data over. And while some disks were accessible by their names (/dev/adaX) for some I had to use disk id. And they are all comming from the same HBA. I know I can tune this but I didn't have it in, sync was in progress. I thought this is your issue first.
 
Sometimes diskid can mess things up . Pls show the gpart show output (with specifying provider).
Shows just physical devices:
Code:
# gpart show
=>        40  1953525088  nvd0  GPT  (932G)
          40        1024     1  freebsd-boot  (512K)
        1064         984        - free -  (492K)
        2048     4194304     2  freebsd-swap  (2.0G)
     4196352  1949327360     3  freebsd-zfs  (930G)
  1953523712        1416        - free -  (708K)

=>        40  1953525088  nvd1  GPT  (932G)
          40        1024     1  freebsd-boot  (512K)
        1064         984        - free -  (492K)
        2048     4194304     2  freebsd-swap  (2.0G)
     4196352  1949327360     3  freebsd-zfs  (930G)
  1953523712        1416        - free -  (708K)
And here are the virtual disks:
Code:
% ll /dev/zvol/zroot/
total 0
crw-r-----  1 root  operator  0x8e Oct 17 13:00 debian
crw-r-----  1 root  operator  0xb2 Oct 17 11:03 ubuntu
crw-r-----  1 root  operator  0xae Sep 30 16:35 work
 
zfs create -V256G -o volmode=dev zroot/ubuntu
"Setting it to dev hides its partitions.".
So gpart show will not show partitions/slices

Try:
zfs create -V256G -o volmode=full zroot/ubuntu
gpart create -s GPT zvol/zroot/ubuntu
gpart show -p zvol/zroot/ubuntu
 
zfs create -V256G -o volmode=dev zroot/ubuntu
"Setting it to dev hides its partitions.".
So gpart show will not show partitions/slices

Try:
zfs create -V256G -o volmode=full zroot/ubuntu
Hmm... Interesting, no such message here on
Code:
% uname -a
FreeBSD BUILDBOX 13.1-RELEASE-p2 FreeBSD 13.1-RELEASE-p2 GENERIC amd64
[EDIT] I misinterpreted your message, Alain De Vos , it's not an output of the command.
But again, gdisk shouldn't be smarter than gpart.
 
Why do you specify the volmode in the first place?
Code:
# zfs create -V32G  rpool/lun00
#
# gpart create -s gpt /dev/zvol/rpool/lun00
zvol/rpool/lun00 created
#
Worth mentioning is the -s to create sparse volumes.
 
Why do you specify the volmode in the first place?
Well, that's my "fault", I was doing that for long time and have never had any problems in the past. I was under impression that "dev" means the same as regular device nodes in /dev/. Also, the directory /dev/zvol/zroot looks much cleaner without numerous "*p[123]" entries.
The mode can be changed easily with:
Code:
zfs set volmode=full zroot/ubuntu
However, the last question: why the alien gdisk is "smarter" than the native gpart remains open.
 
Can you paste your exact commands what you did? I guess I know, but I don't want to guess.:)
Code:
# zfs create -V256M -o volmode=dev zroot/test
ll /dev/zvol/zroot/test*
crw-r-----  1 root  operator  0xbe Oct 17 13:51 /dev/zvol/zroot/test

# gdisk /dev/zvol/zroot/test
....
Found valid GPT with protective MBR; using GPT.
Disk /dev/zvol/zroot/test: 524288 sectors, 256.0 MiB
....
n<created a partition>
w

# gdisk -l /dev/zvol/zroot/test
....
Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048          522239   254.0 MiB   8300  Linux filesystem

# gpart show /dev/zvol/zroot/test
gpart: No such geom: /dev/zvol/zroot/test
 
Well problem is that on that type of disk GEOM_CTL ioctl fails. gdisk is not using it and hence it goes through. But even that type of disk is not visible by gpart (part is type of geom class).
But now there's a nicer, more technical question: why and what is the benefit. I actually don't know.
 
It's interesting that on my FreeBSD 13 I can't find anything about volmode in zfs man pages. I can on my 12.3 box which is still using zfs from opensolaris (opposed to openzfs in 13). Man page in 12 zfs(8) mentions that dev mode could be faster but should be used as raw device only. That explains why geom is not able to use it.
Maybe this is still in TODO list in openzfs or maybe this feature is fading away..
 
but AFAICR gpart worked that time.
You are correct. On my 12.3-RELEASE I can do this:
Code:
# zfs create -V 8G -s -o volmode=dev rpool/forumlun00
# gpart create -s gpt /dev/zvol/rpool/forumlun00
# gpart show zvol/rpool/forumlun00
=>      40  16777136  zvol/rpool/forumlun00  GPT  (8.0G)
        40  16777136                         - free -  (8.0G)
 # zfs get volmode rpool/forumlun00
NAME              PROPERTY  VALUE    SOURCE
rpool/forumlun00  volmode   dev      local
And that ioctl gets through. Which by its own is weird as I'd expect it not to work per the man page.
But then 13 does recognize it too as T-Daemon mentioned, there are some differences now in man pages.

So maybe they actually fixed it in 13 and it now behaves as it should.
 
Now I remember I used to follow the instructions (which haven't been changed in this regard at least since 10.3):
which suggest using namely volmode=dev.
 
"dev" is used because it wants the "guest OS", iso, to write the partition table & partitions via bhyve.
So the partitions themselves do not need to be exposed to the host as separate devices.
 
There is some inconsistency in these ZFS properties/access/controls whatever.
After resizing the ZFS volume it became inaccessible in terms of GEOM, however, it still reports volmode=full:
Code:
# zfs set volsize=64G zroot/ubuntu
% zfs get volmode zroot/ubuntu
NAME          PROPERTY  VALUE    SOURCE
zroot/ubuntu  volmode   full     local
# gpart show /dev/zvol/zroot/ubuntu
gpart: No such geom: /dev/zvol/zroot/ubuntu.
% ll /dev/zvol/zroot/ubuntu*
crw-r-----  1 root  operator  0x76 Oct 18 15:54 /dev/zvol/zroot/ubuntu
 
Back
Top