"Save removal" of removable drives


hmc

Active Member
Joined
Dec 19, 2011
Messages
787
Location
Bavaria, Germany
Hi guys,


I often ran into the situation, when I quickly copied a file to an SD card in the Pandora, then removed the SD card and found the file to be 0 bytes in size.


Waiting for some seconds more would probably have avoided the problem. But this always leaves the impression, that one can never be sure, that all data has been written to the device.


I wonder, if it might be desireable to have a "safe hardware removal" feature included in the new Pandora settings applet (/usr/bin/configbutton).


Besides "Enable WiFi", "Enable USB Host" etc., there could be a menu item "Remove hardware", with subitems listing all attached USB drives and inserted SD cards. Clicking one of such items would sync and unmount the corresponding file systems and show a message "you can now remove device XY".


It could also have a special feature, in case you run the OS from an SD card: This system SD card could be listed too, but labeled as "System - not removable".


What do you think about this?


Btw: Who is the developer of this configbutton applet? I have programmed such applets for pdaXrom / weeXpc on the Zaurus already. So maybe I could help implementing such a feature in the applet.


Daniel
 
Last edited by a moderator:
Use sync in a terminal after copying something, wait, until it completes, remove device :)


Edit: But of course it would be nice to have the options to safely unmount left or right sdcard in the menu.
 
Last edited by a moderator:
Sure, when using the terminal anyway, I use sync now, at least when I remember to do so ;-)


But for all other situations, where you don't use the terminal anyway, a GUI solution would be nice.


Well, actually a "Sync filesystems" item in the main menu of the applet could be enough. Would just be nice to have some feedback, when sync is finished, such as a message "sync finished. You can now safely remove the SD card or USB storage".


But maybe it would be a cleaner solution, if the file system is also unmounted before removal? I don't have enough knowledge of how file systems work, so I don't know, if unmounting is entirely redundant, if a "sync" has been done.


Daniel
 
If you use XFCE, you should see the SD card icons on the desktop, right-clicking allows you to "Eject" the card which forces flushing of writes.


Personally, I think writes to an SD card should never be cached (kind of like when you used to copy to floppy disk, you knew exactly when the disk was ready to take out), but hey, what do I know...
 
I've never properly unmounted a card from the Pandora before ejecting, and I don't recall ever having any data loss. If I've just written a file to or from the card, I always wait for that last flash of the LED before ejecting. Usually it means waiting an extra two seconds after the operation has completed.


I thought I read somewhere that FAT32 cards are less volatile than ext* in this regard, but I can't find that info now.
 
Last edited by a moderator:
I can second the experience with FAT32 being less prone to failures than ext file systems! :-(


And yes, the icons on the XFCE desktop are capable to "eject" the cards. But I find it annoying to first have to make the desktop visible.


Also, there is one icon per file system. So if a card or USB disk has more than one partition, you need to unmount each file system seperately, before you remove the device. A per-device eject feature, which takes care of unmounting all corresponding file systems, would be much more convenient.
 
I agree that a "safe removal" feature would be nice to have. I don't agree with pmprog that SD card writes should not be cached: I assume that the cache can avoid actual writes to the card, e.g. if some temporary file is created and removed again before the next cache flush, or if multiple small writes can be accumulated into one big write, so the SD card has to do less block erases. So I would much prefer to have a large cache (whatever fits in the available free RAM) with a large writeback time setting, together with a "safe removal" button, instead of doing all writes instantly. Or perhaps you even want to make it configurable: e.g. a large cache for the left slot, assuming it is your OS/main applications SD card (which never gets removed anyway), and instant writes on the right slot (assuming that is the one that gets replaced often).
 
I don't agree with pmprog that SD card writes should not be cached: I assume that the cache can avoid actual writes to the card, e.g. if some temporary file is created and removed again before the next cache flush, or if multiple small writes can be accumulated into one big write, so the SD card has to do less block erases.
I can see your point. I suppose that is pretty benficial for the lifespan of the card. It's just contrary to the "hot-pluggable" nature of the cards IMO.


The problem you have with just filling up the RAM for a large writeback, esp' on a battery controlled device, is if you lose power (knock the battery etc.), you lose *everything* that would have been written.
 
Thunar should actually display some eject icon for every mounted partition except the one being used as the root partition, which should be used for quickly unmounting stuff like SD cards,

The problem you have with just filling up the RAM for a large writeback, esp' on a battery controlled device, is if you lose power (knock the battery etc.), you lose *everything* that would have been written.
I remember that at some point FAT32 partitions used to be mounted synchronously by default on the Pandora OS, without any caching. However, modern ext partitions just can't live without any caching, it's what actually makes ext4 as fast as it is known for. But b
 
But b? :)


I'd vote for uncached SD/USB support. Too high a risk for the data, IMHO.


The eject functionality of Thunar, as I said before, is on file system / partition level, not on device level. So it would be a mess to eject a USB disk with 4 partitions that way.


That's one of the little things I like about Windows: The tray tool to eject an entire device (no matter how many partitions it may have) with two mouse clicks.
 
Beer + sleeping mood... Results may vary :wacko:

That's one of the little things I like about Windows: The tray tool to eject an entire device (no matter how many partitions it may have) with two mouse clicks.
However, Windows doesn't even support multiple partitions on removable media that are not recognized as a HDD. It simply ignores the partition table making only the first partition accessible, so the only way to use more partitions is to modify the device to be recognize as a non-removable one.
 
It should be relatively easy to add a configuration setting that allows you to choose how each slot gets mounted (synchronous or cached), and an option in the wifi/usb/cpufreq button for safe removal and (in the case of cached cards) sync. Could this be added in the next hotfix?


I want cached writes for both cards, since it improves performance and card life, and I rarely remove cards nor do I experience power problems, so the potential data loss is not really an issue for me.
 
Theoretically one could create a plugin for slaeshjag's configuration applet to unmount the cards. It seems the logical way to do it to me.


- Neelix
 
Hopefully someone can back me up on this, but here's what I recall:


The OS originally mounted SD cards as fully synchronous. This caused poor write speeds. As a result, ED changed it to be cached with a two-second sync time. This improves performance by caching rapid sequential writes, but still allows cards to be removed fairly freely. Within two seconds of the last completed write, all data should be flushed to the card. It sounded like a good compromise to me, but I'm sure ED would like to know if it's not working out.
 
I just rip them out when I please.. because I demand it.
 
Back
Top