LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Any way to remove usb without unmounting? (https://www.linuxquestions.org/questions/linux-software-2/any-way-to-remove-usb-without-unmounting-4175600432/)

Mill J 02-23-2017 09:38 AM

Any way to remove usb without unmounting?
 
Hello
I was wondering if there is any way to make so that you don't have to unmount a usb drive before removing. Like a smartphone you can remove anytime(as long as you're not copying or something). I know unmounting is necessary if you don't want corrupted data. And supposedly sync wears out drives fast. So is there a way to safely remove without unmounting.
Thanks for suggestions.

BW-userx 02-23-2017 10:21 AM

Quote:

Originally Posted by Mill J
is there a way to safely remove without unmounting.

If you mount a horse is there a safe way to get off of that horse without unmounting it?

if one just falls off the horse. You still unmounted the horse. One way or another it gets unmounted.

what you are referring to is what is called hot plugging. If you manually mount a USB port, There is nothing preventing you from just unplugging it. It will not get registered within the system as no longer being there. But you know it is not, because you unplugged it.

Draw backs:
if the system is presently writing to it, data loss.
if the system tries to wite to it, data loss, and a possible error message. Device not present.

that is the reason behind Hot Plugging.

DavidMcCann 02-23-2017 11:14 AM

I think you answered you own question! If the device was accessed while mounted, then corruption is pretty likely.

Also, the filing system will still think the device is there, which can lead to problems. My computer is set up to mount the first usb device as /media/usb, and that is used in my backup script. If I'd accessed another earlier without unmounting it, the backup device would seem to be the second and get mounted under a different name, so the script would fail.

Mill J 02-23-2017 12:26 PM

Sorry guys. I should have mentioned my auto-mount will also remove/unmount the mount point AFTER the usb is removed so that is not a problem. So if I synced it would I still have to manually unmount?

replica9000 02-24-2017 03:57 PM

I'm not sure what you want to happen here. Your system will not know to unmount the drive until you tell it to.

Only thing I can thing of, is if you had an automated task of some sort, maybe a script that detects a specific usb drive, syncs specific data to it, then umounts drive when finished?

Mill J 02-24-2017 04:38 PM

Quote:

Originally Posted by replica9000 (Post 5675594)
I'm not sure what you want to happen here. Your system will not know to unmount the drive until you tell it to.

Only thing I can thing of, is if you had an automated task of some sort, maybe a script that detects a specific usb drive, syncs specific data to it, then umounts drive when finished?

I use a udev rules script and usb activity triggers it. when I insert a usb it creates a mount point and mounts it. when I unplug the usb it unmounts and removes the mount point.

replica9000 02-24-2017 04:57 PM

Quote:

Originally Posted by Mill J (Post 5675606)
I use a udev rules script and usb activity triggers it. when I insert a usb it creates a mount point and mounts it. when I unplug the usb it unmounts and removes the mount point.

What filesystem? Something like vfat might not hold up to unpluging the usb without a proper umount.

Pearlseattle 02-24-2017 05:25 PM

Quote:

Originally Posted by Mill J (Post 5675606)
I use a udev rules script and usb activity triggers it. when I insert a usb it creates a mount point and mounts it. when I unplug the usb it unmounts and removes the mount point.

So you fixed your problem, right?
But if things don't go as expected then the OS will get stuck with the not-unmounted device, right?

Mill J 02-24-2017 06:28 PM

Well obviously unmounting is still needed. I was just wondering if anyone knows if you can do something like that. For now we can only dream. On a regular Linux install it is not really a problem. but minimal.... So until someone comes up with a program to do it the answer is yes you can. But NOT recommended.

Thanks

Pearlseattle 02-24-2017 06:57 PM

Well, the thing is maybe that Linux is more server-driven, therefore anything that happens unexpectedly is bad and has to be reported but no auto-action has to be taken.

E.g. maybe Windows & OSx are more permissive and say "damn, the device is gone - well, if I lost connection with it then it's probably because the user ejected it", while Linux says "OMG what should I do now - I should probably freeze until the admin does something really clever that fixes the unexpected loss of connection/communication with the device".

ondoho 02-25-2017 11:50 AM

in my experience it is ok to just yank the usb stick out - if it isn't an actual rotating hard drive, and if i was only reading from it.
my system never complained, i guess those udev rules just take care of it.


All times are GMT -5. The time now is 10:57 AM.