4

I installed Ubuntu app on Window 10 OS and trying to run dd command. But the dd command is not listing all drives present in system. I am not sure whether is it Ubuntu app limitation or something is missing in configuration. Please provide me inputs to resolve this issue.

Sagar
  • 49
  • gasp you never want to use a low-level disk io program like dd in an OS like Windows. – WinEunuuchs2Unix Nov 13 '19 at 02:10
  • *NEVER* do this in WSL. WSL is also NOT a complete Linux environment, so dd being used there is NOT going to work properly. DO NOT use it in WSL! – Thomas Ward Nov 13 '19 at 16:23
  • It may be possible to run dd on mounted devices in WSL 2 which is scheduled to be released in April, 2020. – karel Nov 13 '19 at 16:52

3 Answers3

8

You can't.

WSL is not a complete environment. Notably, it lacks a Linux kernel.

WSL is an abstraction layer that allows execution of 64-bit ELF binaries on Windows. It does not provide the traditional Linux device access.

This may change somewhat with WSL2, which is HyperV-based virtualization solution.

vidarlo
  • 22,691
5

Ubuntu and Linux in general running in Windows

As already stated by in the answer by @vidarlo, WSL cannot do everything, that we are used to do in Ubuntu (or Linux in general). But it is a good tool, that provides several of the tools and functions, that we are used to from Ubuntu.

Another alternative, that also suffers from limitations due to the lack of a Linux kernel is the old CygWin.

@vidarlo also mentioned a virtualization solution, that might improve the capability of the next generation of WSL.

There are already other (and general) virtualization solutions. Maybe the most common one for personal use is VirtualBox.

If your computer has enough CPU 'horsepower' and enough memory (RAM), you can run the real Ubuntu live and/or install it in a virtual machine using VirtualBox.

Alternatives to dd in Windows

You want to use dd in WSL. It makes me think that you want to clone from a hybrid iso file, file.iso, or maybe from some other kind of image file file.img to a device, for example a USB pendrive, a memory card, an SSD or a hard disk drive.

In this case you can use Windows tools for cloning,


If you want to do other tasks, for example recovering data from a failing drive, it may be a good idea to create a [persistent] live drive with Ubuntu, install ddrescue from the repository with the package gddrescue and maybe some other tools into it (for example TestDisk and PhotoRec) and work from there.

sudodus
  • 46,324
  • 5
  • 88
  • 152
  • 1
    As an alternative I would also recommend trying Cygwin's dd binary, it has worked perfectly for me and I still use it to backup disk and partition images. – the.1337.house Nov 12 '19 at 16:59
  • @PanosKordis, Thanks for this tip :-) Please write an answer and describe how to identify the drives in Cygwin, and the command line to use, and I will upvote it. dd can be very useful, but risky. There is no 'safety belt' against writing to the wrong drive. – sudodus Nov 12 '19 at 17:24
1

I would recommend giving Cygwin's dd a try.

To find the path to the disk or partition to use as input, view the file /proc/partitions

$ cat /proc/partitions 
major minor  #blocks  name   win-mounts

    8     0 125034840 sda
    8     1    562176 sda1  
    8     2 124470272 sda2   C:\
    8    16 3907018583 sdb
    8    17    131072 sdb1
    8    18 3906885632 sdb2   D:\

first.

To backup the entire disk a Windows partition resides in (e.g. sda2) use a command line like this,

dd if=/dev/sda ...

/dev/sda for the entire disk instead of the partition /dev/sda2

sudodus
  • 46,324
  • 5
  • 88
  • 152