一个自动挂载dos分区的脚本 特别感谢作者:sjqu兄
时间:2010-06-27 来源:hkebao
特别感谢作者:sjqu兄
这就是我的一个练习,请多指教。
代码:
#!/bin/bash
#bakup /etc/fstab
cp /etc/fstab /etc/fstab.orig
# config
fdisk -l /dev/hda |grep FAT >>temp
fdisk -l /dev/hdb |grep FAT >>temp
fdisk -l /dev/hdc |grep FAT >>temp
fdisk -l /dev/hdd |grep FAT >>temp
#sort
awk '$0~/\*/ {print $1" "$NF}' temp >>pt
awk '$0!~/\*/ {print $1" "$NF}' temp >>pt
i=142
while read disks fstype
do
if [ $fstype = "FAT32" ]; then
disks_FS=vfat
else
disks_FS=msdos
fi
i=`expr $i + 1`
if [ "${i:2}" != "8" -a "${i:2}" != "9" ]; then
echo -e "$disks"\\t"/mnt/"\\$i""\\t"$disks_FS"\\t"iocharset=gb2312,codepage=936,umask=0 0 0" >>/etc/fstab
fi
done <pt
rm -f temp pt 原文地址 http://www.bsdlover.cn/html/73/n-773.html
这就是我的一个练习,请多指教。
代码:
#!/bin/bash
#bakup /etc/fstab
cp /etc/fstab /etc/fstab.orig
# config
fdisk -l /dev/hda |grep FAT >>temp
fdisk -l /dev/hdb |grep FAT >>temp
fdisk -l /dev/hdc |grep FAT >>temp
fdisk -l /dev/hdd |grep FAT >>temp
#sort
awk '$0~/\*/ {print $1" "$NF}' temp >>pt
awk '$0!~/\*/ {print $1" "$NF}' temp >>pt
i=142
while read disks fstype
do
if [ $fstype = "FAT32" ]; then
disks_FS=vfat
else
disks_FS=msdos
fi
i=`expr $i + 1`
if [ "${i:2}" != "8" -a "${i:2}" != "9" ]; then
echo -e "$disks"\\t"/mnt/"\\$i""\\t"$disks_FS"\\t"iocharset=gb2312,codepage=936,umask=0 0 0" >>/etc/fstab
fi
done <pt
rm -f temp pt 原文地址 http://www.bsdlover.cn/html/73/n-773.html
相关阅读 更多 +