Re: [SLE] unplugging USB hard disks
Hello from Adam in NYC w SUSE 10.
As long as you dont have active file access, like a browser looking a subdirectory of the usb drive or a xterm sitting doing the same, you just do sync: sync: sync: and unmount. If there is complaining, then you just boobooed.
Adam
-----Original Message-----
From: Jonathan Brooks
Adam, On Thursday 20 October 2005 14:49, adamvaz@earthlink.net wrote:
Hello from Adam in NYC w SUSE 10.
As long as you dont have active file access, like a browser looking a subdirectory of the usb drive or a xterm sitting doing the same, you just do sync: sync: sync: and unmount. If there is complaining, then you just boobooed.
Let's not propagate or encourage superstitious behavior, OK? Syncing twice in a row is redundant. Syncing before unmounting is redundant. The kernel / FS code will carefully flush all modified internal structures and pending write buffers to the device before the sync(2) system call returns. The only reason to sync before shutting down is because the root file system cannot be unmounted.
Adam
Randall Schulz
On Thursday 20 October 2005 5:57 pm, Randall R Schulz wrote:
The only reason to sync before shutting down is because the root file system cannot be unmounted.
I really never thought about this until now that you mention it. It's logic ok. However, I gave /etc/init.d/halt a look and there are two lines almost at the end: mount -no remount,ro / 2> /dev/null sync One would think (I did) that the / filesystem was unmounted and now it's being "remounted" read-only, which isn't the case. It's just the syntax of the command and its options that will make you think that. My question really is: why the sync command after the drive being mounted read-only? Isn't that a contradiction (to put it read-only, and the perform the sync command? Or is it that the "read-only" option doesn't apply for the actual writing of dirty pages to disk? Just food for thought... Thanks, Jorge
On 10/20/05, Randall R Schulz
Adam,
On Thursday 20 October 2005 14:49, adamvaz@earthlink.net wrote:
Hello from Adam in NYC w SUSE 10.
As long as you dont have active file access, like a browser looking a subdirectory of the usb drive or a xterm sitting doing the same, you just do sync: sync: sync: and unmount. If there is complaining, then you just boobooed.
Let's not propagate or encourage superstitious behavior, OK?
Syncing twice in a row is redundant. Syncing before unmounting is redundant. The kernel / FS code will carefully flush all modified internal structures and pending write buffers to the device before the sync(2) system call returns. The only reason to sync before shutting down is because the root file system cannot be unmounted.
For those of us that work in UNIX environments in addition to Linux it is safest to do the double sync. i.e In general it takes 2 syncs to ensure data is flushed, but with Linux it is safe to do only one. As to what gaureentees umount makes I don't know. I suspect that too is Linux/UNIX specific. I will probably continue my superstitious behaviour of calling sync before I disconnect a hot swappable drive. Greg -- Greg Freemyer The Norcross Group Forensics for the 21st Century
Greg, On Friday 21 October 2005 13:21, Greg Freemyer wrote:
On 10/20/05, Randall R Schulz
wrote: ...
For those of us that work in UNIX environments in addition to Linux it is safest to do the double sync. i.e In general it takes 2 syncs to ensure data is flushed, but with Linux it is safe to do only one.
Now, what's that expression?? Oh, yeah, that's it: BS! I'm sorry, but nonsense is nonsense.
...
Greg
Randall Schulz
Randall R Schulz wrote:
Greg,
On Friday 21 October 2005 13:21, Greg Freemyer wrote:
On 10/20/05, Randall R Schulz
wrote: ... For those of us that work in UNIX environments in addition to Linux it is safest to do the double sync. i.e In general it takes 2 syncs to ensure data is flushed, but with Linux it is safe to do only one.
Now, what's that expression??
Oh, yeah, that's it: BS!
I'm sorry, but nonsense is nonsense.
...
Greg
Randall Schulz
I don't know if this Mac Donalds advert appeared elsewhere in the States, but it was on TV in Northern California ... "Eddie the echo", the guy who repeated everything twice, until one day when he placed his order, to great surprise he didn't repeat it and was puzzled by the look on the young lady's face, then she said "Eddie, you didn't repeat your order", that's the stuff Unix myths are made of. I've seen most of my erstwhile colleagues hitting the enter key umpteen times every time before they type anything into an xterm on Solaris. This prompted me one day to ask a guy why they all do that, he said he didn't know and that was the way all the other guys did it. Regards Sid. -- Sid Boyce ... Hamradio License G3VBV, licensed Private Pilot Retired IBM/Amdahl Mainframes and Sun/Fujitsu Servers Tech Support Specialist Microsoft Windows Free Zone - Linux used for all Computing Tasks
On 10/22/05, Randall R Schulz
Greg,
On Friday 21 October 2005 13:21, Greg Freemyer wrote:
On 10/20/05, Randall R Schulz
wrote: ...
For those of us that work in UNIX environments in addition to Linux it is safest to do the double sync. i.e In general it takes 2 syncs to ensure data is flushed, but with Linux it is safe to do only one.
Now, what's that expression??
Oh, yeah, that's it: BS!
I'm sorry, but nonsense is nonsense.
At least do a "man 2 sync" and read it before you claim to understand it. You will see that the UNIX standard calls for a double sync. It is a Linux _choice_ to implement it as a single sync. Greg -- Greg Freemyer The Norcross Group Forensics for the 21st Century
On Saturday 22 October 2005 08:31, Greg Freemyer wrote:
At least do a "man 2 sync" and read it before you claim to understand it.
You will see that the UNIX standard calls for a double sync. It is a Linux _choice_ to implement it as a single sync.
OK, maybe this doesn't count because it was quite a long ago, but my very first solo SunOS 4.1.x command sequence was "sync sync halt" to bring the system down so I could install an internal SCSI drive. - Carl
On Sat, 2005-10-22 at 08:31 -0400, Greg Freemyer wrote:
On 10/22/05, Randall R Schulz
wrote: Greg,
On Friday 21 October 2005 13:21, Greg Freemyer wrote:
On 10/20/05, Randall R Schulz
wrote: ...
For those of us that work in UNIX environments in addition to Linux it is safest to do the double sync. i.e In general it takes 2 syncs to ensure data is flushed, but with Linux it is safe to do only one.
Now, what's that expression??
Oh, yeah, that's it: BS!
I'm sorry, but nonsense is nonsense.
At least do a "man 2 sync" and read it before you claim to understand it.
You will see that the UNIX standard calls for a double sync. It is a Linux _choice_ to implement it as a single sync.
You're confusing me as well now! Looking at that page on suse 9.3, I don't see anything about a double sync: man 2 sync "According to the standard specification (e.g., SVID), sync() schedules the writes, but may return before the actual writing is done. However, since version 1.3.20 Linux does actually wait. (This still does not guarantee data integrity: modern disks have large caches.)" But in any case, that man page describes the system call while the thread is discussing the shell command. Its man page says: man 8 sync "The sync program does nothing but exercise the sync(2) system call. ... On Linux, sync is only guaranteed to schedule the dirty blocks for writing; it can actually take a short time before all the blocks are finally written. The reboot(8) and halt(8) commands take this into account by sleeping for a few seconds after calling sync(2). This page describes sync as found in the fileutils-4.0 package; other versions may differ slightly." Which is interesting because it seems to make a weaker guarantee than the underlying system call. So perhaps one source of all our confusion is inconsistent documentation. Seems to me that what they both say in effect is to do a single sync and then *wait for the operations to occur*. I guess typing sync again is as good a way as any other to pass some time. Cheers, Dave
On Fri, 21 Oct 2005 16:21:40 -0400
Greg Freemyer
For those of us that work in UNIX environments in addition to Linux it is safest to do the double sync. i.e In general it takes 2 syncs to ensure data is flushed, but with Linux it is safe to do only one.
As to what gaureentees umount makes I don't know. I suspect that too is Linux/UNIX specific. I will probably continue my superstitious behaviour of calling sync before I disconnect a hot swappable drive. Sync is a system call, and it's behavior is a bit different depending if you are SVID, Unix 98, Linux, ... A single sync should be sufficient on any system as long as you don't turn off the power. (Note that Unix people normally do: sync; sync; halt) since sync is asynchronous.
In general, I mostly prefer to umount a USB device because of my Unix
background, but on the newer SuSE and Fedora distros it is not
necessary.
--
Jerry Feldman
-----Original Message-----
From: Jonathan Brooks
Subj: [SLE] unplugging USB hard disks Date: Thu Oct 20, 2005 12:45 pm Size: 1016 bytes To: SLE Hi,
We've got an external USB HDD attached to our SuSE 9.3 box, and is being mounted by HAL (subfs). I have a couple of quick questions:
Is it correct that the filesystem listed by "mount" for the drive in question is floppyfss? I.e. output from mount: /dev/sda1 on /media/disk type subfs (rw,nosuid,nodev,sync,fs=floppyfss,procuid)
Last thing, given that normal users cannot umount the disk, is it okay to just unplug it - obviously they should wait until their files are transferred :) Are there any other safeguards one should recommend?
Cheers, Jon.
<moved to fix top posting>
On 10/20/05, adamvaz@earthlink.net
Hello from Adam in NYC w SUSE 10.
As long as you dont have active file access, like a browser looking a subdirectory of the usb drive or a xterm sitting doing the same, you just do sync: sync: sync: and unmount. If there is complaining, then you just boobooed.
Adam
Actually Jon is right. ie. Just pull the plug when you see no activity. That is true only because of the "sync" option shown on the mount line. With this option all write calls block until the data is on the disk, not on the media. Therefore any time there is no disk activity, the filesytem is stable and it is safe to pull the plug. FYI: The "sync" option has been standard for automount since 9.1 I think. Greg -- Greg Freemyer The Norcross Group Forensics for the 21st Century
* Greg Freemyer
FYI: The "sync" option has been standard for automount since 9.1 I think.
My 9.0 version automatically includes sync in /etc/fstab on hotplugged hard drives and memory cards. -- Patrick Shanahan Registered Linux User #207535 http://wahoo.no-ip.org @ http://counter.li.org HOG # US1244711 Photo Album: http://wahoo.no-ip.org/gallery2
participants (9)
-
adamvaz@earthlink.net
-
Carl Hartung
-
Dave Howorth
-
Greg Freemyer
-
Jerry Feldman
-
Jorge Fábregas
-
Patrick Shanahan
-
Randall R Schulz
-
Sid Boyce