Remounting CIFS Shares on Suspend/Resume

Warning - Old Content

This post is quite old, and it might not apply anymore, or maybe there's a better way to do the same thing nowadays. Take with a big grain of salt.

I recently set up a mac mini as a media center and file server. This works great, and I was able to easily share certain folders over the network to windows and linux. The only problem is that the samba shares become inaccessible whenever I suspend/resume my laptop.

The fix is to create two scripts, one to be run on suspend and another to be run on resume. This keeps the shares accessible, but be aware that any files that are open on the share will not work as expected when you resume.

/etc/acpi/suspend.d/30-smbfs-umount.sh:

#!/bin/bash

# script idea from:
# https://bugs.launchpad.net/ubuntu/+source/acpi-support/+bug/24864
# Unmount SAMBA shares - open files on these don't survive suspending.

umount -a -l -t smbfs
umount -a -l -t cifs

/etc/acpi/resume.d/30-smbfs-mount.sh:

#!/bin/bash

# script idea from:
# https://bugs.launchpad.net/ubuntu/+source/acpi-support/+bug/24864
# remount SAMBA shares - open files on these don't survive suspending.

mount -a -l -t smbfs
mount -a -l -t cifs

Edit: Updated to use cifs, since amarok didn’t like parsing smbfs mounts.