關於 Ubuntu 自動掛載 Windows 分區

來源:互聯網
上載者:User
把下面的儲存為 /usr/sbin/autowinfs
sudo gedit /usr/sbin/autowinfs

#!/bin/sh
#
#autowinfs auto mount windows disks
#
# Copyright (c) 2005 Jiahua Huang <jhuangjiahua@gmail.com>
#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
mkdir "/windows/$WDISKS"
done

mv /etc/fstab.swp /etc/fstab

mount -a

exit 0

再運行命令
sudo chmod +x /usr/sbin/autowinfs
sudo /usr/sbin/autowinfs

就可以了

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.