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

help request: Changing the size of a volume in imperitive microvm #315

Open
aidenscott2016 opened this issue Dec 26, 2024 · 4 comments
Open

Comments

@aidenscott2016
Copy link

Hello,

I have imperatively deployed a vm using the following command:
nix run .#nixosConfigurations.k3s-microvm-2.config.microvm.deploy.rebuild [email protected] [email protected] -- --use-remote-sudo

I found that the default size for the root volume was too small, so I explicitly set it using microvm.volumes. I found that redeploying using the above command seems to do nothing. It will do some work, often it will hang on refreshing nix database, but when it completes and I log in to the microvm again, I find that the size of the root volume has not changed.

In troubleshooting i have also tried the following:

  • redeploy the config to the host machine
  • rebuild the vm on the host:
    • check status using microvm -l - this tells me that my machine should be rebuild and rebooted
    • rebuild the microvm with sudo microvm -Ru k3s-microvm-2 but this errors out with a message that no rebuild is necessary, contrarty to the output of -l
  • delete vm from /var/lib/microvms/ redeploy host, rebuild with microvm.deploy.rebuild, restart systemd service
  • All of the above followed by restarting the systemd service, ssh'in in to the microvm and using df / to check the size of the root volume. Sometimes the host key changes, which indicates that the root volume was recreated, but the size always remains the same.

The only way I've been able to successfully change the size of the volume is by changing the name of my microvm, and fully redeploying (hence why in these examples the machine is named k3s-microvm-2

Any advice and recommendations is welcomed! I am about to head out but I can provide my config if necessary. Many thanks!

@aidenscott2016 aidenscott2016 changed the title Changing the size of a volume in imperitive microvm help request: Changing the size of a volume in imperitive microvm Dec 26, 2024
@astro
Copy link
Owner

astro commented Dec 27, 2024

The path of a volume is relative so deleting the VM subdirectory in /var/lib/microvms should have deleted the image.

The size option is only used on auto-creation as there is no logic for resizing volumes yet. I wonder at all whether we should ever attempt to do this automatically, given the risk for data loss. I'd accept PRs for growing volumes' file-system, and for logging a warning if a volume should be shrunk.

@aidenscott2016
Copy link
Author

I see, thanks for the explanation. For some reason I was under the impression that the volume was supposed to be ephemeral, and that it would be recreated on each build. I makes sense that it would not be possible to resize the volume if that is not the case.

In other words, the only way for me to change the size of the volume, would be to delete it from /var/lib/microvms? Is it possible to trigger a recreation of the image?

@astro
Copy link
Owner

astro commented Dec 29, 2024

I personally have no use-case for ephemeral volumes, I always want to keep my data.

Trigger automatic recreation by deleting the volume. 😁 I still think that automatic growing could be a useful feature, so I'm leaving this issue opened.

@aidenscott2016
Copy link
Author

I agree that automatic growing would be a useful feature. My use case here was finding out that the default root volume size is not large enough for k3s to work, then failing to increase its size.

I have finally cracked the issue of re-creating the volume after deleting it. I'm not sure what my problem was initially, perhaps I was doing some steps out of order. For reference my working steps were:

  1. delete volume # rm /var/lib/microvms/k3s-microvm-2/root.img
  2. modify microvms.volumes
  3. rebuild nix run .#nixosConfigurations.k3s-microvm-2.config.microvm.deploy.rebuild [email protected] [email protected] -- --use-remote-sudo
  4. restart vm # systemctl restart microvm@k3s-microvm-2

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

No branches or pull requests

2 participants