/usr/lib/systemd/system-sleep script fails with exit status 32

Hello,

I have a 256Gb USB drive that I am using as a second “hard drive.” It has an entry in fstab so it mounts on boot.

UUID=38cb1d9c-477a-422f-8995-a9f8da4ca66d /media/SanDisk3.2Gen1 ext4 defaults,noatime 0 2

However, when the system is put to sleep, by closing lid or power > suspend, the USB drive unmounts and doesn’t automatically remount on system resume. Currently what I do is just open the terminal and run sudo mount -a

I did some researching online and learned I could put bash scripts in the directory /usr/lib/systemd/system-sleep that could run terminal commands upon system resume.
Here is the script I have:

#!/bin/sh
#mount-Sandisk-on-remsume.sh

case $1 in
    pre) ;;
    post) mount -a ;;
esac

But it doesn’t seem to work, the drive is still not mounted on system resume. Here is the error code from journalctl:

Sep 15 22:51:12 Yoga13ManjaroGnome [60544]: /usr/lib/system-sleep/mount-Sandisk-on-resume failed with exit status 32

I can’t find anywhere what exit status 32 means or how I might get this to work properly. Am I even using the best approach? Any advice to make the script work or even how to achieve my goal using a different method would be greatly appreciated. Also let me know if you want more information I’ll do my best to provide it.

this is trouble with USB that do not support sleep in your case

If you do a man mount and type /exit status Enter you’ll find that it’s a generic:

   32     mount failure

so:

  1. Take a stopwatch
  2. Count how long it takes the machine to resume from sleep: that is your X
  3. change:
post) mount -a ;;

to:

post) 
  sleep X
  mount --all
  ;;

I.E. make the mount command wait for X seconds before being executed.

If that doesn’t work, I apologize and :bowing_man: to the wisdom of @stephane and your external USB drive does not support waking up from sleep…

(but it’s worth a :gun: )

:innocent: