关于 Ubuntu 自动挂载 Windows 分区

简介: 把下面的保存为 /usr/sbin/autowinfssudo gedit /usr/sbin/autowinfs#!/bin/sh##autowinfs auto mount windows disks## Copyright (c) 2005 Jiahua Huang <jhuangjiahua@gmail.com>#License: GPLv2## /usr/bin/suto
把下面的保存为 /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



就可以了
相关文章
|
1月前
|
监控 Ubuntu Linux
Windows11 WSL2 Ubuntu编译安装perf工具
通过以上步骤,你已经在Windows 11的WSL2中成功编译并安装了 `perf`工具。尽管在WSL2中可能会遇到一些限制,但大部分基本性能分析功能应当可以正常使用。使用 `perf`进行性能分析,可以帮助你更好地理解和优化系统及应用程序的性能。
76 14
|
6月前
|
监控 Ubuntu Linux
视频监控笔记(五):Ubuntu和windows时区同步问题-your clock is behind
这篇文章介绍了如何在Ubuntu和Windows系统中通过设置相同的时区并使用ntp服务来解决时间同步问题。
152 4
视频监控笔记(五):Ubuntu和windows时区同步问题-your clock is behind
|
6月前
|
Ubuntu Linux Python
如何利用wsl-Ubuntu里conda用来给Windows的PyCharm开发
如何在WSL(Windows Subsystem for Linux)的Ubuntu环境中使用conda虚拟环境来为Windows上的PyCharm开发设置Python解释器。
640 1
|
8月前
|
Ubuntu 安全 Linux
Windows——安装Ubuntu 18.04 LTS
Windows——安装Ubuntu 18.04 LTS
177 1
Windows——安装Ubuntu 18.04 LTS
|
6月前
|
Ubuntu Linux 开发工具
windows11安装WLS2+Ubuntu
windows11安装WLS2+Ubuntu
|
6月前
|
Kubernetes 容器
基于Ubuntu-22.04安装K8s-v1.28.2实验(三)数据卷挂载NFS(网络文件系统)
基于Ubuntu-22.04安装K8s-v1.28.2实验(三)数据卷挂载NFS(网络文件系统)
337 0
|
8月前
|
Windows
Windows——windows10下如何和子系统Ubuntu18.04互传文件
Windows——windows10下如何和子系统Ubuntu18.04互传文件
111 1
|
8月前
|
Linux Go
Linux——windows10下的Ubuntu18.04安装并配置go环境
Linux——windows10下的Ubuntu18.04安装并配置go环境
90 1
|
8月前
|
Ubuntu Linux 开发工具
Windows11 WSL2 Ubuntu编译安装perf工具
Windows11 WSL2 Ubuntu编译安装perf工具
431 0
|
8月前
|
存储 Linux Windows
【应用服务 App Service】App Service For Windows 如何挂载Storage Account File Share 示例
【应用服务 App Service】App Service For Windows 如何挂载Storage Account File Share 示例