PDA

View Full Version : Auto mounting Hard drive



jdtommy
04-13-2004, 06:15 PM
I add a peace of script to /etc/rcS.d/S00knoppix-autoconfig to search for a specific file on the rott of a partition. What is does is it mounts all possible partitions and then searches root for a file. When the file is found it will mount that partition as /mnt/hda1. It works, but there is 2 problems

1-after it goes through the process of searching the partitions it re-runs the auto config process again where it will re-search for devices and usb devices and configure them again.

2-I get an error every time it tries to mount a non existent partition. I have it forwarding the messages to /dev/null, and it does not get the messages when I test run just my code alone. But when it is run with the boot process it gets this message about 30 times:


modprobe: modprobe: Can't locate module block-major-34


here is the code I added:


# Locate Config File CONFPART.F
findconf(){
LOC=0
# search all partitions for a file in the root directory
for i in /mnt/tmp ; do
# See if it's already mounted
[ -f "$i/$1" ] && { echo "$i/$1"; return 0; }
if [ -d "$i" ] && mount -r "$i" 2>/dev/null; then
[ -f "$i/$1" ] && LOC=0
umount -l "$i" 2>/dev/null
[ -n "$LOC" ] && { echo "$LOC"; return 0; }
fi
done

}

searchdrv(){
DRIVES="/dev/[h-s]d[a-z][0-9]"
CONFDRV=""
LOC=0

for drv in $DRIVES ; do
if (mount $drv /mnt/tmp 2>/dev/null) ; then
LOC="$(findconf CONFPART.F)"
if test "$LOC"; then
CONFDRV=$drv
return 0
fi
umount /mnt/tmp
fi
done
return 0
}
.
.
.
.
.
mkdir /mnt/tmp
mkdir /mnt/hda1
searchdrv
echo Found CONFPART.F file in $CONFDRV
mount -rw $CONFDRV /mnt/hda1

let me know if anyone has an idea

jdtommy
04-16-2004, 04:53 PM
I have been revising my code so that it is cleaner and runs smother buy I still have the same problems :evil: :evil:

here is the code:

# Locate ProQuest Config File CONFPART.F
findconf(){
LOC=0
# search all partitions for a file in the root directory
for i in /mnt/tmp ; do
# See if it's already mounted
[ -f "$i/$1" ] && { echo "$i/$1"; return 0; }
done
return 0
}


searchdrv(){
DRIVES="/dev/[h,s]d[a-z][0-9]"
CONFDRV=""
LOC=""
for drv in $DRIVES ; do
if mount -rw $drv /mnt/tmp >/dev/null 2>&- ; then
LOC="$(findconf CONFPART.F)"
[ -n "$LOC" ] && { umount /mnt/tmp; echo $drv; return 0; }
umount /mnt/tmp
fi
done
return 0
}

# locate ProQuest config partition and mount as hda1
mkdir /mnt/tmp 2>&-
mkdir /mnt/hda1 2>&-

# Search for config files
echo "0" > /proc/sys/kernel/printk
EXISTS="$(searchdrv)"
if test "$EXISTS"; then
echo "${CRE}${BLUE}Found CONFPART.F in ${MAGENTA}$EXISTS"
mount -rw "$EXISTS" /mnt/hda1 2>&-
else
echo "${CRE}${RED}Local config files not loaded"
fi