|
新的内核识别光驱也对应新硬件,应该识别为 sr0,而不是 sda
改写了一下如下:
#!/bin/sh
#自动检测加载分区 //Written by KanKer haulm for Magic Linux
#if [ -f /etc/profile.d/lang.sh ]; then
#. /etc/profile.d/lang.sh
#case $LANG in
#cp936 cp950 cp932 cp949 改成 utf8
if [ ! -f /etc/fstab ];
then touch /etc/fstab;
fi
case $1 in
zh_CN*|zh_SG*)
MOUNTOPTIONS="iocharset=utf8"
;;
zh_TW*|zh_HK*)
MOUNTOPTIONS="iocharset=utf8"
;;
ja_JP*)
MOUNTOPTIONS="iocharset=utf8"
;;
ko_KR*)
MOUNTOPTIONS="iocharset=utf8"
esac
# for scsi devices,now only for sata.
if ! grep -Rn "/dev/pts" /etc/fstab >/dev/null;then
echo 'none /dev/pts devpts gid=5,mode=620 0 0'>>/etc/fstab
fi
if ! grep -Rn "/dev/shm" /etc/fstab >/dev/null;then
echo 'none /dev/shm tmpfs defaults 0 0'>>/etc/fstab
fi
if ! grep -Rn "/proc" /etc/fstab >/dev/null;then
echo 'none /proc proc defaults 0 0'>>/etc/fstab
fi
if ! grep -Rn "/sys" /etc/fstab >/dev/null;then
echo 'none /sys sysfs defaults 0 0'>>/etc/fstab
fi
if [ -f /proc/scsi/scsi ];then
for j in $(/sbin/fdisk -l|grep ^/dev/sd|cut -c1-10);do
LABEL=$(e2label $j 2>/dev/null)
FSTYPE=$(/usr/sbin/fstype $j)
if [ ! -z ${FSTYPE} ];then
if ! grep -Rn "$j " /etc/fstab >/dev/null;then
MYMOUNT="/mnt/$(basename $j)"
mkdir -p "${MYMOUNT}"
chmod 777 "${MYMOUNT}"
if echo ${FSTYPE}|grep -i vfat >/dev/null; then
echo "$j ${MYMOUNT} ${FSTYPE} ${MOUNTOPTIONS},umask=0,exec,rw 0 0" >>/etc/fstab
elif echo ${FSTYPE}|grep -i ntfs >/dev/null; then
MOUNTOPTIONS="locale=zh_CN.UTF8"
echo "$j ${MYMOUNT} ${FSTYPE} ${MOUNTOPTIONS},umask=0 0 0" >>/etc/fstab
MOUNTOPTIONS="iocharset=utf8"
elif echo ${FSTYPE}|grep -i swap >/dev/null; then
echo "$j swap swap defaults 0 0" >>/etc/fstab
else
echo "$j ${MYMOUNT} ${FSTYPE} defaults 0 0" >>/etc/fstab
fi
fi
fi
done
if (cat /proc/scsi/scsi |grep CD-ROM >/dev/null);then
if ( ! grep -Rn sr0 /etc/fstab >/dev/null );then
MYMOUNT="/mnt/cdrom"
mkdir -p "${MYMOUNT}"
chmod 777 "${MYMOUNT}"
echo "/dev/sr0 ${MYMOUNT} udf,iso9660 ${MOUNTOPTIONS},user,noauto 0 0" >>/etc/fstab
fi
fi
fi
#for ide devices
if [ -d /proc/ide ];then
for i in $(ls -d /proc/ide/h*);do
if cat $i/media |grep -i disk >/dev/null;then
for j in $(/sbin/fdisk -l /dev/$(basename $i)|cut -c1-10|grep hd);do
LABEL=$(e2label $j 2>/dev/null)
FSTYPE=$(/usr/sbin/fstype $j)
if [ ! -z ${FSTYPE} ];then
if ! grep -Rn "$j " /etc/fstab >/dev/null;then
MYMOUNT="/mnt/$(basename $j)"
mkdir -p "${MYMOUNT}"
chmod 777 "${MYMOUNT}"
if echo ${FSTYPE}|grep -i vfat >/dev/null; then
echo "$j ${MYMOUNT} ${FSTYPE} ${MOUNTOPTIONS},umask=0,exec,rw 0 0" >>/etc/fstab
elif echo ${FSTYPE}|grep -i ntfs-3g >/dev/null; then
MOUNTOPTIONS="locale=zh_CN.UTF8"
echo "$j ${MYMOUNT} ${FSTYPE} ${MOUNTOPTIONS},umask=0 0 0" >>/etc/fstab
MOUNTOPTIONS="iocharset=utf8"
elif echo ${FSTYPE}|grep -i swap >/dev/null; then
echo "$j swap swap defaults 0 0" >>/etc/fstab
else
echo "$j ${MYMOUNT} ${FSTYPE} defaults 0 0" >>/etc/fstab
fi
fi
fi
done
elif cat $i/media |grep -i cdrom >/dev/null;then
if ! grep -Rn $(basename $i) /etc/fstab >/dev/null;then
MYMOUNT="/mnt/cdrom-$(basename $i)"
if [ ! -d "${MYMOUNT}" ]; then
mkdir -p "${MYMOUNT}"
chmod 777 "${MYMOUNT}"
fi
echo "/dev/$(basename $i) ${MYMOUNT} udf,iso9660 ${MOUNTOPTIONS},user,noauto 0 0" >>/etc/fstab
fi
fi
done
fi
mount -o remount -a
[ 本帖最后由 haulm 于 2012-1-6 16:05 编辑 ] |
|