Alternative way to mount a series of partitions

How to do things, solutions, recipes, tutorials
Post Reply
Message
Author
musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

Alternative way to mount a series of partitions

#1 Post by musher0 »

Hello all.

Here is an alternative way I discovered to mount a series of partitions with no manual
intervention, in one fell swoop.

This can come in handy if
-- you are booting from DVD;

and / or
-- you have quite a few partitions to mount;

and / or
-- your drives are not always recognized in the same order at boot;
---- this one can be a time waster, since you think your partitions are mounted and
they're not, or they want to be mounted on other mount points; and you have to
(re)do the mounting manually;

and / or
-- you do not wish to use PMount times the number of partitions you have.
---- To be clear, PMount is an excellent utility; if you're happy with how PMount works,
by all means continue using it.
---- This script is not a criticism of PMount. It only does things differently.

What this script does:
-- it scans the partitions you have using probepart;
-- it creates mount points if need be;
-- it handles vfat, ext* and fdfs (NOT ntfs at this time, sorry).

A pet is attached. It contains the following script plus a link to it in /root/Startup.
So your desired partitions will be mounted automatically at boot.

The script is as follows --

Code: Select all

#!/bin/sh
# /root/my-applications/bin/a1g8.1.sh
# with symlink at /root/Startup/a1g8.1.sh
#
# Purpose: Mount all vfat, ext*, and fdfs partitions by deduction
# -------- using BK's probepart and a /root/Startup script.
#
# Caution: probably only works on PuppyLinux, since probepart
# -------- is not present in all Linuxes.
#
# musher0, May 3rd, 2020. GPL2.
####
for type in vfat ext2 ext3 ext4 fdfs;do
# You may remove the types you do not wish to mount.
# E.g. if you wish to mount only the ext* filesystems,
# remove "vfat" and "fdfs" from the above line.
	probepart | grep $type | cut -d"|" -f 1 | cut -d"/" -f3 > /root/my-applications/list

	if [ "`wc -l < /root/my-applications/list`" -gt "0" ];then
	# This part kicks in only if file /root/my-applications/list
	# has at least one line in it.
		cd /mnt
		while read line;do
			[ -d /mnt/$line ] || mkdir /mnt/$line
			# This line creates mounting points as needed.
			sleep 0.2s # Doesn't work if process too fast.
			# So we slow it down a bit.
			mount -t $type /dev/$line /mnt/$line
			# Actual mounting of desired partitions.
		done < /root/my-applications/list
		cd - # Back to the directory we came from.
	fi
done
It works fine on jrb's 32-bit upupbb-light. It should work fine on all 32-bit and 64-bit
Puppies as well since this is a bash script.

Any constructive feedback or bug report welcome. But please read the comments
in the above script first, your answer may be in them.

IHTH.
BFN.
Attachments
a1g8.1.pet
Alternative way to mount a series of partitions using BarryK's probepart.
(1020 Bytes) Downloaded 140 times
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

Post Reply