On 6/28/10, Dave Reisner <d@xxxxxxxxxxxxxx> wrote: > On Mon, Jun 28, 2010 at 07:09:11PM -0300, Denis A. Altoé Falqueto wrote: >> On Mon, Jun 28, 2010 at 5:52 PM, Philipp Überbacher >> <hollunder@xxxxxxxxxxx> wrote: >> > Actually I was recently wondering a bit about the unmounting part, >> > especially with USB sticks. I do have udev rules, taken from the wiki, >> > in place that handle automatic mounting. There's also a unmounting part, >> > which afair removes created dirs, but I guess this is only called after >> > the usb drive is removed. It did happen more than once to me that a file >> > transfer seemed to be complete, but when I just removed the drive, the >> > data was gone. Is there a way to provide automatic safe removal? Manual >> > unmounting is a bit of a PITA, as you need to have a terminal ready, >> > guess sdN and type a line, where the device guessing part is the most >> > problematic. I tend to use /dev/sdN to make sure that I remove the >> > device from all mount points. Thanks for any advice. >> >> Well, automounting is really easy, but auto-unmounting (!?) is >> complex, because what triggers the event is the removal of the device, >> but after you take it, the S.O. can't do anything about it anymore. I >> use KDE, so I can mount and unmount easily. Gnome and XFCE also offer >> good services for that. But without those, I fear that you'll need to >> issue unmount manually. >> > Not entirely true. You can assign the results of a blkid call to the > sysfs node that correlates to the flash drive. A snip from my mounted > flash drive.. > > ... > E: SUBSYSTEM=block > E: DEVNAME=sde1 > E: ID_FS_LABEL=Flashy > E: ID_FS_LABEL_ENC=Flashy > E: ID_FS_UUID=6E1B5F1E742ED9F4 > E: ID_FS_UUID_ENC=6E1B5F1E742ED9F4 > E: ID_FS_TYPE=ntfs > E: ID_FS_USAGE=filesystem > ... > > The ID_FS_xxxx info is from blkid. On the REMOVE event, this information > is still accessible, so I know where the drive is mounted because I > always mount by label. When I remove the drive (without calling umount), > the mount point is destroyed as well. > > Ensure that you're mounting the flash drive with 'sync' if you want to > be able to remove it without calling umount. This will slow down > transfers, but data is written synchronously to disk rather than to an > intermediate buffer. > > As always, the Arch Wiki has examples of this on the Udev page. > > /dave To auto mount/umount usb kind of media without needing even X, you can use usbmount from debian: http://packages.debian.org/sid/usbmount Simple, light and pretty handy. However the umount part is done based upon removal, and the recommended/default way for mounting is with "sync" so that there's no data loss... -- Javier.