Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Disk resize command #2034

Merged
merged 1 commit into from
Dec 1, 2023
Merged

Disk resize command #2034

merged 1 commit into from
Dec 1, 2023

Conversation

vasileknik76
Copy link
Contributor

The size of the created disk cannot be changed now. Even if the user resizes the disk using qemu-img resize he needs to run some commands in VM to grow the partition and resize the FS.

I added command limactl disk resize which can resize disk of a stopped vm using qemu-img.

Also I added parsing a format of an existing disk and render it in limactl ls

In cidata was added commands to resize the partition and the FS across all attached disks.

Shrinking of a disk is a danger operation, so i explicitly disallow it

growpart "/dev/${DEVICE_NAME}" 1 || true
# Only resize when filesystem is in a healthy state
if e2fsck -f -p "/dev/disk/by-label/lima-${DISK_NAME}"; then
resize2fs "/dev/disk/by-label/lima-${DISK_NAME}" || true
Copy link
Member

@afbjorklund afbjorklund Nov 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably check for an ext2 (et al) filesystem, perhaps also support xfs ?

xfs_growfs /mount/point -D size

EDIT: Apparently -d grows to the biggest.

I guess e2fsck would have failed. (it is xfs_repair)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xfs_repair repairs FS but e2fsck just only checks it. I think need to use fsck.$FSTYPE

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added xfs_growfs and tested ext2/3/4 and xfs

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought you wanted to do a repair, since you did e2fsck -p

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not plan to repair the file system, but only to check the functionality before increasing the size. Same code can be found at 04-persistent-data-volume.sh

// inspectDiskSize attempts to inspect the disk size by itself,
// and falls back to inspectDiskSizeWithQemuImg on an error.
func inspectDiskSize(fName string) (int64, error) {
// inspectDiskSizeAndFormat attempts to inspect the disk size and format by itself,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// inspectDiskSizeAndFormat attempts to inspect the disk size and format by itself,
// inspectDisk attempts to inspect the disk size and format by itself,

@AkihiroSuda
Copy link
Member

Looks good, but please consider squashing commits

Signed-off-by: Nikita Vasilchenko <n@mintscale.ru>
@vasileknik76 vasileknik76 force-pushed the disk-resize branch 3 times, most recently from 259664d to 65c36a7 Compare November 27, 2023 20:28
Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@AkihiroSuda
Copy link
Member

CI not working?

@AkihiroSuda AkihiroSuda reopened this Nov 28, 2023
@AkihiroSuda AkihiroSuda added this to the v0.19.0 milestone Nov 28, 2023
@AkihiroSuda AkihiroSuda requested review from afbjorklund and a team November 28, 2023 11:26
@AkihiroSuda AkihiroSuda merged commit b453ded into lima-vm:master Dec 1, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants