[systemd-devel] Mounting a partition at the *right* time

Rainer Dorsch ml at bokomoko.de
Mon Jan 4 05:22:12 PST 2016


Hi Mantas,

On Monday 04 January 2016 14:29:23 you wrote:
> On Mon, Jan 4, 2016 at 1:26 PM, Rainer Dorsch <ml at bokomoko.de> wrote:
> > Hi,
> > 
> > 
> > 
> > I am facing an issue with a .mount unit file. The task is simple: mount a
> > partition at the *right* time.
> > 
> > 
> > 
> > The system is OpenElec 6.0, which is based on CoreOS. /etc/fstab is on a
> > squashfs, i.e. it cannot be easily modified and is empty:
> > 
> > 
> > 
> > OpenELEC:~/.config/system.d # cat /etc/fstab
> > 
> > OpenELEC:~/.config/system.d #
> > 
> > 
> > 
> > I would like to mount /storage/.kodi/.local/storage/sdcard after /storage
> > is mounted and before systemd-tmpfiles-setup.service starts executing:
> > 
> > 
> > 
> > I created this .mount unit file:
> > 
> > 
> > 
> > OpenELEC:~/.config/system.d # cat
> > storage-.kodi-.local-storage-sdcard.mount
> > 
> > [Unit]
> > 
> > Description=sdcard mount script
> > 
> > 
> > 
> > #Requires=storage.mount
> > 
> > #After=storage.mount
> > 
> > ConditionPathExists=/storage/.kodi/.local/storage/sdcard
> > 
> > 
> > 
> > Conflicts=umount.target
> > 
> > Before=umount.target systemd-tmpfiles-setup.service
> > 
> > 
> > 
> > [Mount]
> > 
> > What=/dev/mmcblk0p1
> > 
> > Where=/storage/.kodi/.local/storage/sdcard
> > 
> > Options=
> > 
> > Type=ext4
> > 
> > 
> > 
> > 
> > 
> > [Install]
> > 
> > WantedBy=local-fs.target
> 
> Having no CoreOS experience, is "~/.config/system.d/" something specific to
> OpenELEC? I hope you are not trying to use systemd's own ~/.config/systemd/
> here, as that just plain doesn't make sense. (The main init system will not
> look in each user's homedirs, and the per-user instances do not have mount
> privileges...)

I am not an OpenElec expert either (I think it has nothing to do with CoreOS, 
both are a JeOS implementation). What I understood so far: Everything runs as 
root, so there should not be any permission issues.

It is at least the location in which OpenElec has samples for mount units:

OpenELEC:~ # ls -l .config/system.d/
total 56
-rw-r--r--    1 root     root         28816 Jan  1  1970 README
-rw-r--r--    1 root     root          1773 Jan  1  1970 cifs.mount.sample
drwxr-xr-x    2 root     root          4096 Jan  3 22:39 kodi.target.wants
drwxr-xr-x    2 root     root          4096 Jan  3 22:35 local-fs.target.wants
-rw-r--r--    1 root     root          1730 Jan  1  1970 nfs.mount.sample
lrwxrwxrwx    1 root     root            96 Jan  3 22:39 
service.multimedia.vdr-addon.service -> 
/storage/.kodi/addons/service.multimedia.vdr-
addon/system.d/service.multimedia.vdr-addon.service
-rw-r--r--    1 root     root           349 Jan  4 12:09 storage-.kodi-.local-
storage-sdcard.mount
OpenELEC:~ # 

> Can you check the output of `systemctl status
> storage-.kodi-.local-storage-sdcard.mount`?

OpenELEC:~ # systemctl status storage-.kodi-.local-storage-sdcard.mount --no-
pager
● storage-.kodi-.local-storage-sdcard.mount - sdcard mount script
   Loaded: loaded (/storage/.config/system.d/storage-.kodi-.local-storage-
sdcard.mount; enabled; vendor preset: enabled)
   Active: active (mounted) since Mon 2016-01-04 14:11:10 CET; 1min 14s ago
    Where: /storage/.kodi/.local/storage/sdcard
     What: /dev/mmcblk0p1
  Process: 2062 ExecMount=/bin/mount /dev/mmcblk0p1 
/storage/.kodi/.local/storage/sdcard -n -t ext4 (code=exited, 
status=0/SUCCESS)

Jan 04 14:11:10 OpenELEC systemd[1]: Mounting sdcard mount script...
Jan 04 14:11:10 OpenELEC systemd[1]: Mounted sdcard mount script.
OpenELEC:~ # 

Thanks
Rainer

-- 
Rainer Dorsch
http://bokomoko.de/


More information about the systemd-devel mailing list