自动挂载 windows 分区

执行下列命令, 编辑挂载脚本 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 下
    # 单独的 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,nls=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,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
就可以了,Windows分区将挂载在 /windows/ 下.
原文地址:https://www.cnblogs.com/simba/p/565285.html