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

How to do things, solutions, recipes, tutorials
Post Reply
Message
Author
jafadmin
Posts: 1249
Joined: Thu 19 Mar 2009, 15:10

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

#1 Post 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!

s243a
Posts: 2580
Joined: Tue 02 Sep 2014, 04:48
Contact:

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

#2 Post 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!
Find me on [url=https://www.minds.com/ns_tidder]minds[/url] and on [url=https://www.pearltrees.com/s243a/puppy-linux/id12399810]pearltrees[/url].

enrique
Posts: 595
Joined: Sun 10 Nov 2019, 00:10
Location: Planet Earth

#3 Post 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.

jafadmin
Posts: 1249
Joined: Thu 19 Mar 2009, 15:10

#4 Post 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.

User avatar
elephante_of_randomness
Posts: 5
Joined: Wed 25 Mar 2020, 02:18
Location: GTA, ONTARIO, CANADA

*snock

#5 Post by elephante_of_randomness »

i need to look into this. i've already encountered the issue. and i prefer to keep a clean system.

User avatar
elephante_of_randomness
Posts: 5
Joined: Wed 25 Mar 2020, 02:18
Location: GTA, ONTARIO, CANADA

#etc

#6 Post 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

User avatar
Keef
Posts: 987
Joined: Thu 20 Dec 2007, 22:12
Location: Staffordshire

#7 Post 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.

Post Reply