Would like "quick" unmounting of USB drives - SOLVED

Forum rules
Before you post please read this
crgibson
Level 1
Level 1
Posts: 40
Joined: Thu Apr 27, 2017 6:01 pm

Would like "quick" unmounting of USB drives - SOLVED

Postby crgibson » Sat Aug 12, 2017 4:15 pm

A newbie with 3 USB drives (12 partitions) auto mounting at startup.
I get about 30 sec. startups. Reboots or shutdown take over 2 1/2 min before grub starts up.
When I unmount all partitions before reboot, shutdown takes about 3 sec.

Question: Is there any cmd or "trick" to unmount all partitions with a single click?

Thanks for any help!
Last edited by crgibson on Tue Aug 15, 2017 1:05 pm, edited 1 time in total.
CRGibson System: Host: chuck-GA-MA770-UD3 Kernel: 4.10.0-28-generic x86_64 (64 bit)
Desktop: Cinnamon 3.4.4 Distro: Linux Mint 18.2 Sonya

Mute Ant
Level 12
Level 12
Posts: 4118
Joined: Tue Sep 03, 2013 7:45 pm

Re: Would like "quick" unmounting of USB drives

Postby Mute Ant » Sat Aug 12, 2017 6:42 pm

The ext4 mount has a system variable at /proc/sys/vm/dirty_expire_centisecs which is usually set to a value '3000'. It means the last 30 seconds of drive activity, like closing files and shutting down applications, is still in RAM. Normally that's a good thing; Persistent changes are kept in fast RAM store just-in-case they change again; Hundreds of megabytes that don't get written to the drive until Linux is reasonably sure you want to keep them. Some of your shut-down delay will be everyone trying to write to the hard drive. If you want to shut down faster, you can try...

### Reduce the amount of data allowed to pile up in the cache. 10MB is a similar size to the RAM buffer in a hard drive.
sudo su -c "echo 10000000 > /proc/sys/vm/dirty_bytes"

### Send data in the cache to the drive earlier...ext3 uses 5 seconds.
sudo su -c "echo 500 > /proc/sys/vm/dirty_expire_centisecs"

These are temporary changes...gone next reboot. You can make them permanent with entries in the /etc/sysctl.conf file
vm.dirty_bytes = 10000000
vm.dirty_expire_centisec = 500

A five-second latency has worked fine for ext3 for...fifteen years?. You can make it less, of course, getting closer to a 'sync' mount where changes are written as soon as they happen. On my machine the GUI response starts getting 'gritty' as the drive writes interfere, but my processor is ten years old, maybe 'sync' is just what you want.
Last edited by Mute Ant on Sat Aug 12, 2017 9:29 pm, edited 1 time in total.
Armageddon only happens once, you know. They don’t let you go around again until you get it right.

syg00
Level 4
Level 4
Posts: 211
Joined: Fri Jul 21, 2017 4:00 am

Re: Would like "quick" unmounting of USB drives

Postby syg00 » Sat Aug 12, 2017 7:49 pm

Mute Ant wrote:A five-second latency has worked fine for ext3 for...fifteen years?.
For multiple attached USB devices ?.
I'm more comfortable with the dirty_bytes change than dirty_expire. More (slow) activity on the bus may not be beneficial everywhere, all the time. No real harm in testing it though.

Maybe a simple script to umount them all before shutdown - even a systemd service if you're that keen.

crgibson
Level 1
Level 1
Posts: 40
Joined: Thu Apr 27, 2017 6:01 pm

Re: Would like "quick" unmounting of USB drives

Postby crgibson » Sun Aug 13, 2017 4:06 pm

Mute Ant - Thanks for the suggestions . . . .sadly they did nothing and maybe added a few seconds to the shutdown.
Thanks again.

syg00 - Thanks for the reply. It sounds like a script is what I need. Willing to try anything if it will give a fast shutdown. Do you know of one?

Thanks again
CRGibson System: Host: chuck-GA-MA770-UD3 Kernel: 4.10.0-28-generic x86_64 (64 bit)
Desktop: Cinnamon 3.4.4 Distro: Linux Mint 18.2 Sonya

syg00
Level 4
Level 4
Posts: 211
Joined: Fri Jul 21, 2017 4:00 am

Re: Would like "quick" unmounting of USB drives

Postby syg00 » Sun Aug 13, 2017 10:05 pm

Something as simple as this should work

Code: Select all

for i in /media/$USER/* ; do echo $i ; done
Test it, and when happy, change the "echo" to "umount"; should be no need for sudo.

crgibson
Level 1
Level 1
Posts: 40
Joined: Thu Apr 27, 2017 6:01 pm

Re: Would like "quick" unmounting of USB drives

Postby crgibson » Mon Aug 14, 2017 1:19 pm

syg00 - THanks. I ran "for i in /media/$USER/* ; do echo $i ; done" and got a list of the partitions on the desktop. I changed the "echo" to "umount" and got:

chuck@chuck-GA-MA770-UD3 ~ $ for i in /media/$USER/* ; do umount $i ; done
umount: /media/chuck/BACKUPS: No such file or directory
umount: /media/chuck/LINUX: No such file or directory
umount: /media/chuck/NEW: No such file or directory
umount: /media/chuck/OTR: No such file or directory
umount: /media/chuck/Redo: No such file or directory

The first 4 listed are names for partitions
ions on the desktop and are the only ones still showing on the desktop now.

The "No such file or directory" could be because it's not the full name. ex "BACKUPS" should be "BACKUPS & IMAGES", "LINUX" should be "LINUX ONLY", "NEW" should be "NEW DOWNLOADS" and "OTR" should be "OTR BACKUPS".

All the other partitions are single named.

Any help with this info?

Thanks again for help.
CRGibson System: Host: chuck-GA-MA770-UD3 Kernel: 4.10.0-28-generic x86_64 (64 bit)
Desktop: Cinnamon 3.4.4 Distro: Linux Mint 18.2 Sonya

syg00
Level 4
Level 4
Posts: 211
Joined: Fri Jul 21, 2017 4:00 am

Re: Would like "quick" unmounting of USB drives

Postby syg00 » Mon Aug 14, 2017 7:26 pm

Funny, I thought about that at the time and though "nah, nobody uses spaces (and/or special characters) in labels". Try putting doubles-quotes around the $i to stop the word splitting, like so "$i"

crgibson
Level 1
Level 1
Posts: 40
Joined: Thu Apr 27, 2017 6:01 pm

Re: Would like "quick" unmounting of USB drives

Postby crgibson » Mon Aug 14, 2017 8:04 pm

syg00 - After running: "for i in /media/$USER/* ; do echo "$i" ; done" I get the same over 1 1/2 min. shutdown/reboot.

I assume that I'll have to run any script each time before rebooting?

Thanks for help again!
CRGibson System: Host: chuck-GA-MA770-UD3 Kernel: 4.10.0-28-generic x86_64 (64 bit)
Desktop: Cinnamon 3.4.4 Distro: Linux Mint 18.2 Sonya

syg00
Level 4
Level 4
Posts: 211
Joined: Fri Jul 21, 2017 4:00 am

Re: Would like "quick" unmounting of USB drives

Postby syg00 » Mon Aug 14, 2017 9:52 pm

Echo isn't going to do anything - change it to umount like I said. And yes, before every shutdown.

User avatar
catweazel
Level 10
Level 10
Posts: 3335
Joined: Fri Oct 12, 2012 9:44 pm
Location: Australian Antarctic Territory

Re: Would like "quick" unmounting of USB drives

Postby catweazel » Mon Aug 14, 2017 10:22 pm

crgibson wrote:I assume that I'll have to run any script each time before rebooting?

You can always create a shutdown script and assign a keystroke to it, etc...

https://community.linuxmint.com/tutorial/view/1113
For example.
If your problem is fixed, please mark your thread as [SOLVED] by editing the title of the first message in the thread.

crgibson
Level 1
Level 1
Posts: 40
Joined: Thu Apr 27, 2017 6:01 pm

Re: Would like "quick" unmounting of USB drives

Postby crgibson » Tue Aug 15, 2017 1:04 pm

syg00 - Thank You!!! I just had a brain fart when I looked at what I was doing. I saw 'ECHO' but was thinking "umount". It is working like a charm. Will mark SOLVED.

Thanks Again!

catweazel - Thanks for suggestion and link. I'll get to it next week when I have more time. Thanks.
CRGibson System: Host: chuck-GA-MA770-UD3 Kernel: 4.10.0-28-generic x86_64 (64 bit)
Desktop: Cinnamon 3.4.4 Distro: Linux Mint 18.2 Sonya

User avatar
catweazel
Level 10
Level 10
Posts: 3335
Joined: Fri Oct 12, 2012 9:44 pm
Location: Australian Antarctic Territory

Re: Would like "quick" unmounting of USB drives

Postby catweazel » Tue Aug 15, 2017 8:55 pm

crgibson wrote:tweazel - Thanks for suggestion and link. I'll get to it next week when I have more time. Thanks.

You're welcome.

Cheers.
If your problem is fixed, please mark your thread as [SOLVED] by editing the title of the first message in the thread.


Return to “Mounting Partitions”