Script mounts any ext* or vfat partition on HD

Using applications, configuring, problems
Post Reply
Message
Author
musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

Script mounts any ext* or vfat partition on HD

#1 Post by musher0 »

Hello all.

(Edited, June 20, 2018)

Often, you just want to mount a partition in a jiffy without having to
call in the PMount regiment.

So here you go:
This script will mount or unmount any ext? or vfat partition on your hard
drive or thumb drive by right-clicking on its name in the /mnt ROX-Filer
panel.
(Note: do not use on ram-drives created via < modprobe zram >.)

Unzip this script in /root/my-applications/bin or /opt/local/bin. Make it
executable. Once that is done, you click on it once. This will create a
symlink at the proper place in ROX's "OpenWith" structure.

After that, you can use it normally. Just right-click on a partition in the
/mnt folder: it will be in the context menu under the name
"monte-1-dsq.sh".

Click on this context link, and the partition will:
  • * mount if unmounted -- and show the partition in a ROX window
    * unmount if mounted -- in this case ROX will ask you if you want to
    unmount it when you close the ROX window;
    * if the partition does not exist, it will tell you.
BFN.
~~~~~~~~~~~~~~~~~~~~

Code: Select all

Please see more recent version below.
Attachments
sdd8_says_it_does_not_exist_2016-01-22(2).jpg
(33.63 KiB) Downloaded 308 times
Last edited by musher0 on Wed 20 Jun 2018, 08:05, edited 3 times in total.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#2 Post by Karl Godt »

What if
Type="`probepart | grep $Dsq | cut -d'|' -f2`"
get "none" or "swap" ?
«Give me GUI or Death» -- I give you [[Xx]term[inal]] [[Cc]on[s][ole]] .
Macpup user since 2010 on full installations.
People who want problems with Puppy boot frugal :P

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#3 Post by musher0 »

Hi Karl.

Why would one want to mount a swap or non-existing partition?

BFN.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#4 Post by musher0 »

Hello all.

Here is a more recent version. Any questions, please ask below.

Code: Select all

#!/bin/sh
# /opt/local/bin/monte-1-dsq.sh
# Objectif / Goal:
# Monter ou démonter UNE partition. / Mount or unmount ONE partition.
# Usage :
# Appelé par clic droit sur un nom de partition affiché dans un panneau de ROX-Filer. /
# Called by right click on a partition name displayed in a ROX-Filer panel.
# Requis : / Required: /usr/local/lib/X11/mini-icons/mini-hdisk.xpm
## (c) Christian L'Écuyer, Gatineau (Qc), Canada, 21-22 janv. et 13 oct. 2016. GPL3.
##  (Alias "musher0" [forum PuppyLinux]).
#### set -xe
if [ -L /root/.config/rox.sourceforge.net/OpenWith/.inode_mount-point/monte-1-dsq.sh ];then
	Dsq="${@#/*/}"
	if [ "`fdisk -l /dev/$Dsq`" != "" ];then # Partition / existe ? / exists?
		if [ "`mount | grep $Dsq`" = "" ];then # Si non montée, on la monte. # Mount unmounted.
			Type="`probepart | grep $Dsq | cut -d'|' -f2`"
			mount -t $Type /dev/$Dsq /mnt/$Dsq
		else
			umount /mnt/$Dsq # Si montée, on la démonte. # Unmount mounted.
		fi
		rox /mnt/$Dsq # On l'affiche. # We show it.
	else
		[ "${LANG:0:2}" = "fr" ] && TXT="JE N'EXISTE PAS ! " || TXT="I DO NOT EXIST! "
		yaf-splash -bg_gradient true -fontsize large -bg black -fg red -text "$TXT >;->" -icon /usr/local/lib/X11/mini-icons/mini-hdisk.xpm -icon_width 48 -timeout 7
		# Partition / tells you if it exists! / vous dit si elle existe !
	fi
else
	ln -s /opt/local/bin/monte-1-dsq.sh /root/.config/rox.sourceforge.net/OpenWith/.inode_mount-point/
# Makes sure there is a symlink there to use. Means that the first time it is used,
# the script may appear to do nothing. / Assure qu'il y a un lien symbolique à utiliser
# à cet endroit. Signifie que la première fois, il peut sembler ne rien se passer.
fi # set +xe
Enjoy.
Attachments
monte-1-dsq.sh.zip
(1.11 KiB) Downloaded 95 times
Last edited by musher0 on Wed 20 Jun 2018, 07:27, edited 1 time in total.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#5 Post by musher0 »

... Continued from thread "xfe-1.42 FileManager", at
http://www.murga-linux.com/puppy/viewto ... 342#996342
backi wrote:Hi Musher !
Thanks for your Effort .......
But me i am a bit confused ......how to handle your script ......does it only
work in Puppy Linux ...... me executed it in Terminal on Bionic Dog .....but
have no Plan what to do further .
Hi backi.

In answer to your question:

1) -=> Untested on any of the "Dogs". <=-

2) It does not work from a terminal, it is designed to work from the ROX
right-click contextual menu for drives and such ("mount-points").

As an example --
Let's say this is the first time you are using this script. Also, let's say that
your partition sdc7 is unmounted and you want to mount it.

So you right-click on partition sdc7. The context menu is shown.
Click on the "Customize" item. A little ROX-Filer opens. Click "ok".

Now open directory /opt/local/bin OR directory ~/my-applications/bin (i.e.
wherever you stored this script) with ROX.

Now make a link from monte-1-dsq.sh from that directory to the "mount-
points" directory.

Hopefully the illustration explains it enough.

Once that is done, right-click on partition sdc7 and click on item
"monte-1-disk" in the list: this will mount partition sdc7 and a ROX-Filer
window of it will open.

A second example:
You have finished work on /mnt/sdc7 and you wish to unmount it.
Right-click on /mnt/sdc7, and click the "monte-1-disk.sh" item again.
/mnt/sdc7 will be unmounted.

Please note: you have to refresh the ROX-Filer window for /mnt for
the green button (the sign that a partition is mounted) to appear.
Same in reverse when you unmount a partition with this script, for the
green button to disappear.

If the above is not clear, please ask for further explanation.

IHTH.
Attachments
Explanation.jpg
(171.5 KiB) Downloaded 171 times
Last edited by musher0 on Tue 19 Jun 2018, 14:52, edited 1 time in total.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

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

#6 Post by jafadmin »

Why would I want to mount something that is already mounted?

TTFN

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#7 Post by musher0 »

jafadmin wrote:Why would I want to mount something that is already mounted?

TTFN
Hi jafadmin.

Obvious. I do not know why you are stating the obvious. If your remark has
an "overtone/undertone" of any kind, I have this to say:

"You do not like this script? Nobody is forcing you to use it."

BFN.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

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

#8 Post by jafadmin »

musher0 wrote: If your remark has an "overtone/undertone" of any kind ..
All my remarks are certified tone-free by the official tone certifying workgroup. So no worries there. 8)

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#9 Post by musher0 »

Hello all.

I have edited my posts above. May I suggest that you re-read them. Hopefully,
they now contain clearer explanations about what this script does.

Sorry for any inconvenience. TWYL.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

Post Reply