USB Flash Rescue for Windows

2014/03/30 by Lassi A. Liikkanen

Fixing Windows 7 boot problems with a USB rescue drive

Sometimes it feels that things go wrong at the worst possible moment. Truly mobile computer user may experience failure of the system inconveniently at an airport thousands of mails away from the IT support. When a computer fails to start, frustration hits and good advice are needed. Rescue disks can be helpful, but in a world of ultraportable laptops and netbooks, not everyone travels with an optical drive. And those who do don't necessarily carry around a rescue disc. Luckily, you don't need an optical disc with you, instead you can keep a Windows repair copy with you on a USB drive. This guide tells you how to create one and gives an insight about how computers start up.

Understanding your problem

It is necessary to understand that there are problems which can be repaired with a rescue boot disk and some that cannot. Bit simplified, the boot procedure of a modern computer consists of the five steps, listed below and followed by parenthesis indicating typical problem:

  1. Powering up (hardware: power supply and switch, component short circuits)

  2. BIOS boot (hardware: motherboard components, BIOS software)

  3. Accessing boot media (hardware: device function; software: boot sector)

  4. Running boot manager (software: boot record integrity, partitions)

  5. Starting up the operating system (software: everything, new hardware devices)

This guide does no consider all boot issues, particularly items from 1 to 3 are excluded. Windows 7 rescue disk can help you to recover from step 4 to 5. How can you tell where's the problem? Simply put, you can say that if your computer turns on and brights up the screen for a five to ten seconds but then comes to a halt, you have passed from the steps 1 and 2. Telling apart issues 3 and 4 can be more difficult. You should check the details of the error message produced by your computer from a search engine to see where you're at.

Different problems of the boot sequence step four and five have distinct origins. Problems with the boot loader (step four) can relate to the installation or removal of a secondary operating system, such as dual boot Linux. You probably know what has caused the problem when you face it. Problems with booting the operating system, the fifth category, used to be quite common and were often countermeasured using a safe mode boot (F8 during Windows startup). Although these issues are coming less everyday now, the rescue disc might help you when *it happens.

Creating Windows rescue USB

For some reason, Windows does not allow you to create a rescue USB pen with the standard tools. Instead you need to start from an optical rescue medium and create your custom rescue stick. The rescue stick can be quite small, the whole Windows recovery environment (Windows RE) operating system takes up around 230MB of space, so an old USB memory of 512MB will do just fine. The steps in order are following:

  1. Clearing out and formatting the USB

  2. Copying the rescue disk files to the USB

  3. Making the USB bootable

First, create the rescue disc while your hooked up to an optical drive with a Win7 machine. Press Win+R and type in recdisc to run “Create a system repair disc” utility. Use a blank CD or DVD to create the image.

Next you need to format the USB drive appropriately. This requires command line utility called diskpart. Diskpart will wipe out everything from the drive and create a NFTS partition on the drive. The NFTS volume is essential for the Windows boot loader to work. This trick is achieved with the following commands:



DISKPART> list disk

DISKPART> select disk X

DISKPART> clean

DISKPART> create partition primary

DISKPART> select partition 1

DISKPART> active

DISKPART> format fs=ntfs

DISKPART> assign

DISKPART> exit



Notice the second step in which you determine which disk you are working with. You should select the disk number from the list produced in the previous step. Replace X in the second step with your USB disk number.

Formatting a big USB disk for NFTS using diskpart can take time. My 16GB drive (don't even ask why I used that big disk) took nearly an hour. Once the formatting is complete, you should find out what are your drive letters for the optical drive and newly mounted USB drive. After these procedures the stick is prepared to take in the Windows files. Copy them from the repair CD/DVD:

C:\Windows\system32>XCOPY X: Y: /e /h

In the example, X: refers to my DVD drive and Y: to my USB drive.

The stick now looks like it could work, but alas, it doesn't. That's because it is not bootable. You will need to run BOOTSECT.EXE to write a boot sector for your USB disk. Unfortunately this utility does not always come unpacked with Windows installation or in the repair disc at least with Windows 7 Enterprise. This is too bad, but you can find the utility from your IT support, Windows 7 installation disc, some other rescue disc, from Windows online services, or from the Internet. One option which I did not try, is to boot your computer using the optical rescue disk. Once the recovery environment is up and running, you should be able to copy bootsect.exe which emerges from the package onto the USB drive. Please observe that you use appropriate 32 or 64-bit version matching your installation.

Assuming that you find the utility, the final trick is easy:

BOOTSECT.EXE /NT60 Y:

and your drive is ready! Don't mind the Access is denied error message you might see, this is normal for a flash drive. Before placing the stick in your laptop sleeve or day bag, check that it really boots. On most modern computers you can bring a boot menu during BIOS boot sequence by pressing F12 and select your USB drive and see that it works.

On the bottom of the page you can see a log of commands and outputs I received:

Using the disc

I provide one use case for the disc. I decided to erase an old Linux dual boot installation from my laptop's hard drive. The machine was this far booted up using GRUB boot loader and I knew I was into trouble as I deleted the Linux partition from my hard drive using Windows Disk management. This confuses GRUB which does not anymore find the Linux boot partition. So I'm dealing with the fourth type of problem which can be with the rescue disc.

What I do is to simply plug in the repair USB, boot it up and select Command prompt. You should now be able to access your Windows installation volume as drive C. You can then give the command:

bootrec.exe /fixmbr

this erases GRUB code from the boot sector and restores Windows boot loader to the boot sector of the hard disk. After GRUB is removed the Windows boots up normally. The tools included in the rescue disk for automatically repairing startup problems did not fix this for me.

More about booting

Boot problems related to the step four (boot record function) are difficult to diagnose because of the lack of transparency in operation. First we must acknowledge that each disk device contains one or several partitions. Each partition holds volumes, four of which can be primary, the following are contained within a primary partition (called logical partition) holding extended partitions. Partitions can be mounted in Windows with a drive letter or to a mount point in Linux. The operating system boot code is contained within a so called boot partition (though the terminology is mixed between Windows and other operating systems). Boot partitions are not otherwise different but need to contain the particular code, a volume boot record, needed to bootstrap the computer startup. Boot manager code in the boot partition in contained within a file visible in the file system. For instance, try deleting bootmgr file from your Windows7 installation C: and you will make it dead (or at least non bootable).

However, the first and mandatory part of the bootcode is invisible. It is called the master boot record and resides on first, zero sector of the device before the first partition. Master boot record, or MBR is used with all disk devices that can be partitioned (in IBM PCs). On devices such as floppies, CDs, and DVDs, a volume boot record (VBR) is the only boot file needed. The difference is that MBR includes also the partition table required to keep track of the partitions of the disk. This means that on a hard drive, both MBR and VBR can be independently damaged and prevent the proper loading of the operating system. Usually MBR and VBR code is interdependent, because the tiny area for boot code requires the bootstrapping from a VBR to complete the booting. E.g. even though GRUB installs its own code in the boot sector, it quickly calls for a boot code from the Linux boot partition to get the boot loader up and running.

The rescue USB creation log

Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Windows\system32>recdisc
C:\Windows\system32>diskpart

Microsoft DiskPart version 6.1.7600
Copyright (C) 1999-2008 Microsoft Corporation.
On computer: GAYOMART
DISKPART> list disk
Disk ### Status Size Free Dyn Gpt
-------- ------------- ------- ------- --- ---
Disk 0 Online 119 GB 48 GB
Disk 1 Online 7638 MB 0 B
Disk 2 Online 14 GB 0 B

DISKPART> select disk 2
Disk 2 is now the selected disk.

DISKPART> clean
DiskPart succeeded in cleaning the disk.

DISKPART> create partition primary
DiskPart succeeded in creating the specified partition.

DISKPART> select partition 1
Partition 1 is now the selected partition.

DISKPART> active
DiskPart marked the current partition as active.

DISKPART> format fs=ntfs
100 percent completed

DiskPart successfully formatted the volume.

DISKPART> assign

DiskPart successfully assigned the drive letter or mount point.

DISKPART> exit

Leaving DiskPart...

C:\Windows\system32>xcopy e: g: /e /h
E:\bootmgr
E:\bootbcd
E:\bootboot.sdi
E:\bootbootfix.bin
E:\sourcesboot.wim
5 File(s) copied

AT THIS POINT I GO AND RETRIEVE BOOTSECT.EXE FROM THE INTERNET

BOOTSECT.EXE /NT60 G:
Updated NTFS filesystem bootcode. The update may be unreliable since the
volume could not be locked during the update:
Access is denied.

Bootcode was successfully updated on all targeted volumes.

Known issues

You may run into several further issues if you are trying to proceed with Windows Image Recovery (Image backup), available from Windows Vista onwards. This tool can be used to create a mirror image of your system which should then be easily recoverable. Well, yes and no.

As I've written in a separate guide , Image restore works poorly. One of my readers pointed out that the ominous error code 0x80070057 (Windows could not format a partition on disk 0.) can be overcome; as long as you remove the USB flash drive just before the reimaging process starts. Let it find the image and click next. Then remove the flash drive. Once it is restored it will reboot. Please see that article if you're have difficulties with Image restore.

References

http://windows7forums.com/windows-7-support/34709-how-remove-grub-loader-get-windows-7-boot-loader-back-uninstalling-linux.html

http://www.intowindows.com/how-to-install-windows-7vista-from-usb-drive-detailed-100-working-guide/

http://hardforum.com/showthread.php?t=1381323

http://social.answers.microsoft.com/Forums/en-US/w7install/thread/37eadf15-85dd-4e56-a89c-fa0a3339b92e

http://www.everettsporting.com/bootsect.zip

http://hardforum.com/showthread.php?t=1381323&page=8

http://technet.microsoft.com/en-us/library/cc976796.aspx

http://technet.microsoft.com/en-us/library/cc749177(WS.10).aspx

Keywords: [computers] , [windows] Document's status: Ok (Document dates explained)

This document created: 2010/07/31
Modified: 2014/03/30
Published: 2010/08/03


This document's permanent URI (linking):
http://iki.fi/lassial/guides/computers/140330-USB_Flash_Rescue_for_Windows

© Lassi A. Liikkanen 2010 - 2016. All rights reserved.
^Top of the Page^

*Change layout:
Printable printable
Large text

Myydään:

@lassial Twitter feed: