3

I am mounting my Google Drive on login using google-drive-ocamlfuse. The problem is that shutting down or rebooting now seems to have an added 2 minute pause.

Now if when I unmount the Google Drive prior to shutting down, everything goes the way it should and there is no pause.

I inspected some systemd services and built a new one without knowing exactly what I am doing ("educated guess").

/etc/systemd/system/rs-shutdown.service:

# Redsandro 2017-09-1 
# Unmount GoogleDrive to prevent shutdown delay.

[Unit]
Description=Unmount GoogleDrive on shutdown
Before=umount.target shutdown.target reboot.target halt.target

[Service]
Type=oneshot
RemainAfterExit=true
ExecStart=/bin/true
ExecStop=/bin/sh -c "umount /home/redsandro/GoogleDrive"

[Install]
WantedBy=multi-user.target

Then I ran:

sudo systemctl enable rs-shutdown.service
sudo systemctl start rs-shutdown.service

However, shutdown is still lagging by 2 minutes. I still need to manually unmount the share if I want a fast shutdown.

Is there a solution, or is this simply the wrong place to try and do what I want?

I'm Running Linux Mint 17 and Ubuntu 16.04.3.

1
  • Does it unmount cleanly when you do it manually or do you need to close any applications first? – Ken Sharp Jan 10 '18 at 14:53
0

Here's an example of a simple service that performs a task before shutdown. Please note that the default dependencies are disabled by the DefaultDependencies=no option

[Unit]
Description=SleepBeforeShutdown Service
DefaultDependencies=no
Before=halt.target shutdown.target reboot.target

[Service]
Type=oneshot
ExecStart=/bin/sleep 30
RemainAfterExit=yes

[Install]
WantedBy=halt.target shutdown.target reboot.target

After creating/editing your service unit file run systemctl enable yourservice.service and reboot. (it is not necessary to run systemctl start yourservice.service). After that, any time you run shutdown, halt or reboot, the type-oneshot service will do its thing first and then the system proceeds with actual shutdown/reboot.

Edit
I've now found a previous post where the same solution was offered. I do not have the credits to post comments with a link to the question above, so I'll leave my answer as is (even though, strictly speaking, it's a duplicate) Moderators, please remove this post if it violates the rules.

Edit 2
And yet another old post with the same answer. Really not that difficult to find ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.