Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

[Solved] Slow Unmouting USB

Linux Kernel, Network, and Services configuration.
Post Reply
Message
Author
User avatar
Soapm
Posts: 603
Joined: 2012-05-22 04:23
Has thanked: 1 time

[Solved] Slow Unmouting USB

#1 Post by Soapm »

I am having a problem if I don't properly unmount my USB drive before removing it from my server. However, it seems to take upward of 15 minutes (I may be exaggerating) when I do "unmount /movies".

Googling I found this https://lonesysadmin.net/2013/12/22/bet ... rty_ratio/ article basically saying data is sitting in ram that isn't being written to the drive until I try to unmount the drive. And it's writing that data that takes all the time.

In addition to the above article, I found a few site that talk about different settings to adjust to minimize this effect, but none of it is Debian specific and I'm afraid of messing up my good running server.

What do you guys think about this advice I found on a Ubuntu site https://askubuntu.com/questions/410136/ ... es-forever
Workaround: enter a shell root (do that with care --- you are now root for every command)

sudo -i

and issue:

echo $((16*1024*1024)) > /proc/sys/vm/dirty_background_bytes
echo $((48*1024*1024)) > /proc/sys/vm/dirty_bytes

If it works, you can add the two lines above to your /etc/rc.local file.
Again, I'm just afraid of doing more harm than good since I really have no knowledge in this area. I'm just trying to reduce the time it takes the drive to unmount so I can remove it from the server.

My server has 8 gigs of Ram and an Intel G3258 Processor...
Last edited by Soapm on 2018-12-08 21:44, edited 1 time in total.

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 133 times

Re: Slow Unmouting USB

#2 Post by Head_on_a_Stick »

Soapm wrote:I am having a problem if I don't properly unmount my USB drive before removing it from my server. However, it seems to take upward of 15 minutes (I may be exaggerating) when I do "unmount /movies".
I hope that was a typo :)

Try:

Code: Select all

sync ; umount -R /movies && echo Done!
But do not remove the device until you see "Done!" appear in the terminal.
What do you guys think about this advice I found on a Ubuntu site
:lol:
deadbang

Segfault
Posts: 993
Joined: 2005-09-24 12:24
Has thanked: 5 times
Been thanked: 17 times

Re: Slow Unmouting USB

#3 Post by Segfault »

No need to alter systemwide settings, just use sync option to mount this device. Then again, if your server is networked why not use other methods to share your files, like firing up webfs (very light http server). Using USB sticks smells like planting viruses nowadays, they can be used to boot and troubleshoot but I personally have no other use for them.

User avatar
Soapm
Posts: 603
Joined: 2012-05-22 04:23
Has thanked: 1 time

Re: Slow Unmouting USB

#4 Post by Soapm »

Segfault wrote:No need to alter systemwide settings, just use sync option to mount this device. Then again, if your server is networked why not use other methods to share your files, like firing up webfs (very light http server). Using USB sticks smells like planting viruses nowadays, they can be used to boot and troubleshoot but I personally have no other use for them.
I have two USB sticks I use, one for music in the car and the other for movies at the office. I rsync both to folders on my video server as a means of keeping them current and refreshed.

I have a plex server to stream but Comcast has me limited to 1tb/month and my daughter has Netflix. Need I say more?

this is the mount line from my fstab file with user/group ID nobody/nogroup; It mounts via Samba so I can manipulate the files from either of my windows machines if necessary.

Code: Select all

UUID="7488-0B18"     /music        ntfs-3g  defaults,noatime,umask=000,dmask=000,fmask=000,uid=65534,gid=65534        0 0
Do I just add sync like this?

Code: Select all

UUID="7488-0B18"     /music        ntfs-3g  sync,defaults,noatime,umask=000,dmask=000,fmask=000,uid=65534,gid=65534        0 0
Last edited by Soapm on 2018-12-08 20:13, edited 1 time in total.

User avatar
Soapm
Posts: 603
Joined: 2012-05-22 04:23
Has thanked: 1 time

Re: Slow Unmouting USB

#5 Post by Soapm »

Head_on_a_Stick wrote:
Soapm wrote:I am having a problem if I don't properly unmount my USB drive before removing it from my server. However, it seems to take upward of 15 minutes (I may be exaggerating) when I do "unmount /movies".
I hope that was a typo :)
It might be a slight exaggeration but it seems like forever when the wife is blowing the horn or you're running late for a meeting at the office.

Glad I didn't make the changes but I realize that was part of why my usb stick wouldn't plan in the car, I was pulling it out the server without unmouting it first.

I added your line to my bash file so I get the "done" anytime I unmount something...

Segfault
Posts: 993
Joined: 2005-09-24 12:24
Has thanked: 5 times
Been thanked: 17 times

Re: Slow Unmouting USB

#6 Post by Segfault »

TBH I do not think sync as mount option is going to speed up anything, it probably is even not good for flash memory. You could copy like this:

Code: Select all

cp myfile && sync
This will copy and write immediately. How fast - it depends on your USB port and stick speed. Don't expect wonders.

User avatar
Soapm
Posts: 603
Joined: 2012-05-22 04:23
Has thanked: 1 time

Re: Slow Unmouting USB

#7 Post by Soapm »

Segfault wrote:TBH I do not think sync as mount option is going to speed up anything, it probably is even not good for flash memory. You could copy like this:

Code: Select all

cp myfile && sync
This will copy and write immediately. How fast - it depends on your USB port and stick speed. Don't expect wonders.
I use rsync to put the files on the stick, this is the command in my bash file which excludes that annoying "System Volume" folder windows adds to my disk. I guess I can remove that part now that it's been formatted in the debian server.

But are you suggesting something like this?

Code: Select all

alias syncm='rsync -arv --exclude 'System*' /video/Church/Church\ Movies/ /movies/ --delete-after'

Code: Select all

alias syncm='rsync -arv --sync /video/Church/Church\ Movies/ /movies/ --delete-after'
Or how would I include sync with this command...

PS... How about this?

Code: Select all

alias syncm='rsync -arv --exclude 'System*' /video/Church/Church\ Movies/ /movies/ --delete-after' && sync
Last edited by Soapm on 2018-12-08 20:54, edited 1 time in total.

Segfault
Posts: 993
Joined: 2005-09-24 12:24
Has thanked: 5 times
Been thanked: 17 times

Re: Slow Unmouting USB

#8 Post by Segfault »

'sync' is standalone command, see 'man sync'. (Not sure if rsync has similar option.) And don't confuse it with sync mount option, it is not the same thing.
Last edited by Segfault on 2018-12-08 20:56, edited 1 time in total.

User avatar
Soapm
Posts: 603
Joined: 2012-05-22 04:23
Has thanked: 1 time

Re: Slow Unmouting USB

#9 Post by Soapm »

You were answering while I was editing, how about this?

Code: Select all

alias syncm='rsync -arv --exclude 'System*' /video/Church/Church\ Movies/ /movies/ --delete-after && sync'

Segfault
Posts: 993
Joined: 2005-09-24 12:24
Has thanked: 5 times
Been thanked: 17 times

Re: Slow Unmouting USB

#10 Post by Segfault »

Yea, try it out. Note, umount does the same thing, it executes sync before it unmounts.

User avatar
Soapm
Posts: 603
Joined: 2012-05-22 04:23
Has thanked: 1 time

Re: Slow Unmouting USB

#11 Post by Soapm »

Segfault wrote:Yea, try it out. Note, umount does the same thing, it executes sync before it unmounts.
thanks for all the help, I don't have a way to test it until I add or remove more movies but I don't get any errors when I run the command.

Thanks again...

As a side note, I had a made an alias called sync for syncing my music so each time I would run this command I'd see my music syncing. This allowed me to see the error in my ways so now I have "syncmus" and "syncmov". I just hope I can remember my new commands, I am a person to whom old habits die real hard.

Segfault
Posts: 993
Joined: 2005-09-24 12:24
Has thanked: 5 times
Been thanked: 17 times

Re: Slow Unmouting USB

#12 Post by Segfault »

sync as alias is maybe not the best since it will mask the real sync command. I'd use something unique. Otherwise you may need to call it using full path, like this '/bin/sync'.

User avatar
Soapm
Posts: 603
Joined: 2012-05-22 04:23
Has thanked: 1 time

Re: Slow Unmouting USB

#13 Post by Soapm »

Segfault wrote:sync as alias is maybe not the best since it will mask the real sync command. I'd use something unique. Otherwise you may need to call it using full path, like this '/bin/sync'.
Yup, that was the funny part, i didn't realize I had a sync command so didn't realize I had masked it.

But we got her now... Thanks again.

User avatar
Soapm
Posts: 603
Joined: 2012-05-22 04:23
Has thanked: 1 time

Re: [Solved] Slow Unmouting USB

#14 Post by Soapm »

I loaded 4 movies just for kicks and grins, I think this worked because now it takes forever at the end of the rsync command.

But at least it unmounts quickly so that's a plus...

Post Reply