Correct procedure for removing SD cards?


To be clear. my question does not involve USB at all.

I wish to be able to remove an SD card from my Pandora after normal use when I have no PNDs running from that particular SD card.

If I select unmount, it fails.

So far the only safe way to remove an SD card from my pandora, is to first turn of my pandora (a real nusance since it screws up bluetooth operations until a do a few tricks as superuser).
 
While I sounded like I was joking earlier about just pulling them out, I wasn't.. With precautions like waiting a few seconds after last use and such there is minimal risk of data corruption.. I've been using the same SD cards since I got my First Batch Pandora in Feb 2011 without any data loss or need to reformat . 
 
As I understand it (read: not at all, as unmounting works for me, and it's habit) the dirsync option SD cards are automounted with means the Pandora caches very little and instead doesn't allow an operation to complete until all the information is passed safely over the SD interface (and the SD card controller really can't afford to be caching writes for very long at all)


So it ought to be safe to just rip that flash card out with a minimum of warning. Not that I'm taking my own advice.
 
Often the "unmount" from the right click menu doesn't work for me, it keep saying the SD is in use or sometimes that I don't have the rights to do so (I think is something related to SD mounted at the boot VS hot mounted while using the OS)...

so I open a terminal and

sudo umount /media/SDNAME it will be unmounted, and I can remove it happily
 
Last edited by a moderator:
If here is an eject option on the menu. I expect the OS to atleast try unmounting automatically and then eject.

If it's a really fancy OS it should also tell me exactly why it could not unmount and give me some options to resolve the issue.

Kill the app still communicating with the card? (Of course I want to know the name and number of the offending process)

Cancel the ejection?

Screw it, just eject the damn thing!
 
In the beginning I also often had problems with sd-cards not getting cleanly unmounted and because of that was not pleased with the automatic mounting system of the pandora.That's why I setup Mount-Menu. It's no pro-tool, but for me does what it is supposed to do.

MountMenu does provide a more manual way of un-/mounting and gives a bit feedback, but does not directly deal with the issues why a card can not be unmounted when there is an issue.

If you want to understand the system a bit more and find out why an sdcard can not be unmounted, then you should consider trying out a few shell-commands. Here is a quick overview:

1. open a terminal

2. enter "mount" and browse the list. If your sdcard is mounted, then somewhere at the bottom of the list you can see an entry like "/dev/mmcblk1p1 on /media/trans8 type ext2 ....".  If the whole list confuses you, then try "mount | grep mmcblk". That shows only the mounted sdcards.

If something is blocking your card and you want to know why, then:

3. enter "lsof | grep /media/trans8" but replace "/media/trans8" with the name you see in the output of "mount | grep mmcblk" (without the "/" at the end).

That will show you which process is still using the card and so you can ask for more help. Let us know when you need help. I will not go into more detail here, because it's a bit more complicated if a pnd is stuck in the background and thus blocking the sdcard, but if you want to, then I can explain you what to do in such a case.
 
Last edited by a moderator:
Well as of late, the eject feature has been working for me.
 
`I just remove the card, or if I've just been writing stuff on it, I first do a "sync" and wait for it to complete. The cache-writeback settings are such that even that is probably overkill; you can also just wait a couple of seconds and all pending writes will be synced anyway. I guess the correct procedure is to unmount it before physically removing it, to be sure that no processes are still using it. If you're running from NAND and haven't got any PND running from the card you want to remove, I'd say the unmounting and syncing is optional unless you have just done big file transfers or something like that.
 
Often the "unmount" from the right click menu doesn't work for me, it keep saying the SD is in use or sometimes that I don't have the rights to do so (I think is something related to SD mounted at the boot VS hot mounted while using the OS)...
That makes sense. I sometimes forget when I've mounted some non-automounted fs manually and later try to unmount it using the GUI. It moans that it doesn't know about this mount, so I have to go and unmount it again using the command line.

FWIW, on the occasion I've tried to unmount something that genuinely does have something using it, and the error text has suggested a couple of tools I can use to determine what that is... although as far as I can recall, these tools have never found the root of the problem for me :(
 
Last edited by a moderator:
If you try to unmount and it says it is in use, you can open a terminal and type "lsof" (possibly with additional " | grep <name_of_sdcard>", replacing <name_of_sdcard> with the name of your SD card, obviously) to see a list of all open files. That should tell you what is stubbornly refusing to let go.
 
Now we need someone who adds a zenityscript to the unmount command on xfce desktop that shows which programs prevent the sdcard from being unmounted and give an option to kill them.
 
I suppose to be able to do this, just I don't know what script should be modified

EDIT: I found the error string I get when unmounting in "/usr/bin/xfdesktop", but it's a binary file, and I can't find the source in git
 
Last edited by a moderator:
Because I can't find a clue about what should be modified in xfce, I'm doing the script as standalone...
 
Last edited by a moderator:
That looks good :)


Could you add an option to end/kill all processes using the sd and force unmounting?
 
That looks good :)


Could you add an option to end/kill all processes using the sd and force unmounting?
Yeah, that was indeed the point ;)

I'm doing some test, and then I'll make a PND, but naturally should be put in the NAND
 
IIRC, the last time I used Fedora the unmount option in Thunar was labelled 'Eject' for reasons that are beyond my ken.


Unmounting (right click, select 'unmount') works for me on my Pandora. Though these days I rarely eject my cards though - just scp whatever I want from my computer to my Pandora.
On my desktop PC, "Eject" means "Unmount, remove the filesystem from /dev, and, if the hardware supports it, physically eject the disk".

Hence why PCManFM (the LXDE file manager) has both "Unmount" and "Eject". If you want to reformat or repartition an SD card on a system that auto-mounts inserted media, you need to "Unmount" without ejecting but, if you want to eject a CD, you need to "Eject".
 
Back
Top