linuxkit icon indicating copy to clipboard operation
linuxkit copied to clipboard

Cannot mount virtiofs share on darwin/arm64

Open jankammerath opened this issue 8 months ago • 2 comments

I am trying to mount a virtiofs VZSingleDirectoryShare and receive the folling error on hvc0.

onboot 002-mount: from /containers/onboot/002-mount
mount: mounting containers on /var/lib failed: No such device

The LinuxKit YAML section

onboot:
  - name: mount
    image: linuxkit/mount:cb8caa72248f7082fc2074ce843d53cdc15df04a
    command: ["/bin/mount", "-t", "virtiofs", "containers", "/var/lib"]

Apple Virtualization

let storageUrl = self.getStorageUrl()
let sharedDirectory = VZSharedDirectory(url: storageUrl, readOnly: false)
let singleDirectoryShare = VZSingleDirectoryShare(directory: sharedDirectory)
let sharingConfiguration = VZVirtioFileSystemDeviceConfiguration(tag: "containers")
sharingConfiguration.share = singleDirectoryShare
virtualMachineConfiguration.directorySharingDevices = [sharingConfiguration]

LinuxKit run

I also tried linuxkit run with the following command.

linuxkit run virtualization --virtiofs="containers" linuxkit/linuxkit

The mount command was adjusted to the virtiofs0 tag that LinuxKit uses.

  - name: mount
    image: linuxkit/mount:cb8caa72248f7082fc2074ce843d53cdc15df04a
    command: ["/bin/mount", "-t", "virtiofs", "virtiofs0", "/var/lib"]

In all these cases, mount was unable to access the device.

Many thanks for your support in advance!

jankammerath avatar Apr 08 '25 14:04 jankammerath

It seems like linuxkit/kernel:6.6.71 does not have the virtiofs module.

kernel:
    image: linuxkit/kernel:6.6.71
    cmdline: "console=tty0 console=ttyS0 console=ttyAMA0"
init:
    - linuxkit/init:8eea386739975a43af558eec757a7dcb3a3d2e7b
    - linuxkit/runc:667e7ea2c426a2460ca21e3da065a57dbb3369c9
    - linuxkit/containerd:a988a1a8bcbacc2c0390ca0c08f949e2b4b5915d
    - linuxkit/ca-certificates:7b32a26ca9c275d3ef32b11fe2a83dbd2aee2fdb
onboot:
  - name: modprobe
    image: linuxkit/modprobe:773ee174006ecbb412830e48889795bae40b62f9
    command: ["modprobe", "virtiofs"]
  - name: sysctl
    image: linuxkit/sysctl:5f56434b81004b50b47ed629b222619168c2bcdf
  - name: sysfs
    image: linuxkit/sysfs:7345172dbf4d436c861adfc27150af474194289b
  - name: dhcpcd
    image: linuxkit/dhcpcd:157df9ef45a035f1542ec2270e374f18efef98a5
    command: ["/sbin/dhcpcd", "--nobackground", "-f", "/dhcpcd.conf", "-1"]
  - name: mount
    image: linuxkit/mount:cb8caa72248f7082fc2074ce843d53cdc15df04a
    command: ["/bin/mount", "-t", "virtiofs", "virtiofs0", "/var/lib"]
services:
    - name: getty
      image: linuxkit/getty:05eca453695984a69617f1f1f0bcdae7f7032967
      env:
        - INSECURE=true
    - name: snippetd
      image: alpine:latest
      net: host
      pid: host
      binds:
        - /etc/resolv.conf:/etc/resolv.conf
        - /run:/run
        - /tmp:/tmp
        - /etc:/hostroot/etc
        - /usr/bin/ctr:/usr/bin/ctr
        - /usr/bin/runc:/usr/bin/runc
        - /var/log:/var/log
        - /var/lib/containerd:/var/lib/containerd
        - /run/containerd/containerd.sock:/run/containerd/containerd.sock
        - /dev:/dev
        - /sys:/sys
        - /app/snippetd:/app/snippetd
      command: ["/app/snippetd"]
      capabilities:
        - all
      devices:
        - path: all
          type: a
files:
    - path: /app/snippetd
      source: ./bin/snippetd
      mode: "0755"
trust:
    org:
    - linuxkit

jankammerath avatar Apr 09 '25 06:04 jankammerath

It appears you are correct. 5.11.x config has:

CONFIG_VIRTIO_FS=y

while 5.15.x and 6.6.x have:

# CONFIG_VIRTIO_FS is not set

Not bothering to back-fill for 5.15.x, but we can cut a new 6.6.x with it. The most recent build was 6.6.71, but 6.6.81. We also could cut 6.7.x, 6.8.x or 6.9.x, but that is work to add a new minor series.

deitch avatar Apr 09 '25 10:04 deitch