Backup any data before touching the drives! If it’s a VM, take a snapshot before doing anything! I can’t be responsible for any data loss - experiment on a throwaway VM first!
Here I go through the steps to expand the data drive of my Nextcloud install from 500GB to 1TB.
Confirm the drive size before any changes using lsblk, zfs list and zpool list
root@nextcloud:/home/ncadmin# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 60G 0 disk
├─sda1 8:1 0 1G 0 part /boot/efi
├─sda2 8:2 0 2G 0 part /boot
└─sda3 8:3 0 56.9G 0 part
└─ubuntu--vg-ubuntu--lv 252:0 0 56.9G 0 lvm /
sdb 8:16 0 500G 0 disk
└─sdb1 8:17 0 500G 0 part
root@nextcloud:/home/ncadmin# zfs list
NAME USED AVAIL REFER MOUNTPOINT
ncdata 321G 147G 321G /mnt/ncdata
root@nextcloud:/home/ncadmin# zpool list
NAME SIZE ALLOC FREE CKPOINT EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
ncdata 500G 321G 178G - - 9% 64% 1.00x ONLINE -
You can also confirm it all matches in the mount point:
root@nextcloud:/home/ncadmin# df -h /mnt/ncdata
Filesystem Size Used Avail Use% Mounted on
ncdata 468G 321G 147G 68% /mnt/ncdata
View the partitions on the disks, I can see my data disk is /dev/sdb:
root@nextcloud:/home/ncadmin# parted -l
Model: NUTANIX VDISK (scsi)
Disk /dev/sda: 64.4GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 1128MB 1127MB fat32 boot, esp
2 1128MB 3276MB 2147MB ext4
3 3276MB 64.4GB 61.1GB
Model: NUTANIX VDISK (scsi)
Disk /dev/sdb: 537GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 537GB 537GB zfs zfs-0f26cf403f86b355
Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/ubuntu--vg-ubuntu--lv: 61.1GB
Sector size (logical/physical): 512B/4096B
Partition Table: loop
Disk Flags:
Number Start End Size File system Flags
1 0.00B 61.1GB 61.1GB ext4
Now I go expand the VM disk from 500GB to 1TB at the hypervisor level (in my case, Nutanix), and I can see it reflected when I tell parted to resize:
parted /dev/sdb resizepart 1 100%
Model: NUTANIX VDISK (scsi)
Disk /dev/sdb: 1074GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 1074GB 1074GB zfs zfs-0f26cf403f86b355
Now to resize the ZFS ZPOOL to match the expanded partition:
zpool export ncdata
zpool import -d /dev ncdata
zpool online -e ncdata sdb
And now I can see the resized drive:
root@nextcloud:/home/ncadmin# zpool list
NAME SIZE ALLOC FREE CKPOINT EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
ncdata 1000G 321G 678G - - 9% 32% 1.00x ONLINE -
root@nextcloud:/home/ncadmin# df -h /mnt/ncdata
Filesystem Size Used Avail Use% Mounted on
ncdata 968G 321G 647G 34% /mnt/ncdata