Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Automatically expand the filesystem on mounted volumes when they have grown #1103

Closed
jandubois opened this issue Oct 14, 2022 · 9 comments · Fixed by #1126
Closed

Automatically expand the filesystem on mounted volumes when they have grown #1103

jandubois opened this issue Oct 14, 2022 · 9 comments · Fixed by #1126

Comments

@jandubois
Copy link
Member

Description

This issue applies to the diffdisk when the basedisk is an ISO (Alpine), and to additional volumes provided via #1065

Is is possible to expand the max file size of the image on the host (see #356 (comment)), but the additional space does not become available until the partition and filesystem have been extended to include the additional space.

This should be implemented in 05-persistent-data-volume.sh (renamed to 04-... once #1065 is merged).

@chrisx8 Is this something you would like to work on?

@chrisx8
Copy link
Contributor

chrisx8 commented Oct 14, 2022

I can look into this, but I'm not too familiar with Alpine. Assuming it's on ext4, we can just run e2fsck then resize2fs in the script.

Questions:

  • How do we handle errors, in case e2fsck or resize2fs fails?
  • We probably should warn users if e2fsck fails, as this suggests the filesystem is unhealthy. Should we add this, if so, where?

@jandubois
Copy link
Member Author

I can look into this, but I'm not too familiar with Alpine. Assuming it's on ext4, we can just run e2fsck then resize2fs in the script.

Yes, it is always ext4. I just checked, and our alpine-lima image has e2fsck, but not resize2fs. I will add e2fsprogs-extra to our images. We need to check if this is installed in the other distros, or if we need to install those dependencies there as well (which would require re-arranging some code in the boot sequence).

Questions:

  • How do we handle errors, in case e2fsck or resize2fs fails?

I think it will just be logged, and then we proceed without resizing the filesystem.

  • We probably should warn users if e2fsck fails, as this suggests the filesystem is unhealthy. Should we add this, if so, where?

This happens during boot via cloud-init. So I think the only thing we'll have are cloud-init logs.

Not sure what else we can do? Some warning via /etc/profile that this happened? I would ignore this for now; it can be added in a later PR if we feel it is necessary.

@jandubois
Copy link
Member Author

I will add e2fsprogs-extra to our images.

Done in lima-vm/alpine-lima#88 (pending review).

I'll create a new tag/release once approved/merged.

jandubois added a commit to rancher-sandbox/lima that referenced this issue Oct 15, 2022
This will be needed to grow the filesystem when the size
of the attached data volume is increased. See
lima-vm#1103

Signed-off-by: Jan Dubois <jan.dubois@suse.com>
@jandubois
Copy link
Member Author

Alpine image with resize2fs has been released, and the examples/alpine.yaml has been updated in #1106 to use it.

@chrisx8
Copy link
Contributor

chrisx8 commented Oct 16, 2022

@jandubois Can we have the cloud-utils-growpart package in Alpine? I want to use growpart to expand the partition on the datadisk.

@chrisx8
Copy link
Contributor

chrisx8 commented Oct 16, 2022

Also, seems like boot scripts (including 05-persistent-data-volume.sh) are only ran on first start (creating instance from template) and not ran on subsequent launches (of existing instances). Is this expected?

@jandubois
Copy link
Member Author

Can we have the cloud-utils-growpart package in Alpine? I want to use growpart to expand the partition on the datadisk.

Sure, I'll add it.

Also, seems like boot scripts (including 05-persistent-data-volume.sh) are only ran on first start (creating instance from template) and not ran on subsequent launches (of existing instances). Is this expected?

No, this is not expected (and I'm sure not the case). #273 is making sure that every boot is treated like a "first boot" so even scripts only executed during the first boot should be executed every time.

jandubois added a commit to lima-vm/alpine-lima that referenced this issue Oct 17, 2022
Requested in lima-vm/lima#1103 (comment)

Signed-off-by: Jan Dubois <jan.dubois@suse.com>
jandubois added a commit to rancher-sandbox/lima that referenced this issue Oct 17, 2022
Request in lima-vm#1103 (comment)

Signed-off-by: Jan Dubois <jan.dubois@suse.com>
@jandubois
Copy link
Member Author

Can we have the cloud-utils-growpart package in Alpine?

Added in #1118

@chrisx8
Copy link
Contributor

chrisx8 commented Oct 22, 2022

Also, seems like boot scripts (including 05-persistent-data-volume.sh) are only ran on first start (creating instance from template) and not ran on subsequent launches (of existing instances). Is this expected?

Please disregard. Seems like it's caused by me not using e2fsck properly, so it wouldn't work without interactive terminals (like when launched by cloud-init)

I got this implement and #1126 is ready for review!

DennisRasey pushed a commit to DennisRasey/lima that referenced this issue Jan 11, 2024
This will be needed to grow the filesystem when the size
of the attached data volume is increased. See
lima-vm#1103

Signed-off-by: Jan Dubois <jan.dubois@suse.com>
DennisRasey pushed a commit to DennisRasey/lima that referenced this issue Jan 11, 2024
Request in lima-vm#1103 (comment)

Signed-off-by: Jan Dubois <jan.dubois@suse.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants