# Backing up Windows drive using dd



## balanga (Mar 14, 2017)

After installing Debian on a USB stick I have discovered that my mSATA drive with Windows installed has been corrupted, presumably by GRUB. Before attempting to perform a recovery of my Windows partition, I wanted to back up the drive, and wondered if I could use `dd` to do this. What seems to have happened is that GRUB overwrote the MBR of the mSATA drive and in so doing any file system information seems to have been corrupted. 

gpart show identifies the former NTFS partitions as ms-basic-data. I want to save the data on a external disk before trying to correct the file system information. Can I use `dd` to do this?


----------



## wblock@ (Mar 14, 2017)

Yes.  Of course, it will copy every block in the partition, not just used ones, but there is no way to get around that now.  Give it a decent buffer size to speed up copying.


----------



## balanga (Mar 14, 2017)

What should I set `of=` to?


----------



## ShelLuser (Mar 14, 2017)

balanga said:


> What should I set `of=` to?


Check dd(1)? of specifies the output file, so you should set this to whatever file you want to create. Not something we can answer.


----------



## balanga (Mar 14, 2017)

I know that if I set `of` to a device it has to be a least as big as `if` and then I will create a copy, but I'm not sure what will happen if I set it to a file...


----------



## wblock@ (Mar 14, 2017)

If set to a file, the output goes to a file.  Likely a huge file, depending on the input.  It can be piped through gzip(1) for compression:
`dd if=/dev/ada0s2 bs=1M | gzip > /home/storage/corrupt-win-nt-fs.gz`

(Untested.)


----------

