Back up a bootable USB drive to an image file

1

1

I've used the "Recovery Disk" function in Windows 8.1 to create a bootable USB drive with the factory defaults for a laptop. Now I plan to wipe the laptop and install Ubuntu on it.

I'm not comfortable with having a USB drive as my only backup for the factory image (the reliability of these drives is legendary \s). So a more reliable backup is in order.

Is there a way to make Windows Recovery write directly to a mounted image file instead of a USB drive? Alternatively, can I create a bootable image file from the USB drive, including all the boot info and the data? This might be something like dd, but in Windows for a UEFI-enabled bootable drive.

The end goal is to maintain the image file in safe backup and write it to an actual USB drive only if/when required for a factory reset.

I've tried looking at a few articles, such as this, but they go off on tangents without addressing the issue I'm facing (or similar). This question and this one are similar, but not quite the same.

metacubed

Posted 2014-12-22T05:05:35.423

Reputation: 281

There are some tools in Linux that will do this for a Linux installation on a flash drive, although I have not yet had that joy. I don't know if one of those would work on a Windows flash drive, particularly 8.x (the idea being that you boot up into Linux with a LiveDVD and use the tool from there). You would download and burn the Linux iso, and booting from it wouldn't affect anything on your system. I'll just throw this concept out there as a possibility in case it triggers a thought for someone with more knowledge. – fixer1234 – 2014-12-22T06:18:21.613

@fixer1234 The laptop doesn't even have an optical drive. I might be able to use a live USB I guess. – metacubed – 2014-12-22T06:36:40.623

If something like this would work, you will probably need two USB ports (you wouldn't be able to unplug the live session drive to plug in the Windows drive). A USB hub would do it if you don't have two free USB ports. – fixer1234 – 2014-12-22T06:40:17.913

@fixer1234 I'd rather go for a Windows-based solution though, saving steps if it makes sense. – metacubed – 2014-12-22T08:52:54.143

Answers

3

You can use Cygwin to obtain a working version of dd through Windows. I'm not sure how cygwin dd handles its device naming, but Linux drives are mounted as "/dev/sdX". A simple google search should explain cygwin's method of handling USB devices.

This will require root priviledges. On an actual Linux machine you would just run the command with sudo, but with Cygwin you have to launch it by right-clicking it and selecting "Run as administrator".

On Linux, if we assume the flashdrive is /dev/sdb (whenever you find cygwin's alternate device naming, substitude that for this in the command), one would use dd if=/dev/sdb of=usbImage.img bs=4M. Then you can put this newly created "usbImage.img" file somewhere you remember, and use the same command (but with 'if' and 'of' reversed) to write the image BACK to the flashdrive.

Before running this command, make sure the flashdrive is prepared in this "bootable" state. After running the command, you can modify the flashdrive however you please and you can later return it to the bootable state by simply running dd if=usbImage.img of=/dev/sdb bs=4M (the same command but with if/of reversed).

Remember that restoring the image to the flashdrive will completely overwrite all data on it.

techniponi

Posted 2014-12-22T05:05:35.423

Reputation: 316

I'm not familiar with the UEFI implications for a flash drive, but this will record and restore all of the Windows boot partitioning, etc. on the flash drive? – fixer1234 – 2014-12-22T20:09:27.083

@fixer1234 Think of it as a RAW backup of the 0's and 1's of the flashdrive. It preserves it in the EXACT state of the entire device, including partitions. – techniponi – 2014-12-22T22:00:08.580

FYI using Cygwin does not allow me to access the drive directly (/dev/sdb in my case). I get a "Permission denied". sudo does not work either. I'm looking for workarounds as I type this. – metacubed – 2014-12-24T05:33:13.807

All right.. got it working. I needed to right-click the Cygwin exe and "Run as Administrator". This adds the current user to the root group. If you can add that bit in, I will mark this as the answer. Thanks! – metacubed – 2014-12-24T06:46:15.780

Done, glad I could help. – techniponi – 2014-12-24T16:46:27.233