Nextcloud-vm ncdata ZFS zpool EXPANDSZ 扩展

1、在虚拟机扩展 ncdata 所在“硬盘2”分区大小(例如从40Gb到500Gb)

2、查看 zpool

zpool list

NAME     SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT
ncdata   40G   825M   39G        -         -     0%     0%  1.00x    ONLINE  -

3、创建或设置 zpool 并启用自动扩展(默认为关闭)

zpool set autoexpand=on ncdata

4、查看所在 device name

fdisk -l

Disk /dev/sdb: 40 GiB, 536870912000 bytes, 1048576000 sectors
Disk model: VMware Virtual S
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: FFC8A6D8-ED3D-3247-9D82-39D90CC6DCBE

Device     Start        End    Sectors  Size Type
/dev/sdb1   2048 1048575966 1048573919  40G Solaris /usr & Apple ZFS

5、读取新的分区大小进行调整

parted -l

Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 537GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End    Size   File system  Name                  Flags
 1      1049kB  40.9GB 40.9GB zfs           zfs-b90997bf594d9ed2
 9      40.9GB  40.9GB 8389kB[...]

6、删除缓冲区分区

parted /dev/sdb rm 9

7、将第一个分区扩展到可用大小的 100%

parted /dev/sdb resizepart 1 100%

8、将分区调整到正确的大小

zpool online -e ncdata /dev/sdb

# 可能会报错
cannot expand /dev/sdb: no such device in pool

9、重启

reboot
启动时会调整大小,并自动重启系统

其他

https://www.hanssonit.se/nextcloud-vm/