zfs icon indicating copy to clipboard operation
zfs copied to clipboard

ZVOL disk should appear as physical disk to benefit from diskutil apfs resize

Open captain-haddock17 opened this issue 4 years ago • 1 comments

Hi all !

Short story After resizing (extending) of a ZVOL, I'd like to be able to resize formatted APFS volume to the max size.

diskutilwon't do that because of APFS Container disk created on ZFS ZVOL is not actually considered as a Physical Store.

Impact

No actual benefit of ZFS resize facility ...

workaround

without having the ability of doing diskutil apfs resizeContainer disk# 0, I have to destroy [deleteVolume] and recreate [addVolume] the intended Volume to benefit from the new disk space available.

To achieve this, a backup/copy of the whole content of the APFS volume to another HD or disk image with necessary space.

Yes, I know, you could say : it's always a good point/best practice to have a full backup before doing big low-level disk operations ... The aim is to gain some extra commands and delay/time to restore the saved Volume. and actually benefit of ZFS resize facility all the way down to APFS (or JHFS+)

Test case : extending APFS Volume on a ZVOL

(here from 100 GB to 200 GB on zDisk/Libraries)

MacPro 5,1 (2010) with SSD (APFS) and 3 internal SATA drives (zpool named zDisk). Mojave 10.14.6 uname -v

Darwin Kernel Version 18.7.0: Mon Feb 10 21:08:45 PST 2020; root:xnu-4903.278.28~1/RELEASE_X86_64

sysctl {spl,zfs}.kext_version

spl.kext_version: 1.9.4-0 zfs.kext_version: 1.9.4-0

  1. Create ZVOL disk and format APFS
sudo zfs create -V 100G zDisk/Users/Libraries
diskutil list external virtual
diskutil info disk10

sudo diskutil apfs createContainer disk10
sudo diskutil apfs addVolume disk11 APFS Libraries
sudo diskutil apfs list disk11
  1. Resize ZFS ZVOL sudo zfs set volsize=200G zDisk/Users/Libraries

  2. Try to benefit from new space on the APFS formatted Volume sudo diskutil apfs list disk11

| +-- Container disk11 A70D3B83-7FD8-467C-854C-185F5373E8AC ===================================================== APFS Container Reference: disk11 Size (Capacity Ceiling): 107374182400 B (107.4 GB) Capacity In Use By Volumes: 125153280 B (125.2 MB) (0.1% used) Capacity Not Allocated: 107249029120 B (107.2 GB) (99.9% free) |

+-< Physical Store disk10 (No UUID)
APFS Physical Store Disk: disk10
Size: 214748364800 B (214.7 GB)
+-> Volume disk11s1 0C596A0F-70E5-43D0-9925-44C1A9D73D38
    ----------------------------------------------------
    APFS Volume Disk (Role):   disk11s1 (No specific role)
    Name:                      Libraries (Case-insensitive)
    Mount Point:               /Volumes/Libraries
    Capacity Consumed:         663552 B (663.6 KB)
    FileVault:                 No

sudo diskutil apfs resizeContainer disk11 limit

You must supply a partition (with an APFS Physical Store) when making a limits inquiry

sudo diskutil apfs resizeContainer disk11 0b

Started APFS operation Error: -69607: APFS Container Resize only supported for Physical Stores on actual partitions

captain-haddock17 avatar Apr 12 '20 13:04 captain-haddock17

Some workaround to be able to benefit of a resized ZVOL

Condition : ZVOL disk must have partitions to be able to resize embedded JHFS+ partition later on.

Demo

sudo zfs create -V 100G zDisk/Users/Libraries
sudo diskutil partitionDisk disk10 1 GPT JHFS+ Libraries 0

sudo zfs set volsize=200G zDisk/Users/Libraries
sudo diskutil resizeVolume disk10s2 R

got a strange message after resizing ...

(...) Error: -5341: MediaKit reports partition (map) too small; if you recently grew your whole-disk, you should run whole-disk repair

sudo diskutil repairdisk  disk10
sudo diskutil repairvolume  disk10s2

captain-haddock17 avatar Apr 12 '20 20:04 captain-haddock17