You are not logged in.

#1 2012-06-12 13:09:20

ccc1
Member
Registered: 2009-04-16
Posts: 111

[Solved] Safely unmount external usb drive

Hi,

after i umount my external drive, there is still data read/written (?) to the drive for a few seconds, even though the drive doesn't show up as mounted anymore. I guess it has to do with the drive caches.
Is there any command to check if it's safe to remove the drive? I would need it for an undocking scripts ...

ccc1

Last edited by ccc1 (2012-06-13 10:05:35)

Offline

#2 2012-06-12 13:54:52

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [Solved] Safely unmount external usb drive

Offline

#3 2012-06-12 16:11:35

ccc1
Member
Registered: 2009-04-16
Posts: 111

Re: [Solved] Safely unmount external usb drive

I think that's a different problem. In my case the umount command exited, "mount" doesn't show the partition as mounted anymore, but it looks like there is still disk activity (led flashes).

ccc1

Offline

#4 2012-06-12 16:13:36

2ManyDogs
Forum Fellow
Registered: 2012-01-15
Posts: 4,645

Re: [Solved] Safely unmount external usb drive

sync, then unmount, then it's safe.

Last edited by 2ManyDogs (2012-06-12 16:15:36)

Offline

#5 2012-06-12 16:35:39

skanky
Member
From: WAIS
Registered: 2009-10-23
Posts: 1,847

Re: [Solved] Safely unmount external usb drive

Could try this utility, or check the links in the thread: https://bbs.archlinux.org/viewtopic.php?id=130697


"...one cannot be angry when one looks at a penguin."  - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle

Offline

#6 2012-06-12 16:42:35

jdarnold
Member
From: Medford MA USA
Registered: 2009-12-15
Posts: 485
Website

Re: [Solved] Safely unmount external usb drive

Most file explorers on Linux have some kind of option to safely "eject" a USB drive. Which desktop are you using?

Offline

#7 2012-06-12 17:14:56

rdm
Member
From: Italy
Registered: 2012-05-31
Posts: 48

Re: [Solved] Safely unmount external usb drive

Maybe you'd want to use fuser:

http://en.wikipedia.org/wiki/Fuser_(Unix)

Offline

#8 2012-06-13 10:05:19

ccc1
Member
Registered: 2009-04-16
Posts: 111

Re: [Solved] Safely unmount external usb drive

2ManyDogs wrote:

sync, then unmount, then it's safe.

That's the best solution. No idea, why i haven't thought of that ...

ccc1

Offline

#9 2012-06-13 10:24:56

ninian
Member
From: United Kingdom
Registered: 2008-02-24
Posts: 726
Website

Re: [Solved] Safely unmount external usb drive

There's a good discussion and script available at: http://elliotli.blogspot.co.uk/2009/01/ … linux.html
For an up to date Arch though, you've got to tweak the script towards the bottom a bit (name change or something); am not on my Linux system at the moment so can't remember the minor changes exactly. Let me know if you want the tweaked script and I can post it somewhere later.

Last edited by ninian (2012-06-13 10:25:21)

Offline

#10 2012-06-13 10:28:42

skanky
Member
From: WAIS
Registered: 2009-10-23
Posts: 1,847

Re: [Solved] Safely unmount external usb drive

ninian wrote:

There's a good discussion and script available at: http://elliotli.blogspot.co.uk/2009/01/ … linux.html
For an up to date Arch though, you've got to tweak the script towards the bottom a bit (name change or something); am not on my Linux system at the moment so can't remember the minor changes exactly. Let me know if you want the tweaked script and I can post it somewhere later.

That's linked from the blogpost linked at the OP of the thread I posted to. I only mention it as the forked pmount that is the point of that thread is based on the script.


"...one cannot be angry when one looks at a penguin."  - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle

Offline

#11 2012-06-13 10:35:31

ninian
Member
From: United Kingdom
Registered: 2008-02-24
Posts: 726
Website

Re: [Solved] Safely unmount external usb drive

skanky wrote:

That's linked from the blogpost linked at the OP of the thread I posted to. I only mention it as the forked pmount that is the point of that thread is based on the script.

Ah, yes. I tried the safe-removal pmount a while back and had some problems with it IIRC. So that's why I went back to the original script, and I'm now using it (modified as I mentioned) in conjunction with a script calling udevil to unmount.

Offline

#12 2012-06-13 10:40:58

skanky
Member
From: WAIS
Registered: 2009-10-23
Posts: 1,847

Re: [Solved] Safely unmount external usb drive

ninian wrote:
skanky wrote:

That's linked from the blogpost linked at the OP of the thread I posted to. I only mention it as the forked pmount that is the point of that thread is based on the script.

Ah, yes. I tried the safe-removal pmount a while back and had some problems with it IIRC. So that's why I went back to the original script, and I'm now using it (modified as I mentioned) in conjunction with a script calling udevil to unmount.

Okay, let us know the script change. smile


"...one cannot be angry when one looks at a penguin."  - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle

Offline

#13 2012-06-13 19:33:31

ninian
Member
From: United Kingdom
Registered: 2008-02-24
Posts: 726
Website

Re: [Solved] Safely unmount external usb drive

skanky wrote:

Okay, let us know the script change. smile

Here's the patch for you (not a lot to do):

--- suspend-usb-device	2012-06-13 20:21:08.311449540 +0100
+++ suspend-usb-device.patched	2012-06-13 20:24:53.702254506 +0100
@@ -160,7 +160,7 @@
 
     # check if CONFIG_USB_SUSPEND is enabled
     [[ $VERBOSE == 1 ]] && echo "Checking whether $DEVICE can be suspended"
-    POWER_LEVEL_FILE=/sys${DEVICE}/power/level
+    POWER_LEVEL_FILE=/sys${DEVICE}/power/control
     if [ ! -f "$POWER_LEVEL_FILE" ]; then
         1>&2 cat<<EOF
 It's safe to remove the USB device now but better can be done. The
@@ -177,5 +177,5 @@
     fi
 
     [[ $VERBOSE == 1 ]] && echo "Suspending $DEVICE by writing to $POWER_LEVEL_FILE"
-    echo 'suspend' > "$POWER_LEVEL_FILE"
+    echo 'auto' > "$POWER_LEVEL_FILE"
 fi

Offline

#14 2012-06-14 08:41:28

skanky
Member
From: WAIS
Registered: 2009-10-23
Posts: 1,847

Re: [Solved] Safely unmount external usb drive

ninian wrote:
skanky wrote:

Okay, let us know the script change. smile

Here's the patch for you (not a lot to do):

--- suspend-usb-device	2012-06-13 20:21:08.311449540 +0100
+++ suspend-usb-device.patched	2012-06-13 20:24:53.702254506 +0100
@@ -160,7 +160,7 @@
 
     # check if CONFIG_USB_SUSPEND is enabled
     [[ $VERBOSE == 1 ]] && echo "Checking whether $DEVICE can be suspended"
-    POWER_LEVEL_FILE=/sys${DEVICE}/power/level
+    POWER_LEVEL_FILE=/sys${DEVICE}/power/control
     if [ ! -f "$POWER_LEVEL_FILE" ]; then
         1>&2 cat<<EOF
 It's safe to remove the USB device now but better can be done. The
@@ -177,5 +177,5 @@
     fi
 
     [[ $VERBOSE == 1 ]] && echo "Suspending $DEVICE by writing to $POWER_LEVEL_FILE"
-    echo 'suspend' > "$POWER_LEVEL_FILE"
+    echo 'auto' > "$POWER_LEVEL_FILE"
 fi

Thanks smile


"...one cannot be angry when one looks at a penguin."  - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle

Offline

Board footer

Powered by FluxBB