e2fsck resize2fs fdisk volsize truenas
Source
- shutdown the VM
- edit the VM to add a live ISO image with the device order higher than the disk device of the VM
- start the VM to boot into the live ISO
- resize the root partition to its new smaller size
- run
e2fsck -f /dev/vda3
(wheredev/vda3
is the partition to be resized) - then run
resize2fs /dev/vda3 150G
to resize the partition (where150G
is the new smaller size)
- run
- alter the partition table
- run
fdisk /dev/vda
- enter
p
to print the table for reference - enter
d
followed by3
to delete the partition - enter
n
followed by3
followed by+150G
to create a new partition with the smaller size - answer
no
if asked to remove the ext4 marker - enter
t
followed by the correct partition type ID (in this case23
forLinux root (x86-64)
) - enter
w
to write the new partition table
- run
- shutdown the VM again
- create a ZFS snapshot of the zvol
- resize the zvol (only possible via the command line)
- run
zfs set volsize=200G <pool>/<zvol>
to set the new size for the zvol - this will destroy the partition table and maybe even the whole data, but we can get that back when we…
- run
- restore the snapshot from before (this can be done in the GUI again), confirming that this will delete/replace all data
the size of the zvol will stay the new smaller size, butall data (since it should fit snugly into the new space) will be restored- then simply start the VM and enjoy
Edit
It seems, the restoration of the snapshot did reset the
volsize
as well, however, I still have much more free space than before. Also, the partition table and size of the disk inside the VM is still the new smaller size.