How to unmount .iso files if I forget to?
-
- Posts: 597
- Joined: Thu 13 Nov 2008, 13:45
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.
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.
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.
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.
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.
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.
-
- Posts: 597
- Joined: Thu 13 Nov 2008, 13:45
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.
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.
Hi.
This should do what you want.
RSH
This should do what you want.
Code: Select all
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
[b][url=http://lazy-puppy.weebly.com]LazY Puppy Home
The new LazY Puppy Information Centre[/url][/b]
The new LazY Puppy Information Centre[/url][/b]
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.
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: Select all
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
[b][url=http://lazy-puppy.weebly.com]LazY Puppy Home
The new LazY Puppy Information Centre[/url][/b]
The new LazY Puppy Information Centre[/url][/b]
Code: Select all
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
* 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, 06:12, edited 1 time in total.
-
- Posts: 597
- Joined: Thu 13 Nov 2008, 13:45
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.
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.
Puppy code in /usr/local/bin/drive_all and /usr/sbin/filemnt has lines
to close the rox filer window - if rox is the file manager you use.
But that would need to be like that :
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 .
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 :
#here now main part of script .
Code: Select all
rox -D "$mountpoint"
But that would need to be like that :
Code: Select all
[ "$DISPLAY" ] && rox -D "$mountpoint"
sleep 2s
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 .
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.RSH wrote:sleep .2 # ---> works well over here
rm -r $F
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: Select all
sync
sleep 3
-
- Posts: 597
- Joined: Thu 13 Nov 2008, 13:45
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.
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.
I have a very poor memory. So have patience now with an old guy.
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?
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
not an ideal solution though
Puppy has confusing code : /usr/sbin/filemnt is the mime-type starter application if clicked on some loop mountable files : .iso, .sfs, .2fs .nooby wrote:I have a very poor memory. So have patience now with an old guy.
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?
/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: Select all
rox -D $MntPt #BK
umount $MntPt
Err=$?
rmdir $MntPt
IMPORTANT : If you use the commands
Code: Select all
umount /mnt/+crazy+long+path+here+puppy_version.iso
Code: Select all
umount-FULL /mnt/+crazy+long+path+here+puppy_version.iso
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.