Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
linux:unmount_all_fuse_mount_points [2011/06/10 17:56]
Joel Dare
linux:unmount_all_fuse_mount_points [2020/06/01 22:53] (current)
Line 1: Line 1:
 +====== Unmount All Fuse Mount Points ======
  
 +On my laptop, a //Macbook Pro 7,1//, I need to remove all the fuse mounts before I disconnect from the network. ​ If I don't disconnect these fuse mount points before I suspend or shut down then fuse seems to lock up.  I believe that is because after I put the machine to sleep it will no longer be connected to the network when I turn it back on.  Here's how I do it.
 +
 +===== The Unmount =====
 +
 +Here's the line of commands I use to unmount all of the mount points currently mounted with fuse.
 +
 +  mount -l -t fuse.sshfs | awk -F " " '​{print "​fusermount -u " $3}' | bash
 +  ​
 +===== How it Works =====
 +
 +I'll break these commands down for you so that they are a little easier to understand.
 +
 +In the first part, we list everything that is currently mounted with a type of //​fuse.sshfs//​.
 +
 +  mount -l -t fuse.sshfs
 +
 +Next, we pipe that output into //awk//, splitting on spaces, and printing out the fusermount command that will unmount each of them.  I have another page about [[:Using Awk on CSV Files]] that explains this command in a little more detail.
 +
 +  awk -F " " '​{print "​fusermount -u " $3}'
 +  ​
 +Finally, we pipe that output back into //bash// so that each command is executed.
 +
 +  bash
 +
 +===== Automatic on Suspend =====
 +
 +On my system, //Ubuntu 10.10 Maverick//, I'm using pm-utils. ​ To execute something on suspend (sleep) I create a script in the /​etc/​pm/​sleep.d directory. ​ Here's the whole script.
 +
 +<​code>​
 +#!/bin/sh
 +
 +mount -l -t fuse.sshfs | awk -F " " '​{print "​fusermount -u " $3}' | bash
 +</​code>​
 +
 +I've called the script //05_fuse// and then I ran chmod to make the file executable.
 +
 +  sudo chmod +x 05_fuse
comments powered by Disqus
linux/unmount_all_fuse_mount_points.txt · Last modified: 2020/06/01 22:53 (external edit)