SOLVED Resizing VM zvol disk

Gaspetaahl

Explorer
Joined
Sep 13, 2018
Messages
76
Hi,
Im running a VM with alpine linux on my freenas. Sadly my VMs disk is full so i wanted to resize the zvol its using. So I did that in the Storage Tab of the UI but the VM doesnt recognize the bigger disk.
I tried to restart the vm and also tried to remove the disk and then add it again.
Do I have to run a comman in the vm?
I couldnt find any documentation or other threads in the forum about this.
Thank for any help.
 

jgreco

Resident Grinch
Joined
May 29, 2011
Messages
18,680
You haven't given enough information to get a helpful answer. What hypervisor? Is the zvol dedicated to the VM, or are you running something like VMFS on it? What's your setup look like?

In general, resizing virtual disks is fraught with peril and I usually find that people understand the necessary process better if I tell them to just create a new virtual disk of the desired size and then copy the old contents over.
 

Gaspetaahl

Explorer
Joined
Sep 13, 2018
Messages
76
I use bhyve the standard hypervisor. Im not using vmfs. Its just a zvol created with the freenas ui that I assignes as a disk as a ahci device to the vm.
Do you need any more information?
What would you suggest to copy over files? dd? Id like to keep my configuration instead of seting up alpine again
 

Gaspetaahl

Explorer
Joined
Sep 13, 2018
Messages
76
Ok Im a step further. I realized that the partition didnt resize automatically (of course) so I resized it with cfdisk, but df -h still shows me 100% full disk. Any tips what to do now?

Code:
alpine:~$ df -h
Filesystem                Size      Used Available Use% Mounted on
devtmpfs                 10.0M         0     10.0M   0% /dev
shm                     999.2M         0    999.2M   0% /dev/shm
/dev/sda3                 6.5G      6.1G         0 100% /
tmpfs                   199.8M    356.0K    199.5M   0% /run
df: /sys/kernel/debug/tracing: Permission denied
/dev/sda1               511.0M    256.0K    510.7M   0% /boot/efi
cgroup_root              10.0M         0     10.0M   0% /sys/fs/cgroup
/dev/sda3                 6.5G      6.1G         0 100% /var/lib/docker/101.65533
df: /var/lib/docker/101.65533/overlay2/27108e47483314e10291bf70dc27023a77259d510c9345caebe3ceffcc2fae3d/merged: Permission denied
df: /var/lib/docker/101.65533/overlay2/0cfc3daacb600dec360f0f6970cec80eaa9712b992e2d4ca163beb37f22e70f6/merged: Permission denied
df: /var/lib/docker/101.65533/overlay2/0b09e0b362c0b710684289ce1d9280a7fb56270312527c167d3cc79a42302e3b/merged: Permission denied
df: /var/lib/docker/101.65533/overlay2/b9025d2039b1cef89b7a50720bc6122e933f7e0fe7a0223deee521d59bb27c13/merged: Permission denied
df: /var/lib/docker/101.65533/containers/296ffb0199417cc1ab51ebb4d8388aa71d1659544b43bb39ffbaa7960b629815/mounts/shm: Permission denied
df: /var/lib/docker/101.65533/containers/35b6e6f069b4553e94aea13e14ae1636fd2a92534a6bfbdb0608096cac92f120/mounts/shm: Permission denied
df: /var/lib/docker/101.65533/containers/ed403690a83158c47676acff547cd69407a88c384e819eaed6db01661bdfa505/mounts/shm: Permission denied
df: /var/lib/docker/101.65533/containers/e13bf5e565c6e6d187b60c140df3548ca37bde6b7b0c4a683939b1b24509ac7e/mounts/shm: Permission denied
df: /run/docker/netns/e99e2cfd24d3: Permission denied
df: /run/docker/netns/12d202838a8a: Permission denied
df: /run/docker/netns/f76da5546605: Permission denied
df: /run/docker/netns/63295bc038c9: Permission denied
alpine:~$ cfdisk
-ash: cfdisk: not found
alpine:~$ fdisk
BusyBox v1.29.3 (2019-01-24 07:45:07 UTC) multi-call binary.

Usage: fdisk [-ul] [-C CYLINDERS] [-H HEADS] [-S SECTORS] [-b SSZ] DISK

Change partition table

        -u              Start and End are in sectors (instead of cylinders)
        -l              Show partition table for each DISK, then exit
        -b 2048         (for certain MO disks) use 2048-byte sectors
        -C CYLINDERS    Set number of cylinders/heads/sectors
        -H HEADS        Typically 255
        -S SECTORS      Typically 63
alpine:~$ fdisk -l
fdisk: can't open '/dev/sda': Permission denied
alpine:~$ sudo fdisk -l
[sudo] password for user:
Found valid GPT with protective MBR; using GPT

Disk /dev/sda: 209715232 sectors, 16384
Logical sector size: 512
Disk identifier (GUID): f4245c78-cc72-4b4a-87a5-0fe239e22e8a
Partition table holds up to 128 entries
First usable sector is 2048, last usable sector is 209715198

Number  Start (sector)    End (sector)  Size Name
     1            2048         1050623  512M
     2         1050624         6049791 2441M
     3         6049792       209714397 97.1G
alpine:~$
 
Last edited:

jgreco

Resident Grinch
Joined
May 29, 2011
Messages
18,680
A partition is a random mass of storage. You increased the size of that.

A filesystem is a structured and delicate house of cards built on top of your raw storage ("partition"). Growing the partition doesn't upset the cards but it also doesn't make the space available inside the filesystem.

To make the space available inside the filesystem, you need to rearrange the cards. On BSD, that'd be "growfs" but on Linux it will depend on what filesystem you're running.
 

Gaspetaahl

Explorer
Joined
Sep 13, 2018
Messages
76
Ah ok thx. For the record I did:
resize2fs /dev/sda3
ext4 can be resized while mounted.
 

diskdiddler

Wizard
Joined
Jul 9, 2014
Messages
2,377
I do not need to resize the partition.

I've clonzed a 50GB ZVOL to an 80GB ZVOL.
Upon loading into the OS hosted on that, on the 80GB ZVOL now, it's showing a max DISK size of 50GB.
I need to resize the disk, not the partition. I do not know why Bhyve isn't 'presenting' the disk size to the VM as 80, instead of 50?

 

diskdiddler

Wizard
Joined
Jul 9, 2014
Messages
2,377
I have my answer and it's VERY embarassing.

I hope this helps others.
I created an 80GB zvol and cloned a 50GB zvol into it.
I had to use -F to force in doing so.

When doing this, it 'pushed' the 50GB zvol size to the new zvol as well, reducing it back down from 80GB
So I had to edit the zvol after the clone had completed, set it BACK to 80GB then re-size the partition, in gparted.

All fixed! Now my VM not only has 30GB more space but it's zstd compressed.
 
Top