Correct procedure for removing SD cards?


Because I can't find a clue about what should be modified in xfce, I'm doing the script as standalone...
"Here just" should be "Here is"
Sorry, but I can't follow you, have you quoted the right sentence ?  :huh:

Anyway I put here a BETA version of the PND if someone wants to try it.

While It works even from an SD, it is not recommended if you actually need to unmount that SD... so here is a little "how to put it in the NAND":

1) open a terminal

2) sudo cp PATH_WHERE_THE_PND_IS_STORED /usr/pandora/apps/

4) reboot (if it's not already appeared in the SYSTEM menu)

EDIT: wait... why it doesn't show on the desktop ?

EDIT2: oh, ok, it was the wrong dir... corrected, anyway it appears only in the menu...  ;)

EDIT3:  - Attached file was Deleted - I will post another version.
 
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...
"Here just" should be "Here is"
Sorry, but I can't follow you, have you quoted the right sentence ?  :huh:

Anyway I put here a BETA version of the PND if someone wants to try it.

While It works even from an SD, it is not recommended if you actually need to unmount that SD... so here is a little "how to put it in the NAND":

1) open a terminal

2) sudo cp PATH_WHERE_THE_PND_IS_STORED /usr/pandora/apps/

4) reboot (if it's not already appeared in the SYSTEM menu)

EDIT: wait... why it doesn't show on the desktop ?

EDIT2: oh, ok, it was the wrong dir... corrected, anyway it appears only in the menu...  ;)
I was writing about the text shown in the 2nd dialog shown in the post that I quoted.
 
Last edited by a moderator:
ah, ok thanks :) that was just a placeholder text

mmm, it's more complicated than a simple "lsof"... if I start a PND from an SD the only used files are in /usr/utmp/<appname>, so if I search for "/media/" I find that nothing is used...
 
Last edited by a moderator:
Search for /mnt/utmp as well, I guess. The PID returned seems to be for the pnd_run.sh process which has the PND file in its argument list. Not completely simple, but still doable. Didn't know that mounted files don't show in lsof. Weird.
 
Just to be sure: You have to search for "/media" not "/media/".

Edit: Crap, false quick-shot of mine. *g* You shouldn't make your first post in the morning a quick one. I mixed something up. When you include the sdcard-name in the search (like "/media/trans8"), then you have to leave out the "/" at the end. At least in the situation of my test that was the case.
 
Last edited by a moderator:
seems like the problems are related to the loop device, anyway this command seems to be useful, because it has a direct reference to the SD: 

Code:
$ sudo losetup -a
/dev/loop0: [b309]:17 (/media/MEGASD/pandora/apps/wesnoth-1.10.6-1.pnd)
and then with
Code:
$ cat /proc/mounts | grep /dev/loop0
/dev/loop0 /mnt/utmp/wesnoth-1.10 squashfs ro,relatime 0 0
I can find another reference
 
Last edited by a moderator:
Tried to run Battle for Wesnoth and GnGeo from an SD to unmount... found all the processes that were using both the loop devices and killed all of them... 

BUT umount reports that the drive is still in use... I added forced unmount to the script at this point, but I want to know what is still in use...

the commands used to find/kill all the processes are these

# to find the loop devices referencing to the mount points of the pnds
sudo losetup -a | grep "/media/MEGASD" | awk '{ print $1 }' | sed 's/\://'

# in this case I have 2 loop devices, for wesnoth and gngeo, but I also tried the mount point directly
sudo lsof /dev/loop0
sudo lsof /dev/loop2
sudo lsof /media/MEGASD
sudo lsof /mnt/utmp/gngeo_pepone
sudo lsof /mnt/utmp/wesnoth-1.10

sudo fuser -m /dev/loop0
sudo fuser -m /dev/loop2
sudo fuser -m /media/MEGASD
sudo fuser -m /mnt/utmp/gngeo_pepone
sudo fuser -m /mnt/utmp/wesnoth-1.10

sudo ls -l /proc/*/cwd | grep "/dev/loop0"
sudo ls -l /proc/*/cwd | grep "/dev/loop2"
sudo ls -l /proc/*/cwd | grep "/media/MEGASD"
sudo ls -l /proc/*/cwd | grep "/mnt/utmp/gngeo_pepone"
sudo ls -l /proc/*/cwd | grep "/mnt/utmp/wesnoth-1.10"
What can I try to find more than these ?
EDIT: the strange thing is that even forced unmount is NOT able to do the job... and I still can't find anything used

EDIT: FOUND THE DAMN THING !!!!

The unmount must be done in MULTIPLE PASSAGES !!!

In my case I need FIRST to unmount the 2 mount points of the PNDs, and THEN the mount point of the SD !!!
 
Last edited by a moderator:
I'm a bit out of this topic, but I used to frequently unmount pnds manually in the early days of the Pandora. If you need more help, then I will look into the subject ones again on the Pandora. For now here is a quick overview from the blurry memory I got:

When a PND is mounted there is a loop-device set up which joins the data from the PND in a read-only mode and the content of the related appdata-folder in write-enabled mode into one merged directory. So everything you write/change is going into the appdata-folder and everything else that is unchanged and read only is taken from the pnd.

 So if you want to unmount a PND you need to:

1) kill all related process that are still running

2) unmount the directories

3) remove the loopdevice by using "losetup -d ...."

4) remove the empty directory and softlink at "/mnt/pnd" and "/mnt/utmp"

Something like that, maybe 2) and 3) have to be done in opposite order.

I am too busy to make a detailed description right now. But maybe that helps you already.
 
Yeah, what I found to do is exactly what you pointed out (and it's indeed in the correct order), so thanks for the confirmation, anyway I didn't think about deleting the mounted files and the link, so I will add even those things...

It will require a bit, because I have to add a lot of conditions to the script now... but maybe I will release another BETA version to try before adding everything.
 
Last edited by a moderator:
Here is a version you can try, It is able to terminate all the running processes related to the selected SD and it can unmount all the opened PNDs in it.

It doesn't delete the junks that PNDs can leave behind because I need to test a few things in strange conditions before releasing it, anyway it's not an issue.

You should copy this PND in /usr/pandora/apps/ but you can find it only in the SYSTEM section of the menu, I still don't know how to show it on the desktop...

EDIT: You should be able to put an icon on the desktop using this command from a terminal


sudo ln -s /usr/share/applications/unmounter-PowerGod#0.desktop ~/Desktop/unmounter-PowerGod#0.desktop
unmounter.pnd
 

Attachments

  • unmounter.pnd
    11.2 KB · Views: 216
Last edited by a moderator:
Back
Top