To force Dolphin to mount a partition in /mnt, we can cheat with a fake /etc/fstab.
If the partition is written as mounted in /mnt in the file fstab, Dolphin mounts the partition at this place.
Dolphin in the lastest KDE edition of the Porteus distribution mount the partitions in /mnt
Here is the script udev-fstab-update used by Porteus (in /sbin)
Code: Select all
#!/bin/sh
# Handle /etc/fstab entries and /mnt directories for removable devices
# so they are mounted under /mnt directory.
# This script is called by /etc/udev/rules.d/10-porteus-fstab-update.rules
# Inspired by 'udev-fstab-update' from Slax 6.1.2 but rewritten from scratch
# for Porteus by fanthom <fanthom@porteus.org> and Ahau <ahau@porteus.org>
# Variables initialized by the udev environment:
# $ACTION (add, change, remove)
# $DEVNAME (device name including path)
# $ID_FS_TYPE (filesystem type)
# Exit if called during boot:
#ps a | grep -q 'bash /etc/rc.d/rc.S' && exit
# Exit if 'nohd' cheatcode is used:
egrep -qo " nohd( |\$)" /etc/bootcmd.cfg && exit
# Our variables:
FSTAB=/etc/fstab
DEVICE=`echo $DEVNAME | sed s_^/dev/__`
MNTPT=/mnt/$DEVICE
INITRD_PATH=/mnt/live
[ `/bin/ls -1 ${INITRD_PATH}/mnt | grep $DEVICE` ] && MNTPT=${INITRD_PATH}${MNTPT}
FS=$ID_FS_TYPE
[ "$FS" ] || FS=`/sbin/blkid $DEVNAME | egrep -o ' TYPE=[^ ]+' | cut -d'"' -f2`
cdtest=`echo $DEVICE | grep ^sr`
[ "$cdtest" ] && GVICON=',comment=x-gvfs-icon=media-optical-symbolic'
# Make sure the part of a script after 'mutex_lock' call is atomic,
# that means the 'locked' part of the script can never be execuetd
# from several processes at the same time, in parallel.
# Every script waits until it gathers the lock.
# The lock directory is saved in /dev instead of /tmp, because /tmp may be
# readonly at the time when the lock is needed (eg. when udev is starting)
# $1 = name of the lock
#
mutex_lock()
{
while ! mkdir "/dev/ll-mutex-lock-$1" 2>/dev/null; do
usleep 100000;
done
}
# Unlock the lock so another waiting process can reusse it and continue
# $1 = name of the lock
#
mutex_unlock()
{
rmdir "/dev/ll-mutex-lock-$1" 2>/dev/null
}
fstab_add() {
# Create the mount point:
test ! -d $MNTPT && mkdir $MNTPT
# Create new entry as per the 'mopt=' or 'nmopt=' or 'rmopt=' cheatcode - or Porteus defaults:
MOPT=`egrep -o " mopt=[^ ]+" /etc/bootcmd.cfg | cut -d= -f2`
NMOPT=`egrep -o " nmopt=[^ ]+" /etc/bootcmd.cfg | cut -d= -f2`
RMOPT=`egrep -o " rmopt=[^ ]+" /etc/bootcmd.cfg | cut -d= -f2`
[ $MOPT ] || MOPT="users,noatime,nodiratime,suid,dev,exec,async"
[ $NMOPT ] || NMOPT="noatime,nodiratime,group,nodev,exec,async"
[ $RMOPT ] || RMOPT="noatime,nodiratime,suid,dev,exec,async,nofail"
if `test -e /lib/udev/rules.d/80-udisks2.rules`; then MOPT="$MOPT,comment=x-gvfs-show$GVICON"; NMOPT="$NMOPT,comment=x-gvfs-show$GVICON"; fi
if [ "$FS" = vfat ]; then sed -i '\?^'$DEVNAME'?d' $FSTAB; echo "$DEVNAME $MNTPT vfat $MOPT,umask=0,check=s,utf8 0 0" >> $FSTAB
elif [ "$FS" = ntfs ]; then sed -i '\?^'$DEVNAME'?d' $FSTAB; echo "$DEVNAME $MNTPT ntfs-3g $NMOPT 0 0" >> $FSTAB; chmod 777 $MNTPT
elif [ "$FS" = linux_raid_member ]; then sed -i '\?^'$DEVNAME'?d' $FSTAB; echo "$DEVNAME $MNTPT $FS $RMOPT 0 0" >> $FSTAB; chmod 777 $MNTPT
else sed -i '\?^'$DEVNAME'?d' $FSTAB; echo "$DEVNAME $MNTPT $FS $MOPT 0 0" >> $FSTAB
fi
}
fstab_change() {
# Change entry as per the 'mopt=' or 'nmopt=' cheatcode or porteus defaults:
MOPT=`egrep -o " mopt=[^ ]+" /etc/bootcmd.cfg | cut -d= -f2`
NMOPT=`egrep -o " nmopt=[^ ]+" /etc/bootcmd.cfg | cut -d= -f2`
[ $MOPT ] || MOPT="users,noatime,nodiratime,suid,dev,exec,async"
[ $NMOPT ] || NMOPT="noatime,nodiratime,group,nodev,exec,async"
if `test -e /lib/udev/rules.d/80-udisks2.rules`; then MOPT="$MOPT,comment=x-gvfs-show$GVICON"; NMOPT="$NMOPT,comment=x-gvfs-show$GVICON"; fi
if [ "$FS" = vfat ]; then sed -i "s_^$DEVNAME.*_$DEVNAME $MNTPT vfat $MOPT,umask=0,check=s,utf8 0 0_" $FSTAB; mkdir -p $MNTPT
elif [ "$FS" = ntfs ]; then sed -i "s_^$DEVNAME.*_$DEVNAME $MNTPT ntfs-3g $NMOPT 0 0_" $FSTAB; mkdir -p $MNTPT; chmod 777 $MNTPT
elif [ "$FS" = linux_raid_member ]; then sed -i "s_^$DEVNAME.*_$DEVNAME $MNTPT $FS $RMOPT 0 0_" $FSTAB; mkdir -p $MNTPT; chmod 777 $MNTPT
elif [ "$FS" = swap ]; then sed -i "s_^$DEVNAME.*_$DEVNAME none swap sw,pri=1 0 0_" $FSTAB
else sed -i "s_^$DEVNAME.*_$DEVNAME $MNTPT $FS $MOPT 0 0_" $FSTAB; mkdir -p $MNTPT
fi
}
mutex_lock udev-fstab-update
if [ "$ACTION" = add ]; then
# Add new entry:
[ "$FS" ] && fstab_add
elif [ "$ACTION" = change ]; then
if grep -w "^/dev/$DEVICE" $FSTAB; then
# Change existing entry:
[ "$FS" ] && fstab_change
else
# Add new entry:
[ "$FS" ] && fstab_add
fi
elif [ "$ACTION" = remove ]; then
# Delete fstab entry:
sed -i "/$DEVICE /d" $FSTAB
# Remove the mount point:
rmdir $MNTPT 2>/dev/null
fi
mutex_unlock udev-fstab-update
I have removed the parts with "cheatcodes" that are Porteus boot options and created too from this script another script (makefakestab) that makes a fake fstab with all the partitions present at startup.
When a drive is plugged (or unplugged) the script udev-fstab-update is called by a file located in /etc/udev/rules.d
I made a pet file with these 3 files :
As one of the 3 files is in /root/Startup, a reboot is needed before test the pet
EDIT : pet removed