Has anyone noticed that if you copy some big file/folder to a removable device (for instance, an USB stick), the progress bar goes to 100% very quick and then the dialog disappears? However, the copying process is still in progress because Linux is pushing the cache to the actual removable unit -- you can notice this with USB sticks that have an external light that blinks when it's being accessed. This means that:
1- you don't really know when the copying process finishes, so the progress bar is pretty useless;
2- if you unplug the removable device you'll end with corrupt files;
So, although cache is good for non-removable devices, it's pretty useless/unsafe for removable devices -- I can't understand why this is set by default on Linux. Does anyone know a solution to this?
An easy way to disable cache just for removable devices
Re: An easy way to disable cache just for removable devices
Hi fulalas,fulalas wrote:Does anyone know a solution to this?
If you mean a solution to wait till the complete copy has finished, what I usually do is after a copy I open a terminal and type sync, and wait till the sync command exits before unplugging the USB device. By the way, it is not just a gui copy with a progress bar, I've seen cp and mv from the command line also exit much earlier than the actual completion of the transfer to a USB stick.
Have no idea about the cache funda.

-
- Full of knowledge
- Posts: 2104
- Joined: 17 Jun 2013, 13:17
- Distribution: Porteus 3.2.2 XFCE 32bit
- Location: Germany
Re: An easy way to disable cache just for removable devices
..it might sound antiquated:fulalas wrote: 2- if you unplug the removable device you'll end with corrupt files;
"one should get used to unmount and eject a (usb) device"
to avoid data loss..

-- write cache --
you could experiment with hdparm -- be carefully
eg.
Code: Select all
hdparm -W 0 /dev/sdX
Code: Select all
hdparm -I /dev/sdX

Re: An easy way to disable cache just for removable devices
@jssouza, thanks for the tip. Isn't exactly what I'm looking for though 
@donald, I'm aware of the eject 'trick', but I'm looking for something more straightforward. Take a look at how Windows works: https://www.tenforums.com/attachments/t ... ache-2.png . And unfortunately these hdparm commands don't work with USB devices. Thanks anyway

@donald, I'm aware of the eject 'trick', but I'm looking for something more straightforward. Take a look at how Windows works: https://www.tenforums.com/attachments/t ... ache-2.png . And unfortunately these hdparm commands don't work with USB devices. Thanks anyway

- brokenman
- Site Admin
- Posts: 6105
- Joined: 27 Dec 2010, 03:50
- Distribution: Porteus v4 all desktops
- Location: Brazil
An easy way to disable cache just for removable devices
Not all devices perhaps. It works on a USB device I just picked up and plugged in. Silicon Power 4Gb flash drive.
hdparm -W0K1 /dev/sdb
This turned off cache writing for the device. Once you can successfully turn off cache writing you can use a udev rule to turn it off every time the device is plugged in. Another option (without getting into the kernel) is to use the flush argument in fstab. Unfortunately all control panel settings are just too basic.
hdparm -W0K1 /dev/sdb
This turned off cache writing for the device. Once you can successfully turn off cache writing you can use a udev rule to turn it off every time the device is plugged in. Another option (without getting into the kernel) is to use the flush argument in fstab. Unfortunately all control panel settings are just too basic.
How do i become super user?
Wear your underpants on the outside and put on a cape.
Wear your underpants on the outside and put on a cape.
An easy way to disable cache just for removable devices
Code: Select all
root@porteus:/home/guest# hdparm -W0K1 /dev/sdd1
/dev/sdd1:
setting drive keep features to 1 (on)
SG_IO: bad/missing sense data, sb[]: 70 00 05 00 00 00 00 0a 00 00 00 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
setting drive write-caching to 0 (off)
SG_IO: bad/missing sense data, sb[]: 70 00 05 00 00 00 00 0a 00 00 00 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
SG_IO: bad/missing sense data, sb[]: 70 00 05 00 00 00 00 0a 00 00 00 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
SG_IO: bad/missing sense data, sb[]: 70 00 05 00 00 00 00 0a 00 00 00 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
SG_IO: bad/missing sense data, sb[]: 70 00 05 00 00 00 00 0a 00 00 00 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
SG_IO: bad/missing sense data, sb[]: 70 00 05 00 00 00 00 0a 00 00 00 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
write-caching = not supported
