Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
|
02-05-2008, 07:32 AM
|
#1
|
|
Member
Registered: Oct 2004
Location: Southeast, U.S.A.
Distribution: Fedora (Desktop), CentOS (Server), Knoppix (Diags)
Posts: 934
Rep:
|
Mount SYNC option
Is it recommended to use the sync option for removable devices? Wouldn't it help lessen the chance of data loss in the event the device is removed before unmounting?
What about it's use on internal hard drives?
|
|
|
|
02-05-2008, 08:16 AM
|
#2
|
|
Moderator
Registered: May 2001
Posts: 24,970
|
If I may counter that with two things you could research yourself: 0) what does 'man mount' say about the meaning of the option "sync" and 1) can you find out if "umount" does a sync() before unmounting a device?
Last edited by unSpawn; 02-05-2008 at 08:18 AM.
|
|
|
|
02-05-2008, 08:41 AM
|
#3
|
|
Member
Registered: Feb 2004
Location: Orleans, 120 km south of Paris
Distribution: Mandrake, Freeduc (the one I'm making), Slackware, MacOS X
Posts: 108
Rep:
|
Why not...
Quote:
Originally Posted by SlowCoder
Is it recommended to use the sync option for removable devices? Wouldn't it help lessen the chance of data loss in the event the device is removed before unmounting?
|
Recommended, not specially, but usable if you fear a hard disconnection, yes, you can.
Quote:
Originally Posted by SlowCoder
What about it's use on internal hard drives?
|
We dont use it about drives, but partitions...
|
|
|
|
02-05-2008, 09:20 AM
|
#4
|
|
Member
Registered: Oct 2004
Location: Southeast, U.S.A.
Distribution: Fedora (Desktop), CentOS (Server), Knoppix (Diags)
Posts: 934
Original Poster
Rep:
|
Quote:
Originally Posted by unSpawn
If I may counter that with two things you could research yourself: 0) what does 'man mount' say about the meaning of the option "sync" and 1) can you find out if "umount" does a sync() before unmounting a device?
|
unSpawn, I do understand what you are trying to do here ... to teach me to teach myself. Commendable, and I agree. However, I have read documentation, and I think my understanding of sync is on par. But just for the heck of it:
0. the sync option flushes the data stream directly to the device, rather than hold it in the write buffer. This allows faster overall performance, but could potentially result in corruption if the device is disconnected before the buffer is flushed.
1. Yes. umount performs a sync. It would be illogical NOT to sync before removing the device, yes?
However, there are times when I would like to be able to write to a diskette, then temporarily remove the disk for testing (read testing) on another machine, without having to unmount first. I know this goes somewhat against Linux ...
P.S. I like the way you started with 0, instead of 1. Very computerized of you! 
Last edited by SlowCoder; 02-05-2008 at 09:23 AM.
|
|
|
|
02-05-2008, 09:31 AM
|
#5
|
|
Moderator
Registered: May 2001
Posts: 24,970
|
Quote:
Originally Posted by SlowCoder
However, there are times when I would like to be able to write to a diskette, then temporarily remove the disk for testing (read testing) on another machine, without having to unmount first. I know this goes somewhat against Linux ...
|
Ah, why didn't you say that in the first place? You want to deliberately fsck up things!
I'd say that's cool as long as nothing requires to read from or write to the fd while it's removed.
In any case fds are so cheap you could simply test this, right?
|
|
|
|
02-05-2008, 09:45 AM
|
#6
|
|
Member
Registered: Oct 2004
Location: Southeast, U.S.A.
Distribution: Fedora (Desktop), CentOS (Server), Knoppix (Diags)
Posts: 934
Original Poster
Rep:
|
Quote:
Originally Posted by unSpawn
Ah, why didn't you say that in the first place? You want to deliberately fsck up things!
I'd say that's cool as long as nothing requires to read from or write to the fd while it's removed.
In any case fds are so cheap you could simply test this, right?
|
Heh, I would go as far as to say I'm trying to kill my data ...
But I suppose what I want to know is if there's a best practice for sync. For instance, there appears to be a balance between performance and data safety.
So, if my /home directory is mounted default, and some of its data is buffered, then I lose power, that file system has higher potential for corruption. But if the partition is mounted with sync, then that potential is lessened. On the flip side, performance on that partition is also decreased.
Here's one I found ... apparently flash technology life can be lessened if you use sync, due to the write accesses. But a flash drive could be treated just like a floppy, right? If it was mounted sync, could it be removed temporarily? On the other hand, USB tech is typically auto-recognized by Linux these days, so that could be a hassle.
|
|
|
|
02-05-2008, 07:22 PM
|
#7
|
|
Moderator
Registered: May 2001
Posts: 24,970
|
By now now you've tossed all sorts of incomparable hardware examples in the ring just to arrive at your conclusion that "if it works on device Y it should also work on device Z". I could try and support the Dark Side by saying I Find Your Lack Of Faith Disturbing and stuff and talk about buffers, journalling metadata plus data, dirty flags and such I think it won't matter since I think you're gonna try anyway ;-p So.
Quench your thirst for knowledge: experiment with it to experience it :-]
|
|
|
|
02-05-2008, 08:16 PM
|
#8
|
|
Member
Registered: Oct 2004
Location: Southeast, U.S.A.
Distribution: Fedora (Desktop), CentOS (Server), Knoppix (Diags)
Posts: 934
Original Poster
Rep:
|
Quote:
Originally Posted by unSpawn
By now now you've tossed all sorts of incomparable hardware examples in the ring just to arrive at your conclusion that "if it works on device Y it should also work on device Z". I could try and support the Dark Side by saying I Find Your Lack Of Faith Disturbing and stuff and talk about buffers, journalling metadata plus data, dirty flags and such I think it won't matter since I think you're gonna try anyway ;-p So.
Quench your thirst for knowledge: experiment with it to experience it :-]
|
No. You've got me all wrong, Master. You assume to much. I am your Padewan. I desire to learn. I'm not assuming that hard drives, flash drives, and floppy drives should be handled in the same manner. In fact, I believe quite opposite.
Again, I desire to understand best practices, why do we do it the way we do it? Other than performance, why would you mount hard drives async? Why would you mount floppies sync? Do file systems themselves play a role? What is this turtle thing we ride through the vastness of the universe?
Master, teach me. Show me the ways of this force called Linux. Show me how to use my powers to their fullest potential ... Learn me the ways of the Linux Guru.
|
|
|
|
02-06-2008, 09:22 AM
|
#9
|
|
Moderator
Registered: May 2001
Posts: 24,970
|
Heh. No need to go all Jedi on me. I'm certainly no guru.
Quote:
Originally Posted by SlowCoder
Other than performance, why would you mount hard drives async?
|
Performance *is* the reason, but a more suitable term IMHO would be cost so the question becomes: "Why are I/O ops expensive?"
I suggest getting a copy of O'Reilly's "Understanding the Linux Kernel", 3rd Edition (shouldn't be hard to find) and start in the middle with chapter 14 "Block Device Drivers" and read on to section 14.3. "The I/O Scheduler". Then back to 13.4.3.2. "Interrupt mode" which should lead to 4.1. "The Role of Interrupt Signals" and on to the end of chapter 4. Then on to 10.2. "System Call Handler and Service Routines". If that doesn't help make things any clearer just say the word.
|
|
|
|
02-06-2008, 12:15 PM
|
#10
|
|
Member
Registered: Oct 2004
Location: Southeast, U.S.A.
Distribution: Fedora (Desktop), CentOS (Server), Knoppix (Diags)
Posts: 934
Original Poster
Rep:
|
... And I suppose you think this will take me more than an hour to read, so you think you've heard the last from me ... for now? Muhahaha! I'll be back in 5 minutes! 
|
|
|
|
02-06-2008, 12:24 PM
|
#11
|
|
Moderator
Registered: May 2001
Posts: 24,970
|
Quote:
Originally Posted by SlowCoder
Muhahaha! I'll be back in 5 minutes!
|
It isn't about speed?
|
|
|
|
02-07-2008, 06:59 PM
|
#12
|
|
Moderator
Registered: May 2001
Posts: 24,970
|
Uh. OK. Aren't you done reading yet?
|
|
|
|
02-07-2008, 07:10 PM
|
#13
|
|
Member
Registered: Oct 2004
Location: Southeast, U.S.A.
Distribution: Fedora (Desktop), CentOS (Server), Knoppix (Diags)
Posts: 934
Original Poster
Rep:
|
Funny ...
Dern thing is, I haven't had time to run to the book store for the book. Besides, the assignment you gave me is probably worth a month of reading ...
|
|
|
|
02-07-2008, 07:18 PM
|
#14
|
|
Moderator
Registered: May 2001
Posts: 24,970
|
Quote:
Originally Posted by SlowCoder
I haven't had time to run to the book store for the book.
|
I found it on-line and so can you. Else drop me an e-mail.
Quote:
Originally Posted by SlowCoder
the assignment you gave me is probably worth a month of reading ...
|
Hell no, about half an hour, gotta concentrate though ;-p
Again pages/s ain't the thing unless you're one of them LKML guys.
A discussion would be cool. Realise, not tutoring you, I am, OK?
|
|
|
|
02-11-2008, 04:56 AM
|
#15
|
|
Moderator
Registered: May 2001
Posts: 24,970
|
Since you haven't found the time to read yet lets see if I can summarize it a bit for you. Processes live between the CPU and registers (top, bottom half), and that's all nice since it's all low latency locations we're talking about, and since the kernel manages what runs (that's basically what the kernel does: scheduling) it can (UP: seemingly) run many processes at the same time. In short: whatever the kernel does itself *is* asynchronous by design. The "problem" comes when the kernel needs to start an application (read disk to load process image, populate stack) or write out changes to disk. It queues data to be written and issues a write request to the Virtual File System and waits for that process to complete (meanwhile doing something else of course). Writing isn't simply copying data from a memory page to disk sector: the VFS drives the Generic Block Layer (to figure out the files metadata, decrease or increase in size etc, etc *before* actually writing data), then writing data is done by the bottom-most element in this stack: the block device driver (which "talks" to the hardware with hardware requests). While writing the process that needs the write must wait until the write is completed and can't do anything else. Also if two processes want to write to the same file only one single process *can* write to that file (else you get corruption), so unless you can queue that request you'll be blocking that process too. Writes are expensive because data transitions between fast in-kernel structures and relatively slow physical media, because there needs to be set up a lot more processing before the actual write can be done (compared to reads) and because it blocks a process from doing anything else. Now imagine all of that having to respect O_SYNC as well... I hope you get the idea.
* Anyone having their own (rather than linkage) better description or explanation: BMG.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 02:10 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|