On / Questions about expanding zpool (assign free disk space to zfs partition)


#1

Well, as I was tired to have not enough space to update my TrueOS system normally because with the recent updates and some additionally installed packages the BE grow too big to allow for another one (and all the package downloads beforehand) for the update on the 20GB partition I had assigned for TrueOS (in the end I had to either uninstall packages before the update and re-install them afterwards or go the “static” route (which by the way I don’t dislike because I don’t have to wait for hours because the system thinks it has to download all (!) packages again even if the present ones are current (very annoying!)), I upgraded my system to a new hdd with more disk space.

As I use Acronis for backup (which luckily also works for zfs) I now have to problem to expand the 20GB zpool to the available 100GB I assigned to TrueOS.

I haven’t found a good manual yet, because “they” always talk about adding an additional disk to raid system, and the like, but “never” about just extending to the free disk space after the “zfs partition”. At least I haven’t found one.

But I found a forum entry that helped me best so far. But I’m not quite at the finish line, yet.

What didn’t work (what e.g. the oracle docs say should work):

  • Enabling the autoexpand feature of the zpool. The feature can be enabled but it doesn’t autoexpand. That might have it’s cause in the fact the free disk space has to be “added” to the “freebsd partition” first. But I haven’t found anything on that in the oracle docs… (they never mention any gpart commands…)

  • Expanding the zpool using “zpool online -e” command. I guess for the same reason as the previous one.

But at least I was able to add the free disk space thanks to a forum entry.

That’s what my disk looked at the start of my endeavours:

~% gpart show
=> 63 1953525105 ada0 MBR (932G)
63 1985 - free - (993K)
2048 204800 1 ntfs [active] (100M)
206848 204800000 2 ntfs (98G)
205006848 1543712768 3 ntfs (736G)
1748719616 41957376 4 freebsd (20G)
1790676992 162848176 - free - (78G)

=> 0 41957376 ada0s4 BSD (20G)
0 40888320 1 freebsd-zfs (19G)
40888320 104because8576 2 freebsd-swap (512M)
41936896 20480 - free - (10M)

For now I was able to add the free disk space to my “BSD partition”.

Used command:

gpart resize -i 4 /dev/ada0

~% gpart show
=> 63 1953525105 ada0 MBR (932G)
63 1985 - free - (993K)
2048 204800 1 ntfs [active] (100M)
206848 204800000 2 ntfs (98G)
205006848 1543712768 3 ntfs (736G)
1748719616 204805552 4 freebsd (98G)

=> 0 204805552 ada0s4 BSD (98G)
0 40888320 1 freebsd-zfs (19G)
40888320 1048576 2 freebsd-swap (512M)
41936896 162868656 - free - (78G)

Now I thought, ok, but now those steps from before should work. But unfortunately they don’t. Neither autoexpand nor “manually” expanding adds the free space within the BSD partition to the “freebsd-zfs”. The reason might be that there’s that swap “partition” that’s “in the way”.

#####So my question would be now: How do I temporarily delete the swap partition, expand / extend the zfs partiton to the free space and append the swap partition after the new sized zfs partition?

I was thinking of firing up a gparted live system to “edit” the BSD partition. But I’d rather ask first before damaging my system.

Thanks for any helpful hints.


#2

Just succeeded.

Using slightly different words by chance when searching I fund a website I found before but discarded back then. Now I realized it contained exactely what I was looking for.

My hunch wasn’t that bad: Deactivate swap and delete the swap partition, resize the zfs partition, recreate a swap partition and activate it, and finally expand the zpool over the resized zfs partition.

Here are the commands I used:

Deactivate swap

swapoff -a

Delete swap partition (see corresponding gpart details in first post):

gpart delete -i 2 ada0s4

Resize zfs partition:

gpart resize -i 1 -s 97g ada0s4

Result so far:

~% gpart show
=> 63 1953525105 ada0 MBR (932G)
63 1985 - free - (993K)
2048 204800 1 ntfs [active] (100M)
206848 204800000 2 ntfs (98G)
205006848 1543712768 3 ntfs (736G)
1748719616 204805552 4 freebsd (98G)

=> 0 204805552 ada0s4 BSD (98G)
0 203423744 1 freebsd-zfs (97G)
203423744 1381808 - free - (675M)

Add swap partition:

gpart add -t freebsd-swap -i 2 ada0s4

New result:

~% gpart show

=> 63 1953525105 ada0 MBR (932G)
63 1985 - free - (993K)
2048 204800 1 ntfs [active] (100M)
206848 204800000 2 ntfs (98G)
205006848 1543712768 3 ntfs (736G)
1748719616 204805552 4 freebsd (98G)

=> 0 204805552 ada0s4 BSD (98G)
0 203423744 1 freebsd-zfs (97G)
203423744 1381800 2 freebsd-swap (675M)
204805544 8 - free - (4.0K)

Now for the zfs expansion. State right now - even though the zfs partition has 97 GB:

zpool list
NAME SIZE ALLOC FREE EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
tank1 19,4G 10,3G 9,12G 77,5G - 52% 1.00x ONLINE -

So, now expanding the zpool over the complete zfs partition (I add all steps a beginner might need):

We got the name of the zpool with the command above. The name is “tank1”.

Now let’s get the right zpool’s partition’s “name”:

~% zpool status tank1
pool: tank1
state: ONLINE
status: Some supported features are not enabled on the pool. The pool can
still be used, but some features are unavailable.
action: Enable all features using ‘zpool upgrade’. Once this is done,
the pool may no longer be accessible by software that does not support
the features. See zpool-features(7) for details.
scan: none requested
config:
NAME STATE READ WRITE CKSUM
tank1 ONLINE 0 0 0
ada0s4a ONLINE 0 0 0
errors: No known data errors

-> It’s ada0s4a. (As the “ada0s4” from above didn’t work for the following expansion, I needed to know about the aditional “a”)

Now we’re ready to expand:

sudo zpool online -e tank1 ada0s4a

Checking the result:

~% zpool list
NAME SIZE ALLOC FREE EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
tank1 96,9G 10,2G 86,6G - - 10% 1.00x ONLINE -

Worked fine. :slight_smile:

Last thing to do is to activate swap again:

sudo swapon /dev/ada0s4b

To check if it worked:

~% swapctl -l -h
Device: Bytes Used:
/dev/ada0s4b 675M 0B

To tell TrueOS about the (new) swap partition /etc/fstab has to be updated. Mine doesn’t have an entry at all, so I have to check something and come back on that.

[Edit]:

Apparently, that “swap not being activated anymore in /etc/fstab” isn’t really uncommon. As I “upgraded” this system from pcbsd the swap partition should stem from pcbsd. If there was ever a swap entry in the /etc/fstab on my TrueOS BE, I don’t know.

Anyway, for now I just added a (new) entry in /etc/stab:

/dev/ada0s4b none swap sw 0 0

Let’s reboot and see if it works. Because after the recent reboot I got this result due to the missing fstab entry:

~% swapctl -l -h
Device: Bytes Used:

After reboot, now swap is activated thanks to the new entry in /etc/fstab:

~% swapctl -l -h
Device: Bytes Used:
/dev/ada0s4b 675M 0B

=> Project “expanding zpool” successfully completed!


#3

Nice. Good job writing out all the steps. Now you can decide if you want to zpool upgrade tank1. If you are not going to use it mounted in “non TrueOS”, I would do the zpool upgrade. You may also want to do a scrub over it now that you’ve expanded it. Some folks like to schedule periodic scrubs, others let it go until they start seeing errors. Me, I manually do a scrub no less than 30 days no more than 90 days, “just because”.

The extra “a” is the old BSD style naming for the first partition. ada0 is the overall disk device, s4 is the fourth “slice” in BSD partitioning (think primary partition in Windows), “a” is the first partition within the slice. For more info than you would ever want, pick up a copy of Michael W Lucas books: FreeBSD Mastery Storage Essentials, ZFS and Advanced ZFS. He may even have an example doing exactly what you did. The tricky parts come in because it looks like you’re set up to dual boot Windows and TrueOS.


#4

Thanks for the hints.

The “search for the “a”” was just because on the mentioned website were always “talking” about p1 etc. instead of a, b etc. But they also had no ada disk but vtbd … So, no biggy.

I think I tried upgrading tank1, but it said it was already “running” the latest version of zfs.
I might scrub it next time I’m running TrueOS. But I’ve never scrubbed it before. I only learned about that function when I had (or rather seemed to have) an error on another system.

Anyway. I’m jsut glad I finally have a large enough TrueOS partition to not have any disk space hassles when updating (= creating another BE and thus doubling or tripling my space needs)… :slight_smile: