Wrong uid/gid on mounted folder in VM

I have a debian vm on a ubuntu host. Mounted a folder like i usually do with a container.
But now the uid is wrong and i cant change it. “Operation not permitted”

I know this is QEMU but how do i set the uid to the correct user?

Hmm, that’s an unexpected behavior unless you happen to be running in a restricted project.

Can you show:

  • incus config show --expanded VM-NAME
  • incus project list
architecture: x86_64
config:
  image.architecture: amd64
  image.description: Debian bookworm amd64 (20241007_05:24)
  image.os: Debian
  image.release: bookworm
  image.serial: "20241007_05:24"
  image.type: disk-kvm.img
  image.variant: default
  limits.cpu: "8"
  limits.memory: 8GiB
  raw.idmap: |-
    uid 1000 1000
    gid 1000 1000
  security.idmap.isolated: "1"
  volatile.base_image: 37145c4210794728f3a16c36e2d4c6cd1a943ed9d1983eafb7a8457b80578e52
  volatile.cloud-init.instance-id: 9a46d7b4-3818-48b8-82df-43d16bab4390
  volatile.eth0.host_name: mac084c25ad
  volatile.eth0.hwaddr: 00:16:3e:28:44:85
  volatile.eth0.last_state.created: "true"
  volatile.last_state.power: RUNNING
  volatile.uuid: 1be9d8d5-27e1-458e-afd1-bf31abbfcb8c
  volatile.uuid.generation: 1be9d8d5-27e1-458e-afd1-bf31abbfcb8c
  volatile.vsock_id: "2883693065"
devices:
  eth0:
    nictype: macvlan
    parent: eno2np1
    type: nic
    vlan: "40"
  root:
    path: /
    pool: default
    size: 150GiB
    type: disk
  test:
    path: /mnt/test
    raw.mount.options: rw,users
    recursive: "false"
    source: /mnt/test
    type: disk
ephemeral: false
profiles:
- vlan40
stateful: false
description: ""
 default (current) | YES    | YES      | YES             | YES             | YES      | YES           | Default Incus project | 25

So I think the issue here may be the raw.idmap.

raw.idmap in the context of a VM controls what uid/gid should be allow for shared disk mounts.
Your configuration likely means that only uid 1000 and gid 1000 are considered valid on that drive.

I suspect raw.idmap came from your default profile in this case. Maybe move the container-specific options to a separate profile so VMs don’t receive those?

Worked like a charm. Thank you.