LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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

Reply
 
Search this Thread
Old 02-05-2008, 07:32 AM   #1
SlowCoder
Member
 
Registered: Oct 2004
Location: Southeast, U.S.A.
Distribution: Fedora (Desktop), CentOS (Server), Knoppix (Diags)
Posts: 934

Rep: Reputation: 38
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?
 
Old 02-05-2008, 08:16 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,118
Blog Entries: 54

Rep: Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785
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.
 
Old 02-05-2008, 08:41 AM   #3
Stéphane Ascoët
Member
 
Registered: Feb 2004
Location: Orleans, 120 km south of Paris
Distribution: Mandrake, Freeduc (the one I'm making), Slackware, MacOS X
Posts: 111

Rep: Reputation: 20
Cool Why not...

Quote:
Originally Posted by SlowCoder View Post
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 View Post
What about it's use on internal hard drives?
We dont use it about drives, but partitions...
 
Old 02-05-2008, 09:20 AM   #4
SlowCoder
Member
 
Registered: Oct 2004
Location: Southeast, U.S.A.
Distribution: Fedora (Desktop), CentOS (Server), Knoppix (Diags)
Posts: 934

Original Poster
Rep: Reputation: 38
Quote:
Originally Posted by unSpawn View Post
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.
 
Old 02-05-2008, 09:31 AM   #5
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,118
Blog Entries: 54

Rep: Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785
Quote:
Originally Posted by SlowCoder View Post
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?
 
Old 02-05-2008, 09:45 AM   #6
SlowCoder
Member
 
Registered: Oct 2004
Location: Southeast, U.S.A.
Distribution: Fedora (Desktop), CentOS (Server), Knoppix (Diags)
Posts: 934

Original Poster
Rep: Reputation: 38
Quote:
Originally Posted by unSpawn View Post
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.
 
Old 02-05-2008, 07:22 PM   #7
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,118
Blog Entries: 54

Rep: Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785
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 :-]
 
Old 02-05-2008, 08:16 PM   #8
SlowCoder
Member
 
Registered: Oct 2004
Location: Southeast, U.S.A.
Distribution: Fedora (Desktop), CentOS (Server), Knoppix (Diags)
Posts: 934

Original Poster
Rep: Reputation: 38
Quote:
Originally Posted by unSpawn View Post
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.
 
Old 02-06-2008, 09:22 AM   #9
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,118
Blog Entries: 54

Rep: Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785
Heh. No need to go all Jedi on me. I'm certainly no guru.

Quote:
Originally Posted by SlowCoder View Post
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.
 
Old 02-06-2008, 12:15 PM   #10
SlowCoder
Member
 
Registered: Oct 2004
Location: Southeast, U.S.A.
Distribution: Fedora (Desktop), CentOS (Server), Knoppix (Diags)
Posts: 934

Original Poster
Rep: Reputation: 38
... 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!
 
Old 02-06-2008, 12:24 PM   #11
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,118
Blog Entries: 54

Rep: Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785
Quote:
Originally Posted by SlowCoder View Post
Muhahaha! I'll be back in 5 minutes!
It isn't about speed?
 
Old 02-07-2008, 06:59 PM   #12
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,118
Blog Entries: 54

Rep: Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785
Uh. OK. Aren't you done reading yet?
 
Old 02-07-2008, 07:10 PM   #13
SlowCoder
Member
 
Registered: Oct 2004
Location: Southeast, U.S.A.
Distribution: Fedora (Desktop), CentOS (Server), Knoppix (Diags)
Posts: 934

Original Poster
Rep: Reputation: 38
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 ...
 
Old 02-07-2008, 07:18 PM   #14
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,118
Blog Entries: 54

Rep: Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785
Quote:
Originally Posted by SlowCoder View Post
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 View Post
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?
 
Old 02-11-2008, 04:56 AM   #15
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,118
Blog Entries: 54

Rep: Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785
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.
 
  


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
No 'sync' or 'async' option specified for export ":ÿ". cccc Linux - Networking 2 05-31-2007 05:31 PM
Mount an USB-Drive sync ToK Ubuntu 4 03-08-2006 03:14 AM
want to mount removable disk as async not sync tkalfaoglu Linux - Software 3 02-10-2006 06:34 AM
can mount C not D FAT: invalid media value (0x45) mount: wrong fs type, bad option Emmanuel_uk Linux - Newbie 10 11-29-2005 02:47 AM
Ho do you use fstab-sync to mount a drive? ginda Linux - Newbie 3 03-15-2005 10:05 AM


All times are GMT -5. The time now is 11:34 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration