can not copy big file to usb device

0

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?

solomon_wzs

Posted 2013-04-13T17:06:13.030

Reputation: 101

>

  • You can monitor read and writes to the device to see when the actual transfer finishes.
  • try to flush the buffers before unmounting. use command sync couple of times.
  • < – mnmnc – 2013-04-13T18:47:26.990

    @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 – 2013-04-13T18:56:56.857

    Answers

    2

    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.)

    maxxvw

    Posted 2013-04-13T17:06:13.030

    Reputation: 381