LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-25-2015, 07:25 AM   #1
bangnagr
Member
 
Registered: Jan 2013
Posts: 48

Rep: Reputation: 4
How to disable background copy?


Hi all

How do I disable permanently/temporarily copying of files in background? Often while copying many files to usb drive, the message is displayed as 'copying finished'. But when I try to safely remove usb drive, a message pops up like saying 'finishing job... do not unplug usb drive'. And I have to keep looking at the circling animation waiting for it to finish. Some time it takes too long and it is difficult to know whether it hanged or actually doing job in background? Same-thing while copying in terminal too - no difference.

Its same in most of the linux distros I've tried. How do I solve this?

Thanks
 
Old 04-25-2015, 07:44 AM   #2
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060
When you're copying files to a flash drive or other drive (including your hard drive), they're not actually copied directly to the device byte-by-byte: a buffer is filled and when that's full it's flushed to the device. You don't actually write right away, stuff can sit there in memory for some time -- memory is fast, devices are a lot slower.

Here's a trick: if you're doing a large amount of copying, open a terminal and simply type
Code:
sync;sync;sync
and hit the enter key.

That will flush the buffer to the device. You'll notice that there will be a delay while the buffer is written to the device (lights will flash, rain will fall, it'll snow) and, if you repeat the sync it will return almost immediately.

Slow devices (like flash drives) will take a while, a hard drive will take less time but there will be a noticeable delay in either case while the buffer(s) are being written.

Hope this helps some.
 
2 members found this post helpful.
Old 04-25-2015, 07:55 AM   #3
fatmac
Senior Member
 
Registered: Sep 2011
Location: Upper Hale, Surrey/Hants Border, UK
Distribution: AntiX
Posts: 1,978

Rep: Reputation: Disabled
Whilst perhaps not what you are asking, but may be worth looking up, processes can be brought to the foreground via a terminal & cancelled.
 
Old 04-25-2015, 09:42 AM   #4
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,714

Rep: Reputation: 1280Reputation: 1280Reputation: 1280Reputation: 1280Reputation: 1280Reputation: 1280Reputation: 1280Reputation: 1280Reputation: 1280
Quote:
Originally Posted by tronayne View Post
When you're copying files to a flash drive or other drive (including your hard drive), they're not actually copied directly to the device byte-by-byte: a buffer is filled and when that's full it's flushed to the device. You don't actually write right away, stuff can sit there in memory for some time -- memory is fast, devices are a lot slower.

Here's a trick: if you're doing a large amount of copying, open a terminal and simply type
Code:
sync;sync;sync
and hit the enter key.

That will flush the buffer to the device. You'll notice that there will be a delay while the buffer is written to the device (lights will flash, rain will fall, it'll snow) and, if you repeat the sync it will return almost immediately.

Slow devices (like flash drives) will take a while, a hard drive will take less time but there will be a noticeable delay in either case while the buffer(s) are being written.

Hope this helps some.
Sync itself is only a suggestion... The kernel doesn't have to do anything in response.

The only way to ensure that buffers are written to a mounted device is to dismount it. That and that alone will ensure the buffers are on disk. If you are copying to a raw device, the only sure way to know if it is finished is if there is an indicator on the device itself.

Normal I/O to a device will be done in about a millisecond. Only if the system is really busy (or the device is slow and there is a lot of data) will writes take longer. That is why dismounting a filesystem is the only way to ensure the writes- a umount has to wait until the filesystem blocks are all updated before the filesystem can be marked as dismounted and removed from the table.

On one system (it wasn't linux though) sync itself did nothing except exit. Its use in scripts was to cause a minor timing delay (caused by loading and executing the code) which gave the system more time to flush buffers anyway, and it made script compatibility easier.
 
1 members found this post helpful.
Old 04-25-2015, 11:34 AM   #5
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060
Well, a quick look at
Code:
info coreutils 'sync invocation'
indicates
Quote:
`sync' writes any data buffered in memory out to disk. This can
include (but is not limited to) modified superblocks, modified inodes,
and delayed reads and writes. This must be implemented by the kernel;
The `sync' program does nothing but exercise the `sync' system call.

The kernel keeps data in memory to avoid doing (relatively slow) disk
reads and writes. This improves performance, but if the computer
crashes, data may be lost or the file system corrupted as a result.
The `sync' command ensures everything in memory is written to disk.

Any arguments are ignored, except for a lone `--help' or `--version'
(*note Common options:.

An exit status of zero indicates success, and a nonzero value
indicates failure.
Unmounting will, of course, flush the buffers and update the file system. However, because the sync utility does what it does, execute the sync system call, it seems a little quicker and easier to use rather than unmounting and potentially remounting a device.

Hope this helps some.
 
Old 04-25-2015, 12:47 PM   #6
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,714

Rep: Reputation: 1280Reputation: 1280Reputation: 1280Reputation: 1280Reputation: 1280Reputation: 1280Reputation: 1280Reputation: 1280Reputation: 1280
Yeah - I've read that. And also the warnings that parallel writes violate that assumption.

The only way to be sure is to dismount the filesystem before you pull the device out.

Last edited by jpollard; 04-25-2015 at 12:48 PM.
 
Old 04-25-2015, 08:07 PM   #7
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 15,988

Rep: Reputation: 2217Reputation: 2217Reputation: 2217Reputation: 2217Reputation: 2217Reputation: 2217Reputation: 2217Reputation: 2217Reputation: 2217Reputation: 2217Reputation: 2217
I'm with jpollard on this.
Quote:
The `sync' command ensures everything in memory is written to disk.
Note it doesn't say immediately.
I always rely on umount.

When blktrace first became available (in beta) I had lots of fun playing with disk I/O - tools like this are quite educational. Fortunately as they develop, better add-ons arrive which make them easier to use.

Last edited by syg00; 04-25-2015 at 08:09 PM.
 
Old 04-26-2015, 03:50 AM   #8
bangnagr
Member
 
Registered: Jan 2013
Posts: 48

Original Poster
Rep: Reputation: 4
@tronayne, @jpollard

Many thanks
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy file in background sluge Linux - Newbie 6 09-13-2013 01:49 AM
how can we disable change 'desktop background option' / all alternatives for the same prasanth.george Linux - Newbie 3 09-05-2013 09:47 AM
Completely disable the Gnome background setter i92guboj Linux - Desktop 2 09-13-2010 05:26 AM
how to disable the background color on the console? rsmccain SUSE / openSUSE 4 09-13-2006 05:04 PM
Disable background image in KDE only when opened in VNC arobinson74 Linux - General 0 09-01-2004 01:18 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:40 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration