Page 1 of 1

I bet you have a bunch of stale mount points in /mnt, right?

Posted: Sat 25 Jan 2020, 23:05
by jafadmin
Did you ever notice that sometimes you create work in /mnt/sd?1 and it vanishes for no reason? Wanna know why?
Stale mount points. As far as Linux is concerned they are still a legit file directory even if no devices are mounted on them. What to do? Simple. Get rid of stale mount points and you won't put stuff there.

I use a link to this tasty snock* in my Startup directory to clear the essential computing surfaces when I first boot:

delete-stale-mnts:

Code: Select all

#! /bin/bash
#
# Remove stale mount points in '/mnt' - jafadmin
#
RAW=$(ls -d /mnt/*)

for Line in $RAW
do
	if [ ! -z "$(mountpoint $Line | grep not)" ]; then rm -R $Line; fi
done
*I am NOT responsible if this wipes out your crochet videos or homework! Use this at your own risk!

Re: I bet you have a bunch of stale mount points in /mnt, right?

Posted: Sun 26 Jan 2020, 01:26
by s243a
jafadmin wrote: *I am NOT responsible if this wipes out your crochet videos or homework! Use this at your own risk!
This is actually a good warning. I once deleted a mount point that looked empty when viewed from the file manager but wasn't and actually pointed to a good chunk of my system!

Posted: Sun 26 Jan 2020, 03:12
by enrique
Interesting concept. If the folder does not exist we can not save in wrong place. Thanks

;) This reminds me that I have to repair my BusterDog. I did put extra libraries. fredx181 did in fact explained it to me how not to do it. Point is that I have duplicate libraries in charge of my volume mounting. One mount on /media the other on /mnt. I know been lazy to build my self another Busterdog.

Posted: Sun 26 Jan 2020, 07:24
by jafadmin
The script will not remove active mounts.

Puppy is the only Linux I have seen so far that doesn't automatically clean up '/mnt' on shutdown.

*snock

Posted: Wed 25 Mar 2020, 05:04
by elephante_of_randomness
i need to look into this. i've already encountered the issue. and i prefer to keep a clean system.

#etc

Posted: Wed 25 Mar 2020, 05:06
by elephante_of_randomness
/*
what language?
*/


#! /bin/bash
#
# Remove stale mount points in '/mnt' - jafadmin
#
RAW=$(ls -d /mnt/*)

for Line in $RAW
do
if [ ! -z "$(mountpoint $Line | grep not)" ]; then rm -R $Line; fi
dones

Posted: Wed 25 Mar 2020, 18:12
by Keef
That would be Bash, that would. It's a shell script, just a text file to run in a terminal.
Open a terminal where ever the file is, then type:

Code: Select all

./whatever-you-have-named-the-file 
...then watch your crochet videos disappear.