Cygwin equivalent of Linux /dev/sda, /dev/sdb etc
Asked Answered
C

2

7

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.

Cyaneous answered 4/1, 2016 at 4:24 Comment(0)
P
24

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 ~
$
Phillane answered 6/3, 2017 at 6:5 Comment(2)
A bit inelegant but at least it works, unlike the other answer.Cuxhaven
sd* is better than s*Fillmore
P
14

make

cat /proc/partitions

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

Purgatorial answered 15/1, 2016 at 23:4 Comment(3)
Mine doesn't. Could you paste your output? It shows major minor #blocks name, none of which is the windows disk name.Cuxhaven
Can confirm that if a HDD is mounted, this shows the drive letter it's mounted on, under a win-mounts header after name, and this has been the case for as long as I can remember.Wisner
Curiously, coming back to this, this no longer works for some unknown reason - that is, there's nothing showing in the win-mounts column. Can anyone else confirm whether it works on their system?Wisner

© 2022 - 2024 — McMap. All rights reserved.