Gangmax Blog

Shared Directory of UTM

From here and here.

This post records the steps that in “utm“ how to make a Linux guest running on a Mac host be able to access the shared directory.

Host setup

First we need to enable the shared directory feature on host. Open the “utm” app, select the target guest VM and open the “Edit selected VM” dialog(the “upper-right” button). In the “Sharing” section, select the “SPICE WebDAV” item in the “Directory Share Mode” field, and the shared directory in the “Path” field, then “Save”.

Guest setup

From here, here and here.

1. Install the required packages first

1
2
3
# When installing "davfs2", it asked whether you want to mount by non-root user,
# I selected yes.
sudo apt install spice-webdavd qemu-guest-agent davfs2

2. Create the target directory

1
mkdir /home/auser/exchange

Update the “/etc/fstab” file by adding the following content.

1
http://127.0.0.1:9843       /home/auser/exchange         davfs           rw,user,uid=auser,noauto 0 0

3. Mount

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# Restart service to reload "/etc/fstab".
systemctl daemon-reload

# Add the current user to the "davfs2" group.
sudo usermod -a -G davfs2 auser

# Mount.
# I had to restart the guest OS to run this command since it reported
# "auser must be in group davfs2" although it's already added. Restarting
# will make it take effect I think?
mount /home/auser/exchange
# It asks for the "username/password" to mount, since need account is needed
# in this case, just enter to go next. If everything works, you should be able
# to see the the content mounted(shared) directory and you can also write files
# in it.

After that, everytime the system is started, you can run “mount /home/auser/exchange” to mount the shared directory.

Comments