将移动硬盘挂载到 WSL2

# 在 powershell 使用如下命令查看磁盘路径
wmic diskdrive list brief
# 在 powershell 中使用下面的命令将磁盘挂载到 WSL2,下面的 DeviceID 类似 \\.\PHYSICALDRIVE3
wsl --mount <DeviceID> --bare
# wsl --mount \\.\PHYSICALDRIVE3 --bare
# 使用完毕需要卸载则执行下面的命令
wsl --unmount <DeviceID>
# wsl --unmount \\.\PHYSICALDRIVE3
# 安装必要的软件
sudo apt update && sudo apt install -y cfdisk lsof
# 在挂载之后可以通过下面的命令查看磁盘
lsblk
# 如果磁盘没有创建任何分区可以使用下面的命令进行分区和格式化,其中 sde 为移动硬盘的名字
sudo cfdisk /dev/sde
lsblk
sudo mkfs.ext4 /dev/sde1
# 使用下面的命令进行挂载,其中 /mnt/t7 为挂载路径
sudo mkdir /mnt/t7
sudo mount /dev/sde1 /mnt/t7
# sudo chown -R $USER:$USER /mnt/t7
# 使用下面的命令进行卸载
sudo umount /mnt/t7

1.如果在卸载时提示 'device is busy'

# 查找占用挂载点的进程
sudo lsof /mnt/t7
# 结束相关进程(替换 PID 为实际进程号)
sudo kill -9 PID
# 如果还是不行可以在 powershell 中卸载之后,再在 wsl2 中卸载

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>