One of the features of Windows Server 2008 is that many aspects of the operating system can be managed on a command-line basis. If we just need to define a RAID array on a computer with a GUI interface, it is usually easier to implement, and the Disk Management Console program will be able to complete the installation operation with a few clicks on the mouse.
Scripting is more efficient if you need to perform the same raid operations on multiple machines. Similarly, if we are installing Server Core, there is no other option but to manage our own disk subsystem from a command prompt. In this article, you will see how to implement the functionality mentioned above using command-line methods.
1, DiskPart command
Windows Server 2008 contains a command-line utility named Diskpart.exe to manage the disk subsystem of the server. To use this command, simply open a command prompt window and enter the DISKPART.EXE command, and Windows will enter the DiskPart shell interface. In the DiskPart shell interface, you can use various commands to manage the disk subsystem.
2, the syntax of the DiskPart command
DiskPart command format, according to the verb-noun syntax. Verbs tell windows what actions to perform, and nouns tell windows what to do with the action.
For a simple example: "List Disk" command. Where list is a verb, disk is a noun. When this command is entered, the operating system displays a list of all the physical disks installed on the server.
The List Disk command displays all disks that are installed on the server. But DiskPart seems to have a bug: In the value of the figure above, the DiskPart return result shows that the free space on disk 0 is 0 bytes. In practice, however, the disk has a GB of free space.
Note the above values, each disk is assigned a disk number. When we need to perform a specific operation on a particular disk, you can enter the "select" command to specify the disk. For example, to operate on disk 0, enter "select Disk 0" to select Disk 0.
In many cases, disk management involves creating fault-tolerant volumes, which can be easily done using DiskPart. For example, there is an operating system with four hard drives installed, and the hard drive number is 0,1,2,3. Assuming disk 0 is a system drive, disk 1, 2, and 3 are blank hard drives, we want to convert to a RAID 5-formatted volume.
Before creating a RAID 5 disk volume, we must make sure that each disk is a dynamic disk. The List Disk command can indicate whether the disk is dynamic, and we can look back at Figure 1. Assuming there are no dynamic disks, you can enter the convert dynamic command for conversion, as follows:
Select Disk 1
Convert Dynamic
Select Disk 2
Convert Dynamic
Select Disk 3
Convert Dynamic
The disks have been converted to dynamic disks, you can now create a RAID 5 disk volume using the "Create Volume" command, as follows:
Select Disk 1
Create Volume RAID Disk 1, 2, 3