Note: This article is now available on the Amazon Kindle Bookstore: Repairing Windows XP in Eight Commands. Download a convenient e-book version of this article to keep at your side while you repair your computer. Every IT tech from casual to professional should have a copy of this handy reference. There are other commands available in DiskPart, such as the online command that is used to bring an offline disk online, and the import command that allows Windows XP to recognize a “foreign. Dialog box keyboard shortcuts. If you press Shift+F8 in extended selection list boxes, you enable extended selection mode. In this mode, you can use an arrow key to move a cursor without changing the selection. You can press Ctrl+Spacebar or Shift+Spacebar to adjust the selection. To cancel extended selection mode, press Shift+F8 again. Keyboard shortcuts supported by the Microsoft Windows XP operating system. Windows 2000 Recovery Console from the Startup Menu. For a list of commands you can use with the Recovery Console, type HELP at the Recovery Console command Prompt. When starting up Windows 2000 / XP, there will be a boot-selection menu displayed, where you can startup Windows or the Recovery Console: If the default selection is to start the.
One of the most basic tasks involved in using computers is managing disks. Partitioning, formatting, defragmenting, and creating volumes are all skills that help a computer user or technician optimize the way storage space is used by the system and organize the data, system, and application files that are stored on the disk. We’ve come a long way since the DOS days when the FDISK command was the primary means of managing disks.Windows XP includes a variety of tools to help you manage your physical and logical disks. The graphical disk management utility (part of the Computer Management MMC) is the most obvious, but many XP users don’t realize that they also have powerful command line utilities at their service. The most versatile of these is diskpart.exe, a command interpreter that allows you to do, at the command line, most of the same disk management tasks that you can perform with the Disk Management console—and more.
Command line vs. GUI
Why use a command line tool when there’s a perfectly good graphical interface at your disposal? Many experienced users find the command line faster, since your hands can stay on the keyboard and there’s no need for mouse clicking. But the most important reason to master the command line administrative utilities, such as DiskPart, is the ability to write scripts that can automate tasks. For example, you might want to create a script to be used during an unattended setup to partition the disk and create additional volumes on the system (only the boot volume is normally created during the unattended setup process).
A script is a text file that you start by using the diskpart /s command, with the scriptname following, as in:
Diskpart /s scriptname.txt
You can also use the noerr parameter to direct DiskPart not to stop processing the script if it encounters an error (which it does by default). The noerr parameter can be added to the end of most of the commands I’ll discuss (it should be used only in scripts, not when you are entering commands directly).
Tip
Even if you use the noerr parameter, DiskPart will still give you an error message if you get the command syntax wrong.
If you want to add comments to your script, you can use rem to set off the text that you don’t want to be processed.
DiskPart overview
Perhaps the most important (and the only ”tricky”) thing to know about using the DiskPart utility is how to put the “focus” on an object. The objects that can be managed by the DiskPart utility are disk objects: disks, partitions, and volumes. Some of the actions you can perform on them include:
- Partitioning
- Removing all partitioning and formatting information
- Assigning and removing drive letters and mount points
- Converting from basic to dynamic
- Creating volumes (XP supports only simple, spanned, and striped volumes, not fault tolerant volumes)
- Extending volumes
There are a few commands that allow you to do things you can’t do with the GUI, such as creating an EFI (Extensible Firmware Interface) partition or a GUID partition table (GPT) for Itanium-based computers when you’re running the 64-bit version of XP, and preparing a dynamic simple volume to be used as the boot or system volume during unattended setup. Additionally, you can delete OEM MBR partitions with DiskPart—something you can’t do with the Disk Management console.
Tip
DiskPart was also available for Windows 2000, but it was not installed by default. You had to download it as part of the Resource Kit.
DiskPart allows you to list and manage IDE, SCSI, USB, and IEEE 1394 (FireWire) disks. Removable drives (such as zip/jaz drives or flash card devices) are not included.
Using DiskPart
The first step in using DiskPart is to list the available disk objects and then select one on which to focus. First, use the list disk command to select the disk on which you want to work (assuming you have more than one physical disk installed in the computer), and then use the list partition command to see the partitions on that disk and select one. The list partition command won’t work if you haven’t selected a disk first.
You can also use the list volume command to see the volumes on all the disks. This provides information such as the drive letter assigned to each volume, its label, the file system in which it’s formatted, size, health status, and whether it is a system or boot volume, as shown in Figure A. This does not tell you which physical disk each volume is on.
Figure A |
The list volume command displays information about all volumes on all disks. |
If you do want to know which volumes are on a particular disk, you can use the detail disk command to find out. This command provides details—including manufacturer/model number, ID, type, and volume information—about the disk on which the focus is placed.
Tip
Using the detail partition and detail volume commands, you can also view detailed information about partitions and volumes.
Placing the focus on an object
When you initially list the disks, no disk has focus. Here’s the tricky part (or at least, the part that you have to dig down into the Help file to figure out): To put the focus on an object, you use the select disk, select partition, or select volume command. The syntax is:
Select disk/partition/volume <number>
After you select an object, it will appear with an asterisk (*) to indicate that the focus is on it, as shown in Figure B, where I have selected disk 2.
Figure B |
After you use select disk to place the focus on an object, it is marked with an asterisk (*). |
After you’ve selected a disk, you can select a partition on that disk, using the select partition command, as shown in Figure C. As you can see, when you list partitions, both the extended partition and the logical drives within that partition are shown as partitions.
Figure C |
Logical drives within the extended partition are also shown as partitions. |
Tip
You can change the focus explicitly with the select command, but some operations that you perform can implicitly change the focus. For example, if you change the volume focus to a volume that is on a different disk from the disk the focus is on, the disk focus changes to the disk on which the selected volume is located.
Now that you know how to list and select objects, let’s look at what you can do with them.
Converting disks
Windows XP computers support both basic and dynamic disks. Basic disks are divided into partitions. Dynamic disks use volumes (a disk can be divided into volumes, or a volume can span multiple disks).
You can use the convert command to change a disk from basic to dynamic or vice versa. When you convert a disk from dynamic to basic, it must be empty, but a disk with data and partitions can be converted from basic to dynamic. Put the focus on the disk you want to convert and type convert dynamic or convert basic.
You can also change a disk from MBR to GPT or vice versa with the convert mbr or convert gpt command. The disk cannot have data or partitions on it for either of these conversions. You can convert a disk to GPT only if it is installed on an Itanium computer.
Creating and extending partitions and volumes
There are five create partition commands that can be used to create new partitions on the disk that is in focus. They are:
create partition primary
create partition extended
create partition logical
create partition efi
create partition msr
With any of these, you use the size=n and offset=n parameters to set the size and offset for the partition. The size is entered in megabytes and the offset refers to where on the disk to place the partition. If you don’t enter a size, the partition will use all the contiguous free space that is available. If you don’t enter an offset, the partition will be placed in the first free contiguous disk space that is big enough to hold it.
An EFI partition is used by the Extensible Firmware Interface, a new environment for booting the OS that is intended to replace the BIOS. An EFI partition is required on Itanium computers running Windows XP 64-bit edition. An MSR partition is a Microsoft-reserved partition. An MSR partition is required on GPT disks (also on Itanium computers).
On dynamic disks, you can create three types of volumes on XP computers:
- Simple volumes: Contains disk space from a single physical disk
- Spanned volumes: Extends across two or more physical disks
- Striped volumes: Also known as RAID 0, combines equal sized areas of space on multiple physical disks, increasing performance
Windows XP does not support fault tolerant volumes (mirrored or RAID 1 volumes and RAID 5 volumes). DiskPart can be used to create RAID 1 and RAID 5 volumes on Windows 2000 Server and Windows Server 2003 computers.
Use the following create volume commands to create new volumes on dynamic disks:
create volume simple
create volume stripe
In addition to specifying the size (size=n), you’ll need to specify the disk number on which the volume is to be created (disk=n). If you don’t set a size for a simple volume, it will use whatever contiguous free space is available. If you don’t set a size for a striped volume, it will make the stripes the size of whatever free space is available on the disk with the smallest amount of free space. There is no offset for volumes on dynamic disks.
To create a spanned volume, use the extend command to extend a simple volume to another disk. The syntax is:
extend disk=n size=n
Partitions and volumes can be removed by using the delete partition and delete volume commands.
Tip
DiskPart, like the GUI Disk Manager, will not let you delete the system or boot partition or a partition on which an active paging file is located.
Other disk management tasks
When you create a partition with DiskPart, it does not automatically assign a drive letter. To assign it a drive letter, you need to use the assign command. You can specify a drive letter with the command (assign letter=<driveletter>) or if you use the command alone, it will assign the next drive letter that is available. You can also use assign to assign a mount point, using the mount=<path> parameter.
You can remove a drive letter or mount point using the remove command. If you don’t specify a letter or path, the first one DiskPart finds on the volume with the focus will be removed. You can also use the all
Command For Windows Xp Repair
parameter if you want to remove all drive letters and mount points.You can set a partition as active by changing the focus to the partition you want to make active and using the active command. You should set a partition as active only if it contains the files required to boot an OS; otherwise, the computer won’t boot into the OS after you make the change.
Now, if you want to undo everything you’ve done and remove all the partition or volume formatting, you can use the clean command. Be careful with this one; it will overwrite the master boot record (MBR) or, on GPT disks, the Guid Partition Table. If you want to go further and delete all the data, overwriting every sector on the disk with zeros, use the clean all command.
There are other commands available in DiskPart, such as the online command that is used to bring an offline disk online, and the import command that allows Windows XP to recognize a “foreign” disk that has been installed and make it a member of the computer’s disk group. However, the commands described above are the ones you’re likely to use most often.
Finally, when you’re finished with DiskPart, the exit command will take you back to the command prompt.
Summary
The graphical interface is great, but when you need a fast way to do disk management or you want to script disk management tasks, the command line DiskPart utility is an invaluable tool.