I've been trying to do this for a while myself and I finally found a good answer.
Git for windows ships with the whole set of GNU core utilities (updated vs what you can find separately) including dd!
Just install Git for Windows or extract the portable version, from there inside of the install directory in git\usr\bin\ you will find the binaries for all of the GNU utils including dd (tested working)
Some further notes on usage in windows since \dev\sda\ isn't a thing:
$DiskDrives = Gwmi Win32_diskdrive | select DeviceID,BytesPerSector,Index,Caption,InterfaceType,Size,TotalSectors,SerialNumber | Out-GridView -OutputMode Multiple -Title 'Select Source Drive(s)'
$BaseOutputPath = 'D:\'
$DiskDrives | %{
. ('C:\Program Files\Git\usr\bin\dd.exe if={0} of={1} bs={2}' -f $_.DeviceID,(-join($BaseOutputPath,(-
join($Env:ComputerName,$_.Index)),'.img')),$_.BytesPerSector)
}
The included filename logic is just a placeholder, you can replace that parenthetical with a call to Read-Host
if you want it to prompt you for the filename/path.
It is a bit annoying but you really do have to use WMI as the values returned by Get-Disk
don't seem to work.
dd
(though not all have been maintained to work with the latest versions of Windows). There is no native, built-in PowerShell cmdlet for this, and while you could conceivably do it with hand-rolled raw disk access, that's almost certainly a bad idea (mostly because .NET, which PowerShell is based on, offers no easy way to do this). Windows does have files corresponding to raw disk volumes, just like Linux, but accessing them is much more convoluted. – Labyrinthinedd
style image isn't typically useful in a Windows environment. You could usediskpart
to create a VHD, ordiskpart
andMount-DiskImage
(Win10) to repartition, format, and copy files to a USB from an .iso. – Threemaster