This is quite different, in particular the System V init files don’t work any more and so I need to implement a systemd solution to mount the virtual box shared folders. I think these need to run after the vboxaddclient service. Some documentation suggests that LSB compliant scripts will work. I am about to stop and give it a rest; I am definitely of the view that this was a problem not worth solving.

This where I am, having experimented with my script, I return to using a .mount file

B$ cat import-common.mount 
[Unit]
Description=Mounts common on /import/common
Requires=vboxadd-service graphical.target
After=vboxadd-service tmp.mount graphical.target

[Mount]
What=common
Where=/import/common
Type=vboxsf
Options=rw,uid=1000,gid=1000

[Install]
WantedBy=graphical.target

Errormessages

· import-common.mount - Mounts common on /import/common
   Loaded: loaded (/etc/systemd/system/import-common.mount; enabled;
   Active: inactive(dead)
    Where: /import/common
     What: common

Dead Alleys

So I make a .mount file, the first one fails because I didn’t know that one needs to replace the folder delimiter character i.e. “/” in the unit file name with a “-“. This is hidden in the freedesktop.org manual pages.

Now where are the logs? Hidden behind f*ing binaries, there is a program called journalctl but systemctl status <service name or unit file name> both report the service or mount state.

I experimented with rewriting this as a service using my standard script. I discover that Fedora’s lsb functions file is in a different location to Ubuntu but the script is not a daemon and undertook both the mount and unmount operation.  I have found the vboxadd* service unit files, they are in /lib/systemd/system, they have example code to issue start and stop commands.

I have tried to implement redhat-lsb using yum/dnf. This has different function names to the debian version I have been using.

        mount -t vboxsf -o rw,uid=1000 $1 /import/$1
	case $? in
	0) log_success_msg mounting shared folder $1 ;;
	*) log_failure_msg mounting shared folder $1 ;;
	esac

Here are some links

  1. https://fedoraproject.org/wiki/Systemd
  2. http://searchdatacenter.techtarget.com/tip/Mount-file-system-Linux-systemds-way
  3. https://www.linux.com/learn/understanding-and-using-systemd
  4. https://www.freedesktop.org/software/systemd/man/systemd-sysv-generator.html
  5. http://unix.stackexchange.com/questions/203987/debian-services-not-running/204075#204075
  6. http://unix.stackexchange.com/questions/233468/how-does-systemd-use-etc-init-d-scripts
  7. https://www.freedesktop.org/software/systemd/man/systemd.unit.html#
  8. https://www.freedesktop.org/software/systemd/man/systemd-sysv-generator.html

Mike Davies writes,

…think what you need to do is create a systemd unit file named after the filesystem you want to mount. You have to make the unit filename match the mount point. I think you can pass options to control unit file ordered using the [Requires, Before & After directives

He also recommends,

  1. https://oguya.ch/posts/2015-09-01-systemd-mount-partition/
  2. https://www.digitalocean.com/community/tutorials/understanding-systemd-units-and-unit-files

It maybe right to use a service unit, but I can’t see it myself. It looks like the thing runs start and stop.

And this thread,

  1. https://bbs.archlinux.org/viewtopic.php?id=147790

about how to do an rc.local degenerates into a lovely row about the rights and wrongs of systemd.

 

ooOOOoo

Image Credit: Berndt Rostad @flickr CC 2012 BY, he says “Fedora is not only a type of hat and a Linux distribution (which I happen to use) but also a bar and kitchen in Ledererstrasse 3 in Munich. Hooray.

Dave Linux, Technology , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.