Tugger the SLUGger!SLUG Mailing List Archives

Re: [SLUG] Hotplug and cached Disk writes


...and then Steve Downing said:
*snip*
> 4. Pause to allow files to be written WITHOUT kernel caching the write.
> 5. Unceremoniously Pull out the USB key.  Hotplug realises and unmounts 
> filesystem and rmmods the unused modules.
*snip* 
> Step 5 is the killer.  I'm not sure it's even sane without risking 
> the obvious possible disk corruption.
> a) I'm not sure hotplug can do the unmounting, it doesn't seem to 
> have a pre/post-removal thing.

hotplug doesn't really have a pre- or post- removal mechanism, but modutils
does.  Stick something like
pre-remove usb-storage umount -f /path/to/mountpoint

in your /etc/modutils.conf to make sure the filesystem gets unmounted.
It'll leave your system without any stale mounts, but there's a very good
chance you'll lose data.

> b) Win98 doesn't seem handle it properly, so why should I expect 
> Linux to.

Because Linux is funky, and there is always a way.  These things use a vfat
filesystem, don't they?  (run 'mount' on its own when the key is mounted to
make sure)  If so, then maybe what you're looking for is mtools.
From the manpage: "mtools - utilities to access DOS disks in Unix."  It
moves things back and forth from MS filesystems, without mounting them, and
handily bypassing the kernel's caching mechanisms.

Install the package and stick a line like:
drive k: file="/dev/sda1"

in your /etc/mtools.conf, adjusting the device to suit.  Then you can
copy files to the key with "mcopy file k:", get a directory listing with
"mdir k:", and so forth.  There are lots of other tools in the package, and
the best way to find out about them is to play with them, which is
something I haven't actually done.

> Is anyone else trying something like this?
Not really, but I'd love to hear how you go..

Peter
peterhardy@xxxxxxxxxxxxxx
-- 
By now the whole of downtown Morpork was alight, and the richer and worthier
citizens of Ankh on the far bank were bravely responding by feverishly
demolishing the bridges.
		   (Terry Pratchett, The Colour of Magic)

Attachment: pgpcDIGpX4oz2.pgp
Description: PGP signature