How to reinitialize a complete windows system drive image from live linux?

0

I've seen a few questions about how to install windows from linux using ISO. And after some search also found how to install an image of a linux from linux: Create an image file of a running Linux system

Now what I want to do is different there though. My plan is to make an image of my windows system drive (about once a month). And then use that to reinstall in case the hard drive fails or an installation went awry. And all of that as automatic as possible.

Thus I came up with the plan to use a linux there to boot (without installing the linux) and then use command line statements that I could then put onto an USB stick in order to just call a single command and get my hard drive and system back to working condition.

As I didn't find much info there, my question would be how to do it? In essence it boils down to these two parts:

  • What do I need to keep in mind when creating the image (program restrictions, ...)
  • How can I restore the image of the windows OS to the PC (what commands to use there, what to keep in mind)?

As a note: I'm taking the worst case scenario into account there that the hard drive crashed and has to be replaced. Thus the computer has no OS installed at all afterwards. Thus the idea of the live linux there. Maybe as a remark: The image of the windows drive should be created from within windows itself.

Thomas

Posted 2015-11-30T07:34:28.283

Reputation: 279

Answers

1

Well, in Linux you can create an image of any partition or drive using dd (or a program like ddrescue). Running live or regular, just need rw access to the drives.

Warning: dd can be extremely dangerous, overwriting entire partitions or drives at the press of a key. It's also known as Data Destroyer. So be EXTREMELY CAREFUL.

If your hard drive is /dev/sda then to image the whole drive it's basically:

dd if=/dev/sda of=/path/backupdrivefile.dd

and restore is

dd if=/path/backupdrivefile.dd of=/dev/sdx

Or for just a partition, use /dev/sdaN where N is the partition number.

  • Restoring can be a tricky part, if the drive being restored to is a different size, and impossible if it's smaller. Just copying one partition could be easier to restore, just create an empty partition of the same size, then write to it.
  • Also, there could be problems if Windows was only "sleeping" or "hibernating"
  • And changing too much hardware may make Windows complain and think you're a
    pirate
    Just a new storage drive should be ok though.

There's trickier things you can do too, like compress the image first (dd if=/dev/sdaN | gzip -9 > /path/backupNfile.dd), or use a fancier program or setup like maybe Clonezilla.

If it were me, I'd consider

  • creating a Windows Installation disk or Recovery Disk/Drive (USB). Instructions on the Microsoft Community appear to be here for Windows 7 (System Repair disk):

    1. Open Backup and Restore by clicking the Start button, clicking Control Panel, clicking System and Maintenance, and then clicking Backup and Restore.
    2. In the left pane, click Create a system repair disc, and then follow the steps. If you're prompted for an administrator password or confirmation, type the password or provide confirmation.

    and here for Windows 10:

    1. Type “Recovery” in search box and press Enter.
    2. Select the option to create a recovery disc and follow the prompts to create a recovery disc.

    Didn't find Windows 8, but assuming it's virtually the same

  • Keep good backups of all the data and copies of any setup files / registration info for installed programs.

Then if anything bad happens, you can restore/re-install windows and install your wanted programs again, and copy back your files from the backup, and virtually start over with a "fresh" Windows (that used to be a "recommended fix" for most Windows problems) with no worries if Windows will "take" to being restored from a full disk image. Plus, if anything goes wrong you can always turn to MS for help fixing it.

Xen2050

Posted 2015-11-30T07:34:28.283

Reputation: 12 097

+1 for the details and warnings. Btw the picture that made me laugh :). I've heard windows sometimes even thinks that if you change just the memory so the SHOULD be is sadly really a should. But as its just an image written in case of a defective hdd reactivating should be possible without much problems (latest after a call to the microsoft support line). but back to topic. The 2 commands+parameters you listed for restore and backup do make the image for teh whole drive with ALL of the partitions correct? – Thomas – 2015-11-30T11:13:33.193

Btw interesting part about compressing the image. if I'm not mistaken it makes the image then compresses it. Am I right that I then need to use gzip and pipe the result to dd for installing the image? – Thomas – 2015-11-30T11:14:21.117

If it's a zipped image, then would first need to unzip & pipe, correct. Like with gzip -dc file |dd ... or zcat file |dd .... If a drive/partition is mostly empty then they can compress all the zero's a LOT, but dd reads whatever is on the disk, old files marked deleted and everything, it doesn't skip over "free" space. I have a potentially better idea on how to "get windows back" after having to change disks, I'll edit it into the answer. – Xen2050 – 2015-11-30T14:37:49.377