Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cygwin equivalent of Linux /dev/sda, /dev/sdb etc

On Linux, I can access a hard drive as /dev/sdX. This ignores any partition tables, file systems, etc, and just accesses the drive block by block. What is the equivalent in Cygwin? I already searched Google, but could not find anything that works.

I'd like to be able to (for example) create an image of a flash drive with something like

dd if=/dev/??? of=image.bin

I understand that there are Windows programs to read and write hard drive images. The dd command is just a clarifying example. I am not after creating a drive image. I am after device name.

like image 517
rsteward Avatar asked Jan 04 '16 04:01

rsteward


2 Answers

In Cygwin simply copy-and-past the following,"as one long entry" then press enter

for F in /dev/s* ; do echo "$F    $(cygpath -w $F)" ; done

This should be able to be ran as a script by adding the shebang to the beginning of a file along with the text from above

Your output should be similar to the following

PB-2@PB-2 ~
$ for F in /dev/s* ; do echo "$F    $(cygpath -w $F)" ; done
/dev/scd0    \\.\E:
/dev/scd1    \\.\F:
/dev/sda    \\.\Disk{dc9927e0-d232-e04c-2c75-77f787df605d}
/dev/sda1    \\.\Volume{1200e263-fc48-458c-a1d6-115b385b372c}
/dev/sda2    \\.\HarddiskVolume2
/dev/sda3    \\.\STORAGE#Volume#{7c54accc-b533-11e6-9cce-806e6f6e6963}#0000000025900000#{7f108a28-9833-4b3b-b780-2c6b5fa5c062}
/dev/sda4    \\.\C:
/dev/sda5    \\.\Volume{c3553ab1-e8a5-4d7b-a324-544b32fe3d3e}
/dev/sdb    \\.\Disk{ff7e8c9f-7aa2-1f15-8d02-d126ff13dfb5}
/dev/sdb1    \\.\D:
/dev/sdc    \\.\Disk{07352cef-974b-9296-720f-70f1ae015a85}
/dev/sdc1    \\.\G:
/dev/shm    C:\cygwin64\dev\shm
/dev/sr0    \\.\E:
/dev/sr1    \\.\F:
/dev/stderr    /dev/pty0
/dev/stdin    /dev/pty0
/dev/stdout    /proc/3888/fd/pipe:[94489288360]

PB-2@PB-2 ~
$

It took me hours of searching to find this So I'm glad to be sharing it.

If one then wants to know the corresponding Cygpaths

simply type

mount

And the output should be similar to what follows

PB-2@PB-2 ~
$ mount
C:/cygwin64/bin on /usr/bin type ntfs (binary,auto)
C:/cygwin64/lib on /usr/lib type ntfs (binary,auto)
C:/cygwin64 on / type ntfs (binary,auto)
C: on /cygdrive/c type ntfs (binary,posix=0,user,noumount,auto)
D: on /cygdrive/d type ntfs (binary,posix=0,user,noumount,auto)
E: on /cygdrive/e type udf (binary,posix=0,user,noumount,auto)
F: on /cygdrive/f type iso9660 (binary,posix=0,user,noumount,auto)
G: on /cygdrive/g type exfat (binary,posix=0,user,noumount,auto)

PB-2@PB-2 ~
$
like image 88
phatboyj Avatar answered Nov 14 '22 02:11

phatboyj


make

cat /proc/partitions

and you will see the actual mapping of /dev/sdX to their Windows counterparts.

like image 25
rgrr Avatar answered Nov 14 '22 03:11

rgrr