Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I copied one .iso file of size 5 GiB to Pen drive, and after the process completed, I entered the 'sync' command. It took several more minutes to finish the sync.
If I hadn't known about the sync command and had I pulled the USB pen drive, I would have lost the data.
So, is there a way to copy a file to USB or anywhere without using a cache buffer?
Hello All
I copied one .iso file of size 5 GiB to Pen drive, and after the process completed, I entered the 'sync' command. It took several more minutes to finish the sync. If I hadn't known about the sync command and had I pulled the USB pen drive, I would have lost the data. So, is there a way to copy a file to USB or anywhere without using a cache buffer?
Just doing a standard "Eject USB" does the same thing, so even if you didn't know about sync you would have been fine, providing you didn't just yank the drive out. And no, there isn't.
Just doing a standard "Eject USB" does the same thing, so even if you didn't know about sync you would have been fine, providing you didn't just yank the drive out. And no, there isn't.
Sorry, I forgot to mention the copy process was in the terminal with the 'cp' command. No GUI, and was hoping for a solution in the terminal.
Sorry, I forgot to mention the copy process was in the terminal with the 'cp' command. No GUI, and was hoping for a solution in the terminal.
Again, if you just yank the drive out it'll lose data. Again, there is no way to 'write' without that buffer...I'll leave it to you to consider why, and point out the difference in speeds between USB, SSD's/HDD's, etc.
As boughtonp said, umount does the sync for you...same as if you click "Eject Media" (or whatever it is on your GUI).
Many, if not all, GUI file managers also include a right-click menu item to "safely remove" a removable device. If it's not safe to remove yet, the file manager normally will not allow removal.
If I hadn't known about the sync command and had I pulled the USB pen drive, I would have lost the data.
So, is there a way to copy a file to USB or anywhere without using a cache buffer?
Thanks
Simple answer -- No!
All writes to any device are cached and the cache is cleared when the write is complete. Reading is faster than writing so the system always uses a cache during write operations. It takes time to write large quantities of data to a flash drive and it must be complete before the drive is pulled or data corruption will occur.
Using the command "sync" will force the write to complete and the cache to clear but you have to wait for the command prompt to return which indicates the cache is clear.
The "eject" command works similarly but again you must wait for the command prompt to return.
@frankbell gives the info about the gui method. I will note that the later versions of the nautilus file manager put a progress "pie" in the upper right of the window label bar near the minimize, maximize, and close buttons that fills with color as the write proceeds and disappears when done. I believe closing the file manager which started the write/copy before it completes may also interrupt the write but have not tested that myself.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.