温馨提示×

Centos如何挂载Windows

小樊
49
2026-08-30 05:20:57
栏目: 智能运维

在 CentOS 上挂载 Windows 的磁盘或共享,常见有三种场景。下面分别说明,你可以按需要选择。


一、挂载 Windows 的 NTFS 磁盘(物理磁盘/双系统)

1️⃣ 确认 Windows 磁盘

lsblk
fdisk -l

找到 Windows 所在分区(如 /dev/sda2,常见是 NTFS)。


2️⃣ 安装 NTFS 支持(CentOS 7 / 8)

CentOS 默认不支持 NTFS,需要安装 ntfs-3g。

CentOS 7

yum install epel-release -y
yum install ntfs-3g -y

CentOS 8 / Stream

dnf install epel-release -y
dnf install ntfs-3g -y

3️⃣ 创建挂载目录

mkdir -p /mnt/windows

4️⃣ 挂载 NTFS 分区

mount -t ntfs-3g /dev/sda2 /mnt/windows

✅ 如果是 只读问题,加参数:

mount -t ntfs-3g -o ro /dev/sda2 /mnt/windows

5️⃣ 设置开机自动挂载(可选)

编辑 /etc/fstab:

/dev/sda2  /mnt/windows  ntfs-3g  defaults  0 0

二、挂载 Windows 共享文件夹(SMB/CIFS)

适用于:

  • Windows 共享目录
  • 局域网访问

1️⃣ 安装 CIFS 工具

yum install cifs-utils -y
# 或
dnf install cifs-utils -y

2️⃣ 创建挂载目录

mkdir -p /mnt/win_share

3️⃣ 挂载 Windows 共享

mount -t cifs //Windows_IP/共享名 /mnt/win_share \
-o username=windows用户名,password=密码

示例:

mount -t cifs //192.168.1.100/share /mnt/win_share \
-o username=admin,password=123456

4️⃣ 避免明文密码(推荐)

vim /etc/smbpass

内容:

username=admin
password=123456

挂载:

mount -t cifs //192.168.1.100/share /mnt/win_share -o credentials=/etc/smbpass

5️⃣ 开机自动挂载

//192.168.1.100/share  /mnt/win_share  cifs  credentials=/etc/smbpass  0 0

三、挂载 Windows VHD / VHDX(虚拟机磁盘)

如果你是指 Windows 虚拟机磁盘,需要:

  • 使用 qemu-nbd
  • 或使用 kpartx

常见场景:

modprobe nbd
qemu-nbd -c /dev/nbd0 windows.vhd
mount /dev/nbd0p1 /mnt

⚠️ 需要安装:

yum install qemu-img -y

四、常见问题

❓ 挂载失败:Windows 快速启动

✅ 在 Windows 中:

  • 关闭 快速启动
  • 或使用:
mount -t ntfs-3g -o remove_hiberfile

❓ 中文文件名乱码

mount -t cifs ... -o iocharset=utf8

五、你可以告诉我

为了给你更精确的方案,可以告诉我:

  1. CentOS 版本(7 / 8 / Stream)
  2. 是 物理磁盘 还是 网络共享
  3. Windows 是 本地磁盘 / 共享目录 / 虚拟机磁盘

我可以直接给你一条可复制执行的完整命令 ✅

0 踩