ZFS Reduce(shrink) root zfs partition

I had this same problem some months ago over nixos with root zfs and the 'best answer i got' was it can't be done with openzfs and i should planned this and i agree but the point is not that i shouded plan this instead is i didn't, now how can i do that?.
i founded this guide over vultr about how to resize a zfs but actually only works for expanding the filesystem and if you try to shrink the zfs partition happends that gdisk says device bussy and if you try to shrink from liveusb it does it but the problem is that happens the same that happend me a time ago all the zfs metadata keeps on the unsed spaced as if i cutted the partition and let all the important zfs data aver that, the solution for this us reexpand the partition to its original size as if it wasn't shrinked on first time.
but how can i reduce the partition?
really i need install windows on a 100g partition i mean i know windows but i need it and is not negociable regrettably
 
the 'best answer i got' was it can't be done with openzfs

If you give a partition to a ZFS pool, then certainly: it will be impossible to shrink the partition and maintain the integrity of its data.

Please see, for example:

i need install windows on a 100g partition

Do you have only one disk?

If so: how is it partitioned?
 
If you give a partition to a ZFS pool, then certainly: it will be impossible to shrink the partition and maintain the integrity of its data.

Please see, for example:



Do you have only one disk?

If so: how is it partitioned?
yes i have only one hard drive, this is the partition scheme:
Code:
       40  976773088  ada0  GPT  (466G) 
        40     532480     1  efi  (260M)    
        532520       1024     2  freebsd-boot  (512K)
        533544        984        - free -  (492K)     
        534528  16777216     3  freebsd-swap  (8.0G)
        17311744  959461384     4  freebsd-zfs  (458G)
and this is the zpool scheme
Code:
NAME                 USED  AVAIL     REFER  MOUNTPOINT
zroot               47.8G   394G       96K  /zroot
zroot/ROOT          12.5G   394G       96K  none
zroot/ROOT/default  12.5G   394G     12.5G  /
zroot/usr           35.3G   394G       96K  /usr
zroot/usr/home      33.3G   394G     33.3G  /usr/home
zroot/usr/ports     1.28G   394G     1.28G  /usr/ports
zroot/usr/src        702M   394G      702M  /usr/src
zroot/var           1.34M   394G       96K  /var
zroot/var/audit       96K   394G       96K  /var/audit
zroot/var/crash       96K   394G       96K  /var/crash
zroot/var/log        752K   394G      752K  /var/log
zroot/var/mail       240K   394G      240K  /var/mail
zroot/var/tmp         96K   394G       96K  /var/tmp
 
Thanks.

If you have no available external drive that's large enough for a replica of the pool, then the simplest (not quickest) approach might be something like:
  1. pkg prime-origins | sort > ~/prime-origins.txt
  2. temporarily use an online backup service for your user data (33.3 G /usr/home plus whatever else you must not lose)
  3. less ~/prime-origins.txt to remind yourself of what you installed, this might trigger an additional thought about what user data comprises in your case
  4. if necessary, add to the backup
  5. start afresh with an installation of FreeBSD that uses not so much disk space for the pool
  6. update the installation
  7. carefully restore user data.
 
Back
Top