![diskpart命令](https://i-blog.csdnimg.cn/blog_migrate/f6fcadfb43c0a090fb7a8b342e9aa245.png)
diskpart命令
diskpart
is a Windows utility to create partitions on the disk. It is similar to the Linux fdisk utility. diskpart provides an interactive command shell where we will enter related commands to partition, format disk, and volumes. In order to run diskpart we need Administrator privileges. The best way to get Administrator privilege is opening MS-DOS as Administrator by right-clicking on it.
diskpart
是Windows实用程序,用于在磁盘上创建分区。 它类似于Linux fdisk实用程序。 diskpart提供了一个交互式命令外壳,我们将在其中输入相关命令来分区,格式化磁盘和卷。 为了运行diskpart,我们需要管理员权限。 获得管理员特权的最佳方法是通过右键单击以管理员身份打开MS-DOS。
diskpart命令交互模式 (diskpart Command Interactive Mode)
diskpart
is mainly used by its interactive shell. So we should enter this shell with the diskpart
command. All commands issued bellow are used in interactive diskpart
shell.
diskpart
主要由其交互式外壳使用。 因此,我们应该使用diskpart
命令输入此shell。 下面发布的所有命令都在交互式diskpart
shell中使用。
> diskpart
![Interactive Mode](https://i-blog.csdnimg.cn/blog_migrate/0fcb1f389925e4efe37e8078df1da693.png)
diskpart命令帮助(diskpart Command Help)
There are a lot of command supported by diskpart
. We can list these commands with help
diskpart
支持很多命令。 我们可以在help
这些命令
> help
![Help](https://i-blog.csdnimg.cn/blog_migrate/fce4fafb4c7bbe9fb4d9ceaf84b47fab.png)
列出磁盘和分区(List Disk and Partitions)
First we need to know how many disk there are. We will use list disk
command for this. We will also get following information about disks.
首先,我们需要知道有多少个磁盘。 我们将为此使用list disk
命令。 我们还将获得有关磁盘的以下信息。
- Status 状态
- Size尺寸
- Free自由
- GPTGPT
> list disk
![List Disk and Partitions](https://i-blog.csdnimg.cn/blog_migrate/3d6d3c81f0abd598170ebe837cfef1a5.png)
选择要格式化的磁盘(Select Disk To Format)
Now we will select the second disk which is numbered as 1. Because disk numbers start from 0. We will use select disk 1
. In order to execute format commands, we should select a disk.
现在,我们将选择第二个磁盘,编号为1。因为磁盘号从0开始。我们将使用select disk 1
。 为了执行格式化命令,我们应该选择一个磁盘。
> select disk 1
![Select Disk](https://i-blog.csdnimg.cn/blog_migrate/89d6ec583c8177558331e6bd23eb12b5.png)
清理驱动器分区表和信息(Clean Drive Partition Table and Information)
If there is an already set configuration we should clear them to make things simple. We will use clean
command.
如果已经设置好配置,我们应该清除它们以简化操作。 我们将使用clean
命令。
> clean
![Clean Drive](https://i-blog.csdnimg.cn/blog_migrate/b0066cb3b8e338b0e9b7204328cc1fdf.png)
检查磁盘选择(Check Disk Selection)
In order to execute commands to format disk we should select the disk and partition. We have already selected disk but we can check this selection with list disk
command too. Selected disk will have asterisk before its name.
为了执行格式化磁盘的命令,我们应该选择磁盘和分区。 我们已经选择了磁盘,但是我们也可以使用list disk
命令检查此选择。 所选磁盘的名称前将带有星号。
> list disk
![Check Disk Selection](https://i-blog.csdnimg.cn/blog_migrate/62f51249c3ba2e3bb019e29e15f5cc50.png)
创建新的分区表(Create New Partition Table)
We will create a partition on the selected disk. We will issue create partition primary. There are primary and secondary partition types. IF we have less than 5 partitions in a disk we can use primarily for all of them.
我们将在所选磁盘上创建一个分区。 我们将发布create partition primary。 有主分区和辅助分区类型。 如果磁盘中的分区少于5个,则可以将其主要用于所有分区。
> create partition primary
![Create Partition](https://i-blog.csdnimg.cn/blog_migrate/3d0e1a35e4188ef2251442ff43516d30.png)
列出现有分区表和信息(List Existing Partition Table and Information)
Now we can list partition we have already created. We will use list partition
command for this. Also following information about partition will be listed
现在我们可以列出已经创建的分区。 我们将为此使用list partition
命令。 此外,还将列出有关分区的以下信息
- Partition name分区名称
- Partition Type分区类型
- Szie西耶
- Offset抵消
> list partition
![List Partition](https://i-blog.csdnimg.cn/blog_migrate/3fb4196c147f2a0db7b68dcfe774eb95.png)
选择要修改的分区(Select Partition To Modify)
In order to operate on the given partition, we should select the partition with the select partition
command. This will select selected disks given partition according to number.
为了对给定的分区进行操作,我们应该使用select partition
命令选择该分区。 这将根据编号选择给定分区的选定磁盘。
> select partition 1
![Select Partition](https://i-blog.csdnimg.cn/blog_migrate/b6f7193aa31b6c4a76c42d55f00a35e5.png)
激活分区(Activate Partition)
In order to use partition we will activate it. We will use active
command.
为了使用分区,我们将激活它。 我们将使用active
命令。
> active
![Activate Partition](https://i-blog.csdnimg.cn/blog_migrate/1ad58172afd2fc8e64672174672d7810.png)
格式化分区(Format Partition)
This is one of the most important part. We will format the selected and activated partition. We will use format
command. Also, we will specify the file system type with the FS option. label option is used to set the name of partition which is shown to the user. quick specifies the format operation speed. In this example, we set file system type NTFS
and label D
这是最重要的部分之一。 我们将格式化选定并激活的分区。 我们将使用format
命令。 另外,我们将使用FS选项指定文件系统类型。 标签选项用于设置显示给用户的分区名称。 quick指定格式操作速度。 在此示例中,我们设置文件系统类型为NTFS
,标签为D
> format FS=NTFS label=D quick
![Format Partition](https://i-blog.csdnimg.cn/blog_migrate/1ef9821e81000d658ed9e20daa62fb60.png)
分配字母(Assign Letter)
In order to use the partition, we should assign a letter to the formatted partition. We will use assign
command with letter
option. In this example, we assign letter E
to the partition.
为了使用分区,我们应该为格式化的分区分配一个字母。 我们将使用带letter
选项的assign
命令。 在此示例中,我们为分区分配字母E
> assign letter=E
![Assign Letter](https://i-blog.csdnimg.cn/blog_migrate/d5429078d711b839d44f968de6f18815.png)
We can see from screenshot that we have tried to assign D
previously which is already assigned. This produced error and operation is not completed.
从屏幕截图中可以看到,我们已经尝试分配先前已分配的D
产生的错误和操作未完成。
从Diskpart Interactive Shell退出(Exit From Diskpart Interactive Shell)
We can exit from the diskpart
interactive shell with exit
command like below.
我们可以使用如下的exit
命令从diskpart
交互式shell中exit
。
> exit
翻译自: https://www.poftut.com/windows-diskpart-command-tutorial-examples-format-disk/
diskpart命令