把下面的儲存為 /usr/sbin/autowinfs
sudo gedit /usr/sbin/autowinfs
#!/bin/sh
#
#autowinfs auto mount windows disks
# copyright (c) 2005 jiahua huang <[email protected]>
#license: gplv2
# /usr/bin/sutowinfs
# 用來自動挂載機器上的 windows 分區 , 并寫入 /etc/fstab
# 五 2月 18 14:06:12 cst 2005
mkdir -p /windows/
rmdir /windows/* 1> /dev/null
grep -v '/windows/' /etc/fstab > /etc/fstab.swp
# 本腳本用于 utf-8 的 locale 下 , 如果是 gbk 的 locale , 就把 下面的 iocharset=utf8 換成 iocharset=cp936
# 單獨的 fdisk -l 不能列出分區的情況很少了 , 是以把 /dev/[hs]d[a-z] 去掉
## fdisk -l /dev/[hs]d[a-z] | grep -e 'fat|ntfs' | cut -d' ' -f1 | cut -d/ -f3 | while read wdisks
# 查找 ntfs 分區 , 新核心的 auto 好像有點問題 , 是以現在把 ntfs 和 vfst 分開來
fdisk -l /dev/[hs]d[a-z] | grep 'ntfs' | cut -d' ' -f1 | cut -d/ -f3 | while read wdisks
do echo "/dev/$wdisks /windows/$wdisks ntfs auto,user,iocharset=utf8,umask=0 0 0" >> /etc/fstab.swp
mkdir "/windows/$wdisks"
done
fdisk -l /dev/[hs]d[a-z] | grep 'fat' | cut -d' ' -f1 | cut -d/ -f3 | while read wdisks
do echo "/dev/$wdisks /windows/$wdisks vfat auto,user,iocharset=utf8,umask=0 0 0" >> /etc/fstab.swp
mv /etc/fstab.swp /etc/fstab
mount -a
exit 0
再運作指令
sudo chmod +x /usr/sbin/autowinfs
sudo /usr/sbin/autowinfs
就可以了