Virtual Machine and host storage

Hello!

I’m having a problem accessing my host storage from my new VM, created using

lxc launch images:archlinux/desktop-gnome al --vm -c limits.cpu=8 -c limits.memory=8GiB --console=vga

then I stopped it and


lxc config set al raw.idmap "both 1000 1000"
lxc config device add al storage disk source=/mnt/storage/ path=/mnt/storage/

and started it again.

My host user id is

uid=1000(admin) gid=1000(autologin) grupos=1000(autologin),3(sys),90(network),98(power),960(lxd),985(video),991(lp),998(wheel)

My guest user id is

uid=1000(archlinux) gid=1000(archlinux) groups=1000(archlinux),984(users),985(video),999(adm)

So I change to my /mnt/storage/data and do mkdir test-dir. No problem. Then cd test-dir. All ok.
Then touch test. The file is created, but I get a message

touch: setting times of 'test': Stale file handle

ls -la
drwxr-xr-x 2 archlinux archlinux 4096 Feb 22 09:03 .
drwxr-xr-x 5 archlinux archlinux 4096 Feb 15 19:51 ..
-rw-r--r-- 1 archlinux archlinux    0 Feb 22 09:03 test

But I can’t change, edit, move or delete the file in the VM. And yes, the host can do any file operation with it.

rm: cannot remove 'test': Permission denied
mv: cannot open 'test' for reading: Stale file handle

What am I doing wrong?

Hello again. I’ve tried same procedure with other VM installed from ISO, and I having same behaviour… Do I have a missconcept on how VM work?
I was thinking they have almost the same capabilities than the containers. The above method works 100% in containers.

EDIT: NEVERMIND. I’ve found this in the docs: " Virtual machines share host-side mounts or directories through 9p or virtiofs" So is my fault.

Now I’m trying to find information about how to do it. Someone?

What info are you looking for?

Hello…

I’ve just fixed it.

The directory I was trying to mount was owned by root in the host. I changed the ownership to 1000:1000 (my user in host and guest) and now it works ok. Just doing it as described in my first post.

It is strange because the subdirectory used for my testing was 1000:1000, and the files are created but cannot be changed. After changing the ownership of the main directory this strange effect disappears and I can manipulate files in guest.

Regards

1 Like