Skip to content

Instantly share code, notes, and snippets.

Created October 17, 2014 08:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/d12357711ad679fb4d06 to your computer and use it in GitHub Desktop.
Save anonymous/d12357711ad679fb4d06 to your computer and use it in GitHub Desktop.
$ chmod +x /etc/pm/sleep.d/10_mount_umount_disks-hibernate
$ cat /etc/pm/sleep.d/10_mount_umount_disks-hibernate
#!/bin/sh
#
# Action script ensure that shared disks are unmounted
# before a hibernate and re-mounted upon thaw.
# Allowing them to be used in a windows session.
#
# mount -t "ntfs" -o "uhelper=udisks2,nodev,nosuid,uid=1000,gid=1000,dmask=0077,fmask=0077" "/dev/sda9" "/Data"
PATH=/sbin:/usr/sbin:/bin:/usr/bin
_unmount_disks()
{
rm /Data/ubuntu-*mount.ntfs
umount "/Data" || touch /Data/ubuntu-forced-unmount.ntfs && fusermount -uz "/Data"
return 0
}
_remount_disks()
{
mount /Data && rm /Data/ubuntu-*mount.ntfs || \
ntfsfix /dev/sda9 && mount /Data && \
rm /Data/ubuntu-*mount.ntfs && touch /Data/ubuntu-unclean-remount.ntfs
return 0
}
case "${1}" in
hibernate)
_unmount_disks;
;;
thaw)
_remount_disks;
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment