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

Add configuration option for storage location #2417

Closed
daniel-lenz opened this issue Jan 29, 2022 · 16 comments
Closed

Add configuration option for storage location #2417

daniel-lenz opened this issue Jan 29, 2022 · 16 comments

Comments

@daniel-lenz
Copy link

daniel-lenz commented Jan 29, 2022

What are you trying to do?
Option or configuration needed to save instances/images on a custom path.

What's your proposed solution?
Add configuration file or configuration item (multipass set default.image.path=/some/path).

@daniel-lenz daniel-lenz changed the title Add configuration file or configuration item (multipass set default_image_path = /some/path). Add configuration file or configuration item (multipass set default.image.path=/some/path). Jan 29, 2022
@Saviq
Copy link
Collaborator

Saviq commented Jan 29, 2022

Hi @daniel-lenz, have a look at #1215, it's now possible through the MULTIPASS_STORAGE environment variable. Moving it to a fully supported setting will be slightly trickier - do we move all the data, or only the images? Do we migrate existing VMs? Need to answer such questions.

@daniel-lenz
Copy link
Author

Ok, wow! I'll give it a try now 👍

@daniel-lenz
Copy link
Author

Is not working for me setting MULTIPASS_STORAGE in the override.conf is not working:
● snap.multipass.multipassd.service - Service for snap application multipass.multipassd
Loaded: loaded (/etc/systemd/system/snap.multipass.multipassd.service; enabled; vendor preset: enabled)
Drop-In: /etc/systemd/system/snap.multipass.multipassd.service.d
└─override.conf
Active: failed (Result: exit-code) since Sat 2022-01-29 17:34:27 CET; 3s ago
Process: 15170 ExecStart=/usr/bin/snap run multipass.multipassd (code=exited, status=1/FAILURE)
Main PID: 15170 (code=exited, status=1/FAILURE)

Jan 29 17:34:27 notebook systemd[1]: snap.multipass.multipassd.service: Scheduled restart job, restart counter is at 5.
Jan 29 17:34:27 notebook systemd[1]: Stopped Service for snap application multipass.multipassd.
Jan 29 17:34:27 notebook systemd[1]: snap.multipass.multipassd.service: Start request repeated too quickly.
Jan 29 17:34:27 notebook systemd[1]: snap.multipass.multipassd.service: Failed with result 'exit-code'.
Jan 29 17:34:27 notebook systemd[1]: Failed to start Service for snap application multipass.multipassd.

@daniel-lenz
Copy link
Author

Now I can not use multipass at all:
launch failed: cannot connect to the multipass socket
Please ensure multipassd is running and '/var/snap/multipass/common/multipass_socket' is accessible
snap info multipass
name: multipass
summary: Instant Ubuntu VMs
publisher: Canonical✓
store-url: https://snapcraft.io/multipass
contact: https://github.com/CanonicalLtd/multipass/issues/new
license: GPL-3.0
description: |
Multipass is a tool to launch and manage VMs on Windows, Mac and Linux that simulates a cloud
environment with support for cloud-init. Get Ubuntu on-demand with clean integration to your IDE
and version control on your native platform.

Launch an instance (by default you get the current Ubuntu LTS)

 multipass launch --name foo

Run commands in that instance, try running bash (logout or ctrl-d to quit)

 multipass exec foo -- lsb_release -a

Pass a cloud-init metadata file to an instance on launch

 multipass launch -n bar --cloud-init cloud-config.yaml

See your instances

 multipass list

Stop and start instances

 multipass stop
 multipass start

Get help

 multipass help

commands:

  • multipass.gui
  • multipass
    services:
    multipass.multipassd: simple, enabled, inactive
    snap-id: mA11087v6dR3IEcQLgICQVjuvhUUBUKM
    tracking: latest/edge/pr1789
    refresh-date: today at 17:53 CET
    channels:
    latest/stable: 1.8.0 2021-10-27 (6130) 133MB -
    latest/candidate: 1.8.0 2021-12-02 (6286) 133MB -
    latest/beta: ↑
    latest/edge: 1.9.0-dev.346+gbd2f057c 2022-01-27 (6408) 134MB -
    installed: 1.9.0-dev.346+gbd2f057c (6408) 134MB -

@daniel-lenz
Copy link
Author

seems to be a permission problem:
snap logs multipass
2022-01-29T18:08:07+01:00 systemd[1]: Stopped Service for snap application multipass.multipassd.
2022-01-29T18:08:07+01:00 systemd[1]: Started Service for snap application multipass.multipassd.
2022-01-29T18:08:07+01:00 multipassd[12691]: Caught an unhandled exception: unable to create directory '/vms/cache'
2022-01-29T18:08:07+01:00 systemd[1]: snap.multipass.multipassd.service: Main process exited, code=exited, status=1/FAILURE
2022-01-29T18:08:07+01:00 systemd[1]: snap.multipass.multipassd.service: Failed with result 'exit-code'.
2022-01-29T18:08:08+01:00 systemd[1]: snap.multipass.multipassd.service: Scheduled restart job, restart counter is at 5.
2022-01-29T18:08:08+01:00 systemd[1]: Stopped Service for snap application multipass.multipassd.
2022-01-29T18:08:08+01:00 systemd[1]: snap.multipass.multipassd.service: Start request repeated too quickly.
2022-01-29T18:08:08+01:00 systemd[1]: snap.multipass.multipassd.service: Failed with result 'exit-code'.
2022-01-29T18:08:08+01:00 systemd[1]: Failed to start Service for snap application multipass.multipassd.

@Saviq Saviq changed the title Add configuration file or configuration item (multipass set default.image.path=/some/path). Add configuration option for storage location Jan 29, 2022
@daniel-lenz
Copy link
Author

still getting:
2022-01-29T19:08:50+01:00 multipassd[5492]: Caught an unhandled exception: unable to create directory '/media/cache'

my fstab:
/dev/sda1 on /media type ext4 (rw,relatime)

@daniel-lenz
Copy link
Author

dmesg tells me:
[ 24.322499] audit: type=1400 audit(1643480065.310:84): apparmor="DENIED" operation="mkdir" profile="snap.multipass.multipassd" name="/media/cache/" pid=1469 comm="multipassd" requested_mask="c" denied_mask="c" fsuid=0 ouid=0

@Saviq
Copy link
Collaborator

Saviq commented Jan 29, 2022

@daniel-lenz you need to connect the removable-media interface: sudo snap connect multipass:removable-media. Otherwise confinement won't allow access.

https://snapcraft.io/docs/removable-media-interface

@daniel-lenz
Copy link
Author

daniel-lenz commented Jan 30, 2022

@Saviq saving multipass data on "/media" worked now, but not on another mount point e.g. "/vms". I also disabled apparmor=0 intermediately in grub defaults and activated it again, rebooted and now I am unsure that apparmor.service is running correctly, so I opened an issue with the apparmor-devs here: https://gitlab.com/apparmor/apparmor/-/issues/212

@daniel-lenz
Copy link
Author

ok, apparmor developers checked the service configuration and all looks as it should.
The only thing to do was manually, temporary disable apparmor with adding the grub default parameter "apparmor=0" and reboot. Then multipass service was able to create the directories below my /media-mountpoint.

Afterward removing the parameter "apparmor=0" from grub default and reboot. Multipass works as expected.

Good job!

@Saviq
Copy link
Collaborator

Saviq commented Feb 2, 2022

Glad to hear. I'll leave it open for the full multipass set local.storage=… experience.

@Saviq Saviq reopened this Feb 2, 2022
@daniel-lenz
Copy link
Author

yeah, great @Saviq keep it coming 👍

@daniel-lenz
Copy link
Author

@daniel-lenz you need to connect the removable-media interface: sudo snap connect multipass:removable-media. Otherwise confinement won't allow access.

https://snapcraft.io/docs/removable-media-interface

OMG, shout RTFM to me, my bad! 👍

@cpressland
Copy link

cpressland commented May 18, 2023

Unfortunately it looks like we can no longer set environment variables on macOS using the method described in the documentation.

$ launchctl setenv MULTIPASS_STORAGE "/Volumes/WD2/multipass"
Could not set environment: 150: Operation not permitted while System Integrity Protection is engaged

So that multipass set local.storage= option would be really really helpful for macOS users right about now.

EDIT: As a workaround I've executed the following:

$ launchctl unload /Library/LaunchDaemons/com.canonical.multipassd.plist
$ cd /var/root/Library/Application Support
$ rm -rf multipassd
$ ln -s /Volumes/WD2/multipass/data multipassd
$ launchctl load /Library/LaunchDaemons/com.canonical.multipassd.plist

@huyz
Copy link

huyz commented May 26, 2023

Same as @cpressland . As of macOS 13.4 (Ventura), it looks like launchctl setenv requires disabling System Integrity Protection. So the docs at https://multipass.run/docs/configure-multipass-storage#heading--macos need to be updated with the symlink workaround (I use /Library/Application\ Support/multipassd/data)

@giuliazanchi
Copy link
Contributor

The workaround is documented in https://multipass.run/docs/configure-multipass-storage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants