Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I use Debian wheezy with KDE4. Most of the time when I copy something to a flashdrive, the write does not actually take place until I unmount. This even happens with relatively large amounts of data (i think some music around 100MB was still buffered until unmount).

Is there any way to tell the OS to write immediately when I tell it to write so I don't have to worry too much about removing my flashdrive without properly unmounting it?

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

You can do this by arranging for the device to be mounted with the sync option. But it's not such a good idea, because this can wear cheap USB flash drives very fast (this has been discussed on the Linux kernel mailing list).

Recent versions of Linux have the flush option for FAT filesystems, which is somewhere between sync and async: it causes all delayed writes to be flushed as soon as the disk becomes inactive. The flush option is on by default in Ubuntu 10.04, but not in Debian wheezy.

See also Should I unmount a USB drive before unplugging it?

share|improve this answer
add comment

The mount command has two related options:

sync All I/O to the filesystem should be done synchronously.

dirsync All directory updates within the filesystem should be done synchronously.

You can specify them in the mount command's -o option:

mount -o sync /mnt/flashdrive

Or in your /etc/fstab's fourth column:

/dev/sdb1 /mnt/flashdrive auto rw,user,noauto,sync 0 0

share|improve this answer
3  
-o flush is preferable to -o sync, as sync will waste time and put more wear and tear on the disk performing every single trivial write, which can wear out the FAT sooner. Flush just makes sure the writing is all done when the file is closed. –  psusi Sep 28 '11 at 18:04
    
You are right. As I remember I never met flash drive with other filesystem than FAT. –  manatwork Sep 28 '11 at 18:32
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.