Ivan Tomica

Expanding ZFS pool on Linux VPS

In order to expand ZFS pool first step is to resize underlying disk. Once that’s done, by default on Linux, partition 9 of size 8MB is created at the end of the disk. Reasoning for this partition is not completely clear for me, but according to some random discussions on the internet, it would seem that it comes from Solaris, but no clear explanation why it exists in the first place.

Anyhow, after adding more space to the disk (resizing underlying block device) this partition stays in a way of expanding the filesystem:

root@web1:~# parted /dev/sdb unit s p
Warning: Not all of the space available to /dev/sdb appears to be used, you can fix the GPT to use all of the space (an extra 41943040 blocks) or continue with the current setting? 
Fix/Ignore? Fix                                                           
Model: HC Volume (scsi)
Disk /dev/sdb: 734003200s
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start       End         Size        File system  Name                  Flags
 1      2048s       692041727s  692039680s               zfs-c1774c443a9d3641
 9      692041728s  692058111s  16384s

Trying to grow the partition will return the error

root@web1:~# growpart /dev/sdb 1
NOCHANGE: partition 1 is size 692039680. it cannot be grown

So the solution is to remove the partition 9

root@web1:~# parted /dev/sdb rm 9

And then grow partition 1 to the full block device size

root@web1:~# growpart /dev/sdb 1
CHANGED: partition=1 start=2048 old: size=692039680 end=692041728 new: size=734001119,end=734003167

root@web1:~# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0 19.1G  0 disk 
└─sda1   8:1    0 19.1G  0 part /
sdb      8:16   0  350G  0 disk 
└─sdb1   8:17   0  350G  0 part 

And to expand the vdev in the pool use

zpool online -e home /dev/sdb
Tagged in:,