Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Thu 31 Jul 2014, 20:10
All times are UTC - 4
 Forum index » House Training » Users ( For the regulars )
How to unmount .iso files if I forget to?
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [12 Posts]  
Author Message
mini-jaguar

Joined: 13 Nov 2008
Posts: 462

PostPosted: Wed 27 Mar 2013, 14:29    Post subject:  How to unmount .iso files if I forget to?  

I noticed that when I mount an .iso file and don't unmount it, it stays mounted, and after shutting down and rebooting they come back mounted.

Is there a way to unmount all mounted .iso files, or a way to check if there are any and which are mounted?

Please don't post "click on it and it unmounts", that is obvious.
Back to top
View user's profile Send private message 
Karl Godt


Joined: 20 Jun 2010
Posts: 3956
Location: Kiel,Germany

PostPosted: Wed 27 Mar 2013, 22:03    Post subject:  

Older Puppies up to Slacko-5.3.1 had bugs at rc.shutdown in regards to unmounting. That should be fixed better now, but since your dell does not like newer kernels, it might be a good idea to replace the rc.shutdown with one of the newer ones.

But I think the main reason you ask is that clicking on it next time , you get a mount error.
That is also a code bug in /usr/sbin/filemnt, better handled also at later Pups.

IMHO the umount script should delete empty /mnt/+here+crazy+long+name+to+pup.sfs folders using the rmdir command ( rm -rf would erase everything below ) and not the filemnt script, since i unmount these manually in rox window, and since they don't get removed, next time clicking on the .iso i get a mount error first.

What I have experimented with is a rc.shutdown.local script to unmount and rmdir MOUNTPOINT .
rc.shutdown needs probably an extra entry to run a .local sub script.
Back to top
View user's profile Send private message Visit poster's website 
8-bit


Joined: 03 Apr 2007
Posts: 3357
Location: Oregon

PostPosted: Thu 28 Mar 2013, 10:39    Post subject:  

In my case, after a reboot, if I find a directory in /mnt that relates to an iso I had previously mounted and I find it is empty, I just delete that directory from /mnt.
But it is important to make sure that the directory is truly empty since I do not know if deleting it containing files would remove or try to remove the associated files in the directory.
Back to top
View user's profile Send private message 
mini-jaguar

Joined: 13 Nov 2008
Posts: 462

PostPosted: Thu 28 Mar 2013, 10:45    Post subject:  

So you're saying any Puppy newer than 5.3.1 will unmount all .iso files automatically at shut down? I haven't tested this on all Puppies...

But where did you get the idea that my Dell has problems with newer kernels? It has problems with only a few of them, maybe only 3 or 4 don't work out of 10 or 15 I tried with 3.* kernel. All Saluki and Exprimo 5.* work, most Precise derivatives (in fact all except one), all FatDog including 6.2.0beta(only not 6.1.* and UEFI) and all Slacko except for a very slight bug in 5.5, which can be simply ignored by doing simple shut downs instead of rebooting.

On the other hand I was having some serious problems with some of the Dpup 4.* versions, which have 2.* kernels, some of those wouldn't even boot. Puppy 4.2.1 also does not work, only the retro version of it works.

Anyways, I also get the error you mention if I click on it after rebooting, but then I can simply mount the .iso then unmount it and it's fine.

The way I have noticed that there are still mounted .isos is that when I use a program to open a file (for example vlc, mhwaveedit, some video editor), it lists somewhere .isos I may have mounted at one time. I guess I could simply use this as a guide as to which files to unmount.

I was just looking for a simple way to unmount all .isos, like a console command, or a command which lists all the mounted .isos.
Back to top
View user's profile Send private message 
R-S-H

Joined: 18 Feb 2013
Posts: 490

PostPosted: Thu 28 Mar 2013, 11:14    Post subject:  

Hi.

This should do what you want.

Code:
Path=/mnt
Files=`find $Path -maxdepth 1 -type d`
echo "$Files" |while read F
do
   if [ "$F" != "" ]; then
      #echo $F > /tmp/mounted_dir_tmp
      if [[ "$F" == *.iso* ]]; then
         echo $F > /dev/null
         umount $F
         sleep 1 # keep this!!! Maybe set to .5 if successfully tested
         rm -r $F
      fi
   fi
done


RSH

_________________
LazY Puppy Home
The new LazY Puppy Information Centre

Back to top
View user's profile Send private message 
R-S-H

Joined: 18 Feb 2013
Posts: 490

PostPosted: Thu 28 Mar 2013, 11:45    Post subject:  

Hi, again me.

This one is working also for SFS files. I don't know if there are any other file types that could be mounted by a single mouse click. However, the code hopefully makes clear, how to modify this script to make it useable for such files.
Code:
Path=/mnt
Files=`find $Path -maxdepth 1 -type d`
echo "$Files" |while read F
do
   if [ "$F" != "" ]; then
      # Set to don't unmount $F
      do_unmount="false"
      # Check for mounted ISO or SFS
      if [[ "$F" == *.iso* ]]; then
         do_unmount="true"
         elif [[ "$F" == *.sfs* ]]; then
            do_unmount="true"
      fi
      # Unmount if $F is ISO or SFS (do_unmount="true")
      if [ "$do_unmount" = "true" ]; then
         echo $F > /dev/null
         umount $F
         sleep .2 # ---> works well over here
         rm -r $F
      fi
   fi
done

_________________
LazY Puppy Home
The new LazY Puppy Information Centre

Back to top
View user's profile Send private message 
Karl Godt


Joined: 20 Jun 2010
Posts: 3956
Location: Kiel,Germany

PostPosted: Thu 28 Mar 2013, 15:31    Post subject:  

Code:

sync
sleep 3s
#PRIVATE='\.[0-9]*' ##my filemnt mounts without the many + anymore , using pid or random number
BONES='type [[:alnum:]]* (.*)$'
while read device on mountpoint bones
do
[ "$device" ] || continue
[ "$DISPLAY" ] && rox -D "$mountpoint"
echo "'$device' '$mountpoint'"
umount-FULL -d -l -r -v $device
[ $? -eq 0 ] || { echo "Probably failed to unmount."; continue; }
sleep 2s
[ -d "$mountpoint" ] && rmdir "$mountpoint"
done<<EOI
$(mount |tac | grep '^/dev/loop' |grep -v '/initrd' |grep -i -E -e "\.iso$PRIVATE $BONES|\.sfs$PRIVATE $BONES|\.[2-4]fs$PRIVATE $BONES")
EOI

EDIT 1:
* had forgotten to leave out /initrd -> could result in not saving at shutdown
* had \.ext[2-4], while Puppy uses \.[2-4]fs extension
EDIT 2:
* added sync to flush to mounted save-files.3fs
* added sleep because sync may return always zero before the data finished being written
* added test for display and rox -D to close rox windows.

TODO :
* check for usage of fuser to kill opened terminals and others
* support for filename with spaces
* probably write a gui

Last edited by Karl Godt on Sun 31 Mar 2013, 02:12; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website 
mini-jaguar

Joined: 13 Nov 2008
Posts: 462

PostPosted: Sat 30 Mar 2013, 10:29    Post subject:  

RHS's code works pretty well. The only problem that can come up is if I recently opened an .iso by clicking and the window is open with the files in it, all the icons inside disappear and I can't get the files in it to re-appear even by re-clicking.

However, this shouldn't be a problem if I am trying to unmount after a reboot, and even if not rebooted I can visually check if any .isos are open.

Haven't tried your script yet Karl, but I will. And I think I've only tried the first RHS code.
Back to top
View user's profile Send private message 
Karl Godt


Joined: 20 Jun 2010
Posts: 3956
Location: Kiel,Germany

PostPosted: Sat 30 Mar 2013, 18:30    Post subject:  

Puppy code in /usr/local/bin/drive_all and /usr/sbin/filemnt has lines
Code:
rox -D "$mountpoint"

to close the rox filer window - if rox is the file manager you use.
But that would need to be like that :
Code:
[ "$DISPLAY" ] && rox -D "$mountpoint"
sleep 2s

before
rmdir "$mountpoint"
to check if X is still running - otherwise rox will complain a little bit if you run the script after X has been killed by wmpoweroff or wmreboot scripts .

RSH uses rm but in case of an typo like rm -rf and if unmounting fails, it could remove files if the file is still mounted read-write like save-files.3fs .
RSH wrote:
sleep .2 # ---> works well over here
rm -r $F

does not work well for me. To be sure i use sleep 2 , not 0.2 , because removal of the directory often fails, if run too short after the umount command in my experience but everyone has his/hers own preferences.
The directory should be removed, because filemnt script tests if that directory exists next boot, and if so, thinks it is mounted and tries to unmount it at first click, instead of mounting it.

Nevertheless , I have not experienced file-system corruption of read-only files having been mounted at a hard-poweroff.

Another idea would be to run the sync command before the unmounting loop starts, like :

Code:
sync
sleep 3

#here now main part of script .
Back to top
View user's profile Send private message Visit poster's website 
mini-jaguar

Joined: 13 Nov 2008
Posts: 462

PostPosted: Tue 02 Apr 2013, 10:57    Post subject:  

Second RHS script works well. Close window, reclick, and .iso mounts again. But the first time it had a slight problem unmounting an .iso that was open from a previous session (on a previous boot). Running it a second time unmounted that .iso though.

Actually that is a normal function of Puppy that the icons disappear from an unmounted volume if its window is open (unless a script is written to automatically close it, I guess), I remember from Saluki.

Karl Godt's script works intermittently, one time it seemed to work, one time it didn't unmount the mounted .isos, another time it unmounted but blocked all .iso files from mounting again, even after rebooting. Running the second RHS script made it work normally again.

But maybe it works fine on Karl's computer, just not mine. I'm not an expert in programming anyways.

Modifying sleep .2 to sleep 2 in RHS's script made it bug, that it was hard to remount an .iso after running the script, had to try clicking on it several times until it finally mounted.
Back to top
View user's profile Send private message 
nooby

Joined: 29 Jun 2008
Posts: 10557
Location: SwedenEurope

PostPosted: Tue 02 Apr 2013, 13:21    Post subject:  

I have a very poor memory. So have patience now with an old guy. Smile

My recall is that I could have mounted an iso say july 2012 and
then get back to it say yesterday and it is still mounted
and has to be unmounted before I get access to the files?

Am I correct or is that poor memory How long time does it stay mounted
unless one manually unmount it?

_________________
I use Google Search on Puppy Forum
not an ideal solution though
Back to top
View user's profile Send private message 
Karl Godt


Joined: 20 Jun 2010
Posts: 3956
Location: Kiel,Germany

PostPosted: Wed 03 Apr 2013, 14:26    Post subject:  

nooby wrote:
I have a very poor memory. So have patience now with an old guy. Smile

My recall is that I could have mounted an iso say july 2012 and
then get back to it say yesterday and it is still mounted
and has to be unmounted before I get access to the files?

Am I correct or is that poor memory How long time does it stay mounted
unless one manually unmount it?

Puppy has confusing code : /usr/sbin/filemnt is the mime-type starter application if clicked on some loop mountable files : .iso, .sfs, .2fs .
/usr/sbin/filemnt creates the /mnt/+crazy+long+path+here+puppy_version.iso directory, if it does not already exist.
If mount fails, it does not remove the created directory. This is important to know for older Puppies being unable to mount new xz compressed .sfs :
The mountpoint gets created and rox opens a window in that mountpoint-directory without contents ( harmlless buguletti ) .

Also older filemnt scripts had code like this :
Code:
  rox -D $MntPt #BK
  umount $MntPt
  Err=$?
  rmdir $MntPt

Newer filemnt has moved the rmdir $MntPt line further down below the yaf-splash -timeout 3 line to make it more sure, that the directory got removed.

IMPORTANT : If you use the commands
Code:
umount /mnt/+crazy+long+path+here+puppy_version.iso

or
Code:
umount-FULL /mnt/+crazy+long+path+here+puppy_version.iso

or unmount it by choosing the unmount option in the ROX-Filer right click menu ,
this /mnt/+crazy+long+path+here+puppy_version.iso directory
does not get removed also.
It only gets removed if left-clicked on that .iso file again.
Any mounts that show up next boot regardless today or in hundred years are fake mounts due to still showing entries in the /mnt folder kept in the save-file.2fs .

@mini-jaguar : Look at my code again, I had forgotten to check if frugal loopdevices are mounted, since I run mostly full installed . I assume that you got these troubles because the code should have unmounted your save-file.2fs . Sorry for inconveniences.
Back to top
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 1 of 1 [12 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » House Training » Users ( For the regulars )
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0911s ][ Queries: 12 (0.0037s) ][ GZIP on ]