LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Debian (https://www.linuxquestions.org/questions/debian-26/)
-   -   How to reproduce the knoppix Automount for Debian? (https://www.linuxquestions.org/questions/debian-26/how-to-reproduce-the-knoppix-automount-for-debian-743018/)

frenchn00b 07-27-2009 02:05 AM

How to reproduce the knoppix Automount for Debian?
 
Hello,

Here I come up with the idea, to do like knoppix for debian.

example:
Quote:

fstab:
/proc /proc proc defaults 0 0
/sys /sys sysfs noauto 0 0
/dev/pts /dev/pts devpts mode=0622 0 0
/dev/fd0 /mnt/auto/floppy auto user,noauto,exec,umask=000 0 0
/dev/cdrom /mnt/auto/cdrom auto user,noauto,exec,ro 0 0
# Added by KNOPPIX
/dev/hda1 /mnt/hda1 vfat noauto,users,exec,umask=000,uid=1001,gid=50 0 0
# Added by KNOPPIX
/dev/hda2 /mnt/hda2 auto noauto,users,exec 0 0
# Added by KNOPPIX
/dev/hda3 /mnt/hda3 ext2 noauto,users,exec 0 0
# Added by KNOPPIX
/dev/hda5 none swap defaults 0 0
# Added by KNOPPIX
/dev/hda6 /mnt/hda6 ext2 noauto,users,exec 0 0


So :

Code:

apt-get install udev autofs
then
Code:

mkdir /mnt/auto
then get this into the /etc/auto.master:
Code:

#
# $Id: auto.master,v 1.4 2005/01/04 14:36:54 raven Exp $
#
# Sample auto.master file
# This is an automounter map and it has the following format
# key [ -mount-options-separated-by-comma ] location
# For details of the format look at autofs(5).
#/misc  /etc/auto.misc --timeout=60
#/smb  /etc/auto.smb
#/misc  /etc/auto.misc
#/net  /etc/auto.net
/mnt/auto      /etc/automount.sh      --timeout=2

and save this /etc/automount.sh
Code:

#!/bin/bash
# Generate an automounter entry automatically
# for automount /mnt/auto program this_script
# (C) Klaus Knopper 2002
# WARNING: This script is used for removable media in KNOPPIX,

fstype(){
[ -n "$1" ] || return 1

while read device mountpoint filesystem relax; do
case "$device" in *$1*) echo "$filesystem"; return 0;; esac
done <<EOT
$(cat /proc/mounts)
EOT

dd if="$1" count=1 bs=1024 >/dev/null 2>&1 || return 2
FILE="$(LANG=C LC_ALL=C LC_MESSAGES=C file -Ls "$1")"
[ "$?" = "0" ] || return 2

FILESYSTEMS=""
case "$FILE" in
*[Ff][Aa][Tt]*|*[Xx]86*) FILESYSTEMS="vfat msdos ntfs";;
*[Rr][Ee][Ii][Ss][Ee][Rr]*)  echo "reiserfs"; return 0;;
*[Xx][Ff][Ss]*)  echo "xfs"; return 0;;
*[Ee][Xx][Tt]3*) echo "ext3"; return 0;;
*[Ee][Xx][Tt]2*) echo "ext2"; return 0;;
*[Ss][Ww][Aa][Pp]*) echo "swap"; return 0;;
esac
TMPDIR="/tmp/autmount.${1##*/}.$$.dir"
mkdir -p "$TMPDIR" || return 3
FS=""
read LOGLEVEL relax < /proc/sys/kernel/printk
echo "0" >/proc/sys/kernel/printk
for f in $FILESYSTEMS $(</etc/filesystems); do
mount -r -t "$f" "$1" "$TMPDIR" >/dev/null 2>&1 && { umount "$TMPDIR"; FS="$f"; break; }
umount -f "$TMPDIR" >/dev/null 2>&1
done
echo "$LOGLEVEL" >/proc/sys/kernel/printk
rmdir "$TMPDIR"
[ -n "$FS" ] && echo "$FS" || return 4
}

rw="rw"
device="/dev/${1##*/}"
case "$1" in
floppy)    [ -s /etc/sysconfig/floppy ] || exit 1; device="/dev/fd0";;
cdrom*)    rw="ro";;
dvd*)      rw="ro";;
esac

fs="$(fstype "$device")"

[ "$?" = "0" ] || exit 1

case "$fs" in
*fat|msdos) options="${rw},uid=knoppix,gid=knoppix,umask=000";;
ntfs)      options="ro,uid=knoppix,gid=knoppix,umask=0222";;
iso9660)    options="ro";;
*)          options="${rw}";;
esac

MNTLINE="-fstype=$fs,users,exec,$options        :$device"

echo "$MNTLINE"



All times are GMT -5. The time now is 05:50 PM.