Springen naar inhoud


Foto

[7.1-release] + mdev (automount) + self defined mountpoint !


  • Please log in to reply
Er zijn 9 reacties in dit onderwerp

#1 Pike_Bishop

  • Senior Member
  • 1119 berichten

+72
Good

Geplaatst op 21 juli 2019 - 21:05

Hi,

 

i have several volumes (harddiscs and/or usb-sticks) on my box, but one of my external harddiscs i need only to backup movies, so that this harddisc

isn't always connected on my box.

in this case it's a good idea to mount this harddisc with mdev in always the same mountpoint.

for those who want to do the same that is possible if you edit the script on the box in /etc/mdev with name mdev-mount.sh

 

you need only a function as following in the mdev-mount.sh  (i named it my_uuid_mount);

my_uuid_mount() {
FIXED_MOUNTPOINT=/media/usb4 
EXT_USB_HDD_UUID=9a9ceb61-8626-4851-b7b8-5813fc8kb2af
	if [ "$EXT_USB_HDD_UUID" = "$UUID" ] ; then
		MOUNTPOINT=$FIXED_MOUNTPOINT
	fi
}

certainly you must edit the following variables from this function;

 

FIXED_MOUNTPOINT=/media/usb4
EXT_USB_HDD_UUID=9a9ceb61-8626-4851-b7b8-5813fc8kb2af

 

and set your own mountpoint and your uuid ( bold marked ) for your media

(you find out what is the uuid for your media with the command blkid in telnet or ssh if your media is connected on the box and on).

in my case the external harddisc will be mountet to /media/usb4 as you can see.

 

this function you must write on the right place in the mdev-mount.sh in fact under the function get_blkid, so that it looks as following;

get_blkid() {
	# run the result of blkid as a shell command
	eval `blkid /dev/${MDEV} | grep ${MDEV} | cut -d ':' -f 2`
	log ">" "device TYPE = $TYPE"
	log ">" "device UUID = $UUID"
	log ">" "device LABEL = $LABEL"
}

my_uuid_mount() {
FIXED_MOUNTPOINT=/media/usb4
EXT_USB_HDD_UUID=9a9ceb61-8626-4851-b7b8-5813fc8kb2af
    if [ "$EXT_USB_HDD_UUID" = "$UUID" ] ; then
        MOUNTPOINT=$FIXED_MOUNTPOINT
    fi
}

and now you must nor write the name of the new function (in this case my_uuid_mount) in the mdev-mount.sh on the right place too.

in fact at the following section from the original mdev-mount.sh script;

# Use mkdir as 'atomic' action, failure means someone beat us to the punch
			if ! mkdir "${MOUNTPOINT}" ; then
				MOUNTPOINT="/media/$MDEV"
				log ">" "alternative MOUNTPOINT = $MOUNTPOINT"
				mkdir -p "${MOUNTPOINT}"
			fi

after edit it must looks as following;

# Use mkdir as 'atomic' action, failure means someone beat us to the punch
			if ! mkdir "${MOUNTPOINT}" ; then
				MOUNTPOINT="/media/$MDEV"
				my_uuid_mount
				log ">" "alternative MOUNTPOINT = $MOUNTPOINT"
				mkdir -p "${MOUNTPOINT}"
			fi

basically now it's ready, but if you want to disconnect the media after usage you need also a own script to umount it before disconnect.

this script i named external_backup_hdd_mount.sh and you must copy it on your box to /usr/script and also it must be set executable

with following command in telnet or ssh;

chmod 755 /usr/script/external_backup_hdd_mount.sh

it looks as following;

#!/bin/sh

EXTERNAL_BACKUP_HDD_MOUNTPOINT="/media/usb4"
EXTERNAL_BACKUP_HDD_UUID="UUID=9a9ceb61-8626-4851-b7b8-5813fc8kb2af"
TMP=/tmp
LOGFILE=$TMP/external_backup_hdd_mount.log


# Logfile loeschen
rm -f $LOGFILE


# Logfile erstellen
touch $LOGFILE


if [ ! -d $EXTERNAL_BACKUP_HDD_MOUNTPOINT ] ; then
	mkdir $EXTERNAL_BACKUP_HDD_MOUNTPOINT

		if [ "$?" = "0" ] ; then
			echo -e "Verzeichnis\n$EXTERNAL_BACKUP_HDD_MOUNTPOINT wurde erstellt." | tee -a $LOGFILE
		else
			echo -e "ABBRUCH !\nVerzeichnis\n$EXTERNAL_BACKUP_HDD_MOUNTPOINT erstellen fehlgeschlagen." | tee -a $LOGFILE && exit 1
		fi
fi


EXTERNAL_BACKUP_HDD_MOUNT="$(/bin/mount | grep "$EXTERNAL_BACKUP_HDD_MOUNTPOINT" | awk '{print $3}')" > /dev/null 2>&1

case $EXTERNAL_BACKUP_HDD_MOUNT in
	$EXTERNAL_BACKUP_HDD_MOUNTPOINT)

		DEVICE="$(/bin/mount | grep "$EXTERNAL_BACKUP_HDD_MOUNTPOINT" | awk '{print $1}')" > /dev/null 2>&1
		MOUNT_CNT="$(/bin/mount | grep -c ${DEVICE})" > /dev/null 2>&1

			while [ "$MOUNT_CNT" -gt "0" ]
			do
				umount $DEVICE

					if [ "$?" = "0" ] ; then
						MOUNT_CNT="$(/bin/mount | grep -c ${DEVICE})" > /dev/null 2>&1

							if [ "$MOUNT_CNT" -gt "0" ] ; then
								continue
							elif [ "$MOUNT_CNT" -eq "0" ] ; then
								echo "Platte wurde umountet." | tee -a $LOGFILE && break
							fi

					else
						echo -e "ABBRUCH !\nPlatte umounten fehlgeschlagen." | tee -a $LOGFILE && exit 1
					fi

			done
	;;

	"")
		mount $EXTERNAL_BACKUP_HDD_UUID $EXTERNAL_BACKUP_HDD_MOUNTPOINT

			if [ "$?" = "0" ] ; then
				echo "Platte wurde gemountet." | tee -a $LOGFILE
			else
				echo -e "ABBRUCH !\nPlatte mounten fehlgeschlagen." | tee -a $LOGFILE && exit 1
			fi
	;;
esac

exit

it's important that you use this script with hotkey, so put it on a button of your rc with hotkey, or you can also use ppanel for it.

and ditto as above at the new function with name my_uuid_mount you must edit the variables for your own mountpoint and uuid, in fact the following two variables

from the script with name external_backup_hdd_mount.sh;

 

EXTERNAL_BACKUP_HDD_MOUNTPOINT="/media/usb4"
EXTERNAL_BACKUP_HDD_UUID="UUID=9a9ceb61-8626-4851-b7b8-5813fc8kb2af"

 

the mountpoint and the uuid must be the same as in the new function with name my_uuid_mount

 

with the script named external_backup_hdd_mount.sh you can then if you connect your media and it was mounted with mdev (automounter)

automatically in your desired mountpoint, umount your media before disconnected, or if you change your mind mount it again.

 

 

but please note, if you update your image (box) maybe it comes also a update for mdev and then it's good possible that your

edited mdev-mount.sh script in /etc/mdev will overridden.

 

 

at last, with the mdev-mount.sh in /etc/mdev is something more possible, as example, if you have also a internal harddisc you can

set a link automatically from the external harddisc in the moviedir from the internal harddisc too after mount the external harddisc.

 

 

regards

Pike


Receiver: VU Ultimo 4K, Octagon SF8008 4K, Gigablue Quad 4K

Image: OpenPLI-8.3


Re: [7.1-release] + mdev (automount) + self defined mountpoint ! #2 Pike_Bishop

  • Senior Member
  • 1119 berichten

+72
Good

Geplaatst op 21 juli 2019 - 22:07

and here is nor a mount check script, it's named show_mounts.sh.

with it you can see which device is in which mountpoint mountet, put it on the box to /usr/script, make it executable with command;

chmod 755 /usr/script/show_mounts.sh

and put it on a button with hotkey, it looks as following;

#!/bin/sh

TMP=/tmp
READFILE=$TMP/mounts.txt
DEVICES=/dev/sd*

rm -f $READFILE

grep "^device /dev/" /proc/self/mountstats >> $READFILE &&
MEDIUM="$(cat $READFILE | grep "$DEVICES" | awk '{print $2," -> ",$5," -> ",$8}')"

echo -e "DEVICE          MOUNTP.          FILESYS.\n"  
echo "$MEDIUM" | while read i
do
    echo "$i"
done

echo ""

exit

edit or write a script only with a linux compatible editor as notepad++

 

regards

Pike


Veranderd door Pike_Bishop, 21 juli 2019 - 22:09

Receiver: VU Ultimo 4K, Octagon SF8008 4K, Gigablue Quad 4K

Image: OpenPLI-8.3


Re: [7.1-release] + mdev (automount) + self defined mountpoint ! #3 WanWizard

  • PLi® Core member
  • 68309 berichten

+1719
Excellent

Geplaatst op 21 juli 2019 - 22:54

Instead of all this, you can also label your disk "usb4", and the rest will happen automatically.


Currently in use: VU+ Duo 4K (2xFBC S2), VU+ Solo 4K (1xFBC S2), uClan Usytm 4K Pro (S2+T2), Octagon SF8008 (S2+T2), Zgemma H9.2H (S2+T2)

Due to my bad health, I will not be very active at times and may be slow to respond. I will not read the forum or PM on a regular basis.

Many answers to your question can be found in our new and improved wiki.


Re: [7.1-release] + mdev (automount) + self defined mountpoint ! #4 Pike_Bishop

  • Senior Member
  • 1119 berichten

+72
Good

Geplaatst op 21 juli 2019 - 23:07

yes that's right


Receiver: VU Ultimo 4K, Octagon SF8008 4K, Gigablue Quad 4K

Image: OpenPLI-8.3


Re: [7.1-release] + mdev (automount) + self defined mountpoint ! #5 Pike_Bishop

  • Senior Member
  • 1119 berichten

+72
Good

Geplaatst op 22 juli 2019 - 18:15

but if you want disconnect the harddisc (media) during operation you must first umount it, and for that you need at least the second script with name external_backup_hdd_mount.sh

from post #1

 

for me it's ok as it is because i also use mdev to make a symlink.

 

but you're right i can make label and so it is't necessary to edit the mdev script, and the link i can make automatically with a other script and a cronjob

,and if i disconnect my harddisc the same cronjob script removes the dead link, because i didn't want to have dead links in the movielist - thisi is maybe a better solution as i have at this moment :)

 

but as i above wrote the second script for umount i need for this solution too.

 

 

regards

Pike


Receiver: VU Ultimo 4K, Octagon SF8008 4K, Gigablue Quad 4K

Image: OpenPLI-8.3


Re: [7.1-release] + mdev (automount) + self defined mountpoint ! #6 WanWizard

  • PLi® Core member
  • 68309 berichten

+1719
Excellent

Geplaatst op 22 juli 2019 - 18:22

The option to unmount a mounted device from the GUI is on the todo list, it is indeed missing functionality at the moment.


Currently in use: VU+ Duo 4K (2xFBC S2), VU+ Solo 4K (1xFBC S2), uClan Usytm 4K Pro (S2+T2), Octagon SF8008 (S2+T2), Zgemma H9.2H (S2+T2)

Due to my bad health, I will not be very active at times and may be slow to respond. I will not read the forum or PM on a regular basis.

Many answers to your question can be found in our new and improved wiki.


Re: [7.1-release] + mdev (automount) + self defined mountpoint ! #7 Pike_Bishop

  • Senior Member
  • 1119 berichten

+72
Good

Geplaatst op 22 juli 2019 - 19:14

that sounds good !


Receiver: VU Ultimo 4K, Octagon SF8008 4K, Gigablue Quad 4K

Image: OpenPLI-8.3


Re: [7.1-release] + mdev (automount) + self defined mountpoint ! #8 Pike_Bishop

  • Senior Member
  • 1119 berichten

+72
Good

Geplaatst op 22 juli 2019 - 22:53

Hi,

 

i have testet it now with label, it's not reliable here on my vu ultimo 4k, one time it works, and another time it didn't work - blkid says;

/dev/sde1: LABEL="backup1" UUID="9a9ceb61-8626-4851-b7b8-5813fc8kb2af" TYPE="ext4"

and mount says then;

/dev/sde1 on /media/sde1 type ext4 (rw,noatime,data=ordered)

when it didn't work.

when it works mount says;

/dev/sde1 on /media/backup1 type ext4 (rw,relatime,data=ordered)

maybe it's a problem because i use openmultiboot at the moment, but i don't know.

i go return to my mdev solution, this works always here.

 

 

regards

Pike


Receiver: VU Ultimo 4K, Octagon SF8008 4K, Gigablue Quad 4K

Image: OpenPLI-8.3


Re: [7.1-release] + mdev (automount) + self defined mountpoint ! #9 WanWizard

  • PLi® Core member
  • 68309 berichten

+1719
Excellent

Geplaatst op 22 juli 2019 - 23:14

Then our mdev-mount doesn't run, for one reason or other. It's been working here for years (and I do several reboots a day).


Currently in use: VU+ Duo 4K (2xFBC S2), VU+ Solo 4K (1xFBC S2), uClan Usytm 4K Pro (S2+T2), Octagon SF8008 (S2+T2), Zgemma H9.2H (S2+T2)

Due to my bad health, I will not be very active at times and may be slow to respond. I will not read the forum or PM on a regular basis.

Many answers to your question can be found in our new and improved wiki.


Re: [7.1-release] + mdev (automount) + self defined mountpoint ! #10 Pike_Bishop

  • Senior Member
  • 1119 berichten

+72
Good

Geplaatst op 22 juli 2019 - 23:33

Hi,

 

i believe you :) , and as i said i think the problem comes from openmultiboot (i know about mount problems with openmultiboot)

, anytime i will test with label without openmultiboot.

 

 

regards

Pike


Receiver: VU Ultimo 4K, Octagon SF8008 4K, Gigablue Quad 4K

Image: OpenPLI-8.3



0 gebruiker(s) lezen dit onderwerp

0 leden, 0 bezoekers, 0 anonieme gebruikers