containers / podman

Podman: A tool for managing OCI containers and pods.
https://podman.io
Apache License 2.0
22.98k stars 2.34k forks source link

Allow specifying path for vhdx file #13984

Open sanyer opened 2 years ago

sanyer commented 2 years ago

Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)

/kind feature

Description

Steps to reproduce the issue:

  1. podman machine init

Describe the results you received:

ext4.vhdx file of a wsl distribution is created in %HOME%.local\share\containers\podman\machine\wsl\wsldist

Describe the results you expected:

Using something like --wsl-distro-path to specify destionation of wsl disk

Additional information you deem important (e.g. issue happens only occasionally):

I was able to relocate distribution by running these commands:

$ wsl --shutdown
$ wsl --export podman-machine-default E:\wsl\podman-machine-default\distro.tar
$ wsl --unregister podman-machine-default
$ wsl --import podman-machine-default E:\wsl\podman-machine-default  E:\wsl\podman-machine-default\distro.tar --version 2

So, it works fine in other location.

Output of podman version:

time="2022-04-23T23:34:58+02:00" level=warning msg="Failed to retrieve default tmp dir: invalid image_copy_tmp_dir value \"/var/tmp\" (relative paths are not accepted)"
Client:       Podman Engine
Version:      4.0.3
API Version:  4.0.3
Go Version:   go1.16.15
Git Commit:   62534053086fdeba7b93117e7c4dc6e797835a3e
Built:        Mon Apr  4 19:34:42 2022
OS/Arch:      windows/amd64

Server:       Podman Engine
Version:      4.0.3
API Version:  4.0.3
Go Version:   go1.16.15
Built:        Fri Apr  1 20:21:14 2022
OS/Arch:      linux/amd64

Output of podman info --debug:

time="2022-04-23T23:36:08+02:00" level=warning msg="Failed to retrieve default tmp dir: invalid image_copy_tmp_dir value \"/var/tmp\" (relative paths are not accepted)"
host:
  arch: amd64
  buildahVersion: 1.24.3
  cgroupControllers: []
  cgroupManager: cgroupfs
  cgroupVersion: v1
  conmon:
    package: conmon-2.1.0-2.fc35.x86_64
    path: /usr/bin/conmon
    version: 'conmon version 2.1.0, commit: '
  cpus: 4
  distribution:
    distribution: fedora
    variant: container
    version: "35"
  eventLogger: file
  hostname: GAMING-DESKTOP
  idMappings:
    gidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 100000
      size: 65536
    uidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 100000
      size: 65536
  kernel: 5.10.102.1-microsoft-standard-WSL2
  linkmode: dynamic
  logDriver: journald
  memFree: 7835369472
  memTotal: 8336093184
  networkBackend: netavark
  ociRuntime:
    name: crun
    package: crun-1.4.4-1.fc35.x86_64
    path: /usr/bin/crun
    version: |-
      crun version 1.4.4
      commit: 6521fcc5806f20f6187eb933f9f45130c86da230
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +YAJL
  os: linux
  remoteSocket:
    exists: true
    path: /run/user/1000/podman/podman.sock
  security:
    apparmorEnabled: false
    capabilities: CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_NET_BIND_SERVICE,CAP_SETFCAP,CAP_SETGID,CAP_SETPCAP,CAP_SETUID,CAP_SYS_CHROOT
    rootless: true
    seccompEnabled: true
    seccompProfilePath: /usr/share/containers/seccomp.json
    selinuxEnabled: false
  serviceIsRemote: true
  slirp4netns:
    executable: /usr/bin/slirp4netns
    package: slirp4netns-1.1.12-2.fc35.x86_64
    version: |-
      slirp4netns version 1.1.12
      commit: 7a104a101aa3278a2152351a082a6df71f57c9a3
      libslirp: 4.6.1
      SLIRP_CONFIG_VERSION_MAX: 3
      libseccomp: 2.5.3
  swapFree: 2145898496
  swapTotal: 2147483648
  uptime: 4m 16.23s
plugins:
  log:
  - k8s-file
  - none
  - passthrough
  - journald
  network:
  - bridge
  - macvlan
  volume:
  - local
registries:
  search:
  - registry.fedoraproject.org
  - registry.access.redhat.com
  - docker.io
  - quay.io
store:
  configFile: /home/user/.config/containers/storage.conf
  containerStore:
    number: 2
    paused: 0
    running: 0
    stopped: 2
  graphDriverName: overlay
  graphOptions:
    overlay.mount_program:
      Executable: /usr/bin/fuse-overlayfs
      Package: fuse-overlayfs-1.7.1-2.fc35.x86_64
      Version: |-
        fusermount3 version: 3.10.5
        fuse-overlayfs: version 1.7.1
        FUSE library version 3.10.5
        using FUSE kernel interface version 7.31
  graphRoot: /home/user/.local/share/containers/storage
  graphStatus:
    Backing Filesystem: extfs
    Native Overlay Diff: "false"
    Supports d_type: "true"
    Using metacopy: "false"
  imageCopyTmpDir: /var/tmp
  imageStore:
    number: 3
  runRoot: /run/user/1000/containers
  volumePath: /home/user/.local/share/containers/storage/volumes
version:
  APIVersion: 4.0.3
  Built: 1648837274
  BuiltTime: Fri Apr  1 20:21:14 2022
  GitCommit: ""
  GoVersion: go1.16.15
  OsArch: linux/amd64
  Version: 4.0.3

Package info (e.g. output of rpm -q podman or apt list podman):

$ scoop info podman

Name        : podman
Description : A tool for managing OCI containers and pods.
Version     : 4.0.3
Bucket      : main
Website     : https://podman.io
License     : Apache-2.0
Updated at  : 04-Apr-22 22:27:06
Updated by  : github-actions[bot]
Installed   : 4.0.3
Binaries    : usr\bin\podman.exe

Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide? (https://github.com/containers/podman/blob/main/troubleshooting.md)

Yes

Additional environment details (AWS, VirtualBox, physical, etc.):

mheon commented 2 years ago

@n1hility PTAL

github-actions[bot] commented 2 years ago

A friendly reminder that this issue had no activity for 30 days.

n1hility commented 2 years ago

This feature request sounds like a good idea. I have it on my eventual todo but if anyone wants to take a stab at contributing this is a nice first time feature. Feel free to ping me on the issue for help if you are interested.

sanyer commented 2 years ago

@n1hility I think I can actually help with it :-)

n1hility commented 2 years ago

Ok great! The init command impl you need to add the parameter to is here: https://github.com/containers/podman/blob/main/cmd/podman/machine/init.go

The backend you need to pass it to and use during import is here:

https://github.com/containers/podman/blob/main/pkg/machine/wsl/machine.go

To build it’s easiest if you do so on a linux env. You can do make podman-remote-windows and copy over the podman.exe

sanyer commented 2 years ago

Perfect, thanks! Btw, I'm using docker to build podman, not on linux per se.

github-actions[bot] commented 2 years ago

A friendly reminder that this issue had no activity for 30 days.

sanyer commented 2 years ago

Good reminder, I'll try to get back to this issue coming week.

github-actions[bot] commented 2 years ago

A friendly reminder that this issue had no activity for 30 days.

rhatdan commented 2 years ago

@sanyer any update.

sanyer commented 2 years ago

@rhatdan I've made progress locally, will PR this weekend.

github-actions[bot] commented 1 year ago

A friendly reminder that this issue had no activity for 30 days.

rhatdan commented 1 year ago

@sanyer Are you still working on this?

sanyer commented 1 year ago

Hey @rhatdan , yes! Coming back to it after a break.

rhatdan commented 1 year ago

Great

n1hility commented 1 year ago

@sanyer did you ever get a chance to look at a patch?

sanyer commented 1 year ago

@n1hility yes, I did. Did even some test builds but got overwhelmed at some point and decided to move it to "better times". What would you say if I push whatever I did to a PR, describe my struggles and get some tips?

vrothberg commented 1 year ago

@sanyer, that sounds great. Feel free to open a PR.

delicacyyy commented 1 year ago

does this feature work? I just tried to migrate my podman 20G vhdx file into new laptop but failed.

sanyer commented 1 year ago

hey @delicacyyy , no, not yet. I don't have enough capacity to find time for this yet. But it is on my list. But I definitely was able to migrate my podman vhdx file. You can try using my gist: https://gist.github.com/sanyer/0d25dbf8e57faaa7358c46cfb746da82

eye942 commented 11 months ago

If it's simply to change where the vhdx file is initialized, I recently found a workaround by setting XDG_DATA_HOME as an environment variable.

It also changes where images are stored, as documented, but it works pretty well for me since I'm running a smaller boot drive and a much larger SSD.

gavenkoa commented 11 months ago

I also is able to relocate WSL 2 image location by wsl utility:

  cd d:/srv/wsl
  mkdir podman-machine-default
  wsl --shutdown
  wsl --export podman-machine-default podman.tar
  wsl --unregister podman-machine-default
  wsl --import podman-machine-default podman-machine-default/ podman.tar --version 2
  del podman.tar

I use lots of tools so I'm afraid of XDG_DATA_HOME - some might use it with unpredictable effect (like Cygwin or MSYS)...