Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I mount usb device like this:

sudo mount /dev/sdb1 /media/usb

and then copy a big file which about 1Gb to the device:

sudo cp ~/big_file /media/usb

Ordinary, if I copy a big file to usb, the command should run a few minutes. But it finish quickly.

And then I check the file in usb:

md5sum /media/usb/bigfile

It is same as origin file. Then I umount the usb and it run a long time:

sudo umount /media/usb

When I remount the usb device and check the file with md5sum again, the file in usb is different from origin file.

I am sure the device is ok because I can copy the file success in Windows, so what is the problem of my system?

share|improve this question

migrated from stackoverflow.com Apr 13 '13 at 18:36

This question came from our site for professional and enthusiast programmers.

    
1. You can monitor read and writes to the device to see when the actual transfer finishes. 2. try to flush the buffers before unmounting. use command sync couple of times. –  mnmnc Apr 13 '13 at 18:47
    
@mnmnc I run iostat and found that it was still writing data to usb device, although cp was finish. Why cp was finish before the data was copied to usb device completely? –  solomon_wzs Apr 13 '13 at 18:56
add comment

1 Answer 1

up vote 2 down vote accepted

When you copy a big file the system can spend a huge time to execute it, so it's running in background.

Be sure the file copy is complete using # lsof /media/usb/bigfile

You can request a sync of file copy with # sync

And you can umount your device the lazy way: # umount -l /media/usb

From umount(8):

-l Lazy unmount. Detach the filesystem from the filesystem hierarchy now, and cleanup all references to the filesystem as soon as it is not busy anymore. (Requires kernel 2.4.11 or later.)

share|improve this answer
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.