powershell - 如何在 wsl2 上使用 linux dd 命令来刻录可启动的 USB?

标签 powershell windows-subsystem-for-linux dd wsl-2

我是一个狂热的 Linux 用户,他被要求使用 Windows 工作。我被允许在工作计算机上安装 WSL2 和 Ubuntu。我想在 WSL2 中使用 dd 刻录可启动 USB,但一直无法弄清楚如何获取设备,因为 lsblk 不提供连接到计算机的外部块设备。我知道我可以在 Rufus 之类的东西中做到这一点,但由于它是一台工作计算机,我不允许在计算机上获得类似的东西。
StackOverflow上只有一个这样的问题,但它已关闭并且没有给出答案。但是,它确实为我提供了开始寻找物理设备名称的线索。使用这条线索,我找到了这个问题的答案并想分享它,因为我不仅在 StackOverflow 上找不到答案,而且在互联网上的任何其他地方都找不到答案。

最佳答案

电源 shell :

# I ran this command to get the DeviceID of my USB Thumbdrive (Mine came out to be
# \.\\PHYSICALDRIVE 5, but yours may vary)
Get-WmiObject Win32_diskdrive | Select Caption,DeviceID,InterfaceType,Size | Where-Object {$_.InterfaceType -eq "USB"}
Ubuntu 20.04 终端:
# After I got the physical drive number from powershell (as I would do using lsblk in Linux) I
# formatted the drive using mkfs to ensure it would work before trying to use dd.
sudo mkfs.vfat -I \\.\PHYSICALDRIVE5

# After a successful format, I was able to run dd as normal
sudo dd if=path/to/my/file.iso of=\\.\PHYSICALDRIVE5 status=progress

关于powershell - 如何在 wsl2 上使用 linux dd 命令来刻录可启动的 USB?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64683871/

相关文章:

c# - linux dd命令的Windows C#实现

android - 使用 dd (Android) 将文件打印到进程标准输出

android - 如何制作安卓分区的镜像到你的电脑

powershell - 无法从远程计算机在 Windows Server 2012 R2 中执行 DSC 文件

.net - PowerShell - 如果用户输入凭据,则查询 AD 时出错

powershell - 在 powershell MTP 连接中访问上次修改日期

sh - 无法在 WSL 上创建符号链接(symbolic link)

windows-subsystem-for-linux - 如何让 Windows 10 终端启动 WSL?

ubuntu - 如何在 Win 10 中使用 WSL Ubuntu Bash 开发 Go App

powershell - 未向具有默认值的字符串参数传递任何值时出错