You are not logged in.

#1 2018-04-17 10:54:46

TheCoon
Member
Registered: 2016-05-10
Posts: 42

[SOLVED] systemd service fails to access /boot

I would like to copy files from /boot/ to /boot/efi/ using a systemd service. Here is my unit file in its current form:

[Unit]
Description=Copy boot files
RequiresMountsFor=/boot/efi /boot /home

[Service]
Type=oneshot
ExecStart=/usr/bin/rsync -tAHX /boot/* /boot/efi/.

[Install]
WantedBy=multi-user.target

I tried using /usr/bin/cp before going the rsync route, but both are failing with the same error:

cannot stat '/boot/*': no such file or directory

The RequiresMountsFor was added after previous failed attempts (the service is originally intended to run before shutdown, this new unit is one I'm using for debugging the error).

The same rsync command works when executed from terminal.

Is there a reason my service wouldn't be able to access/read the files on /boot?

Last edited by TheCoon (2018-04-17 11:53:20)

Offline

#2 2018-04-17 11:35:00

WorMzy
Administrator
From: Scotland
Registered: 2010-06-16
Posts: 13,718
Website

Re: [SOLVED] systemd service fails to access /boot

ExecStart is limited, it doesn't start a shell, so it can't do globbing (and is also why you need absolute binary paths). If you need globbing, then make a script with an appropriate shebang, or wrap the command in a shell (e.g. 'ExecStart=/usr/bin/bash -c "blah blah blah"'.


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

#3 2018-04-17 11:53:04

TheCoon
Member
Registered: 2016-05-10
Posts: 42

Re: [SOLVED] systemd service fails to access /boot

I learned something new today. Thank you!

Offline

Board footer

Powered by FluxBB