格式Format

适用于: Windows 10、Windows Server 2016Applies to: Windows 10, Windows Server 2016

格式化磁盘以接受 Windows 文件。Formats a disk to accept Windows files. 您必须是 Administrators 组的成员才能格式化硬盘驱动器。You must be a member of the Administrators group to format a hard drive.

备注

你还可以在恢复控制台中使用带有不同参数的 format 命令。You can also use the format command, with different parameters, from the Recovery Console. 有关恢复控制台的详细信息,请参阅 windows RE) (Windows 恢复环境 For more information about the recovery console, see Windows Recovery Environment (Windows RE).

语法Syntax

format <volume> [/fs:{FAT|FAT32|NTFS}] [/v:<label>] [/q] [/a:<unitsize>] [/c] [/x] [/p:<passes>]
format <volume> [/v:<label>] [/q] [/f:<size>] [/p:<passes>]
format <volume> [/v:<label>] [/q] [/t:<tracks> /n:<sectors>] [/p:<passes>]
format <volume> [/v:<label>] [/q] [/p:<passes>]
format <volume> [/q]

参数Parameters

参数Parameter 说明Description
<volume> 指定要格式化的驱动器的装入点、卷名或驱动器号 (后面跟一个冒号) 。Specifies the mount point, volume name, or drive letter (followed by a colon) of the drive that you want to format. 如果未指定任何以下命令行选项,则 format 将使用卷类型来确定磁盘的默认格式。If you do not specify any of the following command-line options, format uses the volume type to determine the default format for the disk.
/fs: {FAT/fs:{FAT FAT32FAT32 NTFSNTFS} 指定文件系统的类型 (FAT、FAT32、NTFS) 。Specifies the type of file system (FAT, FAT32, NTFS).
/v:<label>/v:<label> 指定卷标。Specifies the volume label. 如果省略了 /v 命令行选项或在未指定卷标的情况下使用它,则格式化完成后, 格式 会提示你输入卷标。If you omit the /v command-line option or use it without specifying a volume label, format prompts you for the volume label after the formatting is complete. 使用语法 /v: 以防提示输入卷标。Use the syntax /v: to prevent the prompt for a volume label. 如果使用单个 format 命令格式化多个磁盘,则会为所有磁盘指定相同的卷标。If you use a single format command to format more than one disk, all of the disks will be given the same volume label.
/a<unitsize>/a:<unitsize> 指定要在 FAT、FAT32 或 NTFS 卷上使用的分配单元大小。Specifies the allocation unit size to use on FAT, FAT32, or NTFS volumes. 如果未指定 unitsize,则会根据卷大小进行选择。If you don't specify unitsize, it's chosen based on volume size. 对于常规使用,强烈建议采用默认设置。Default settings are strongly recommended for general use. 以下列表显示了 NTFS、FAT 和 FAT32 unitsize的有效值:The following list presents valid values for NTFS, FAT, and FAT32 unitsize:
  • 512512
  • 10241024
  • 20482048
  • 40964096
  • 81928192
  • 16K16K
  • 32K32K
  • 64K64K
对于大小超过 512 字节的扇区,FAT 和 FAT32 还支持 128k 和 256k。FAT and FAT32 also support 128K and 256K for a sector size greater than 512 bytes.
/q/q 执行快速格式化。Performs a quick format. 删除以前格式化的卷的文件表和根目录,但不会对错误区域执行逐个扇区扫描。Deletes the file table and the root directory of a previously formatted volume, but does not perform a sector-by-sector scan for bad areas. 你应使用 /q 命令行选项来仅设置你知道的状态良好的以前格式化的卷的格式。You should use the /q command-line option to format only previously formatted volumes that you know are in good condition. 请注意,/q 可替代 /pNote that /q overrides /p.
/f<size>/f:<size> 指定要格式化的软盘的大小。Specifies the size of the floppy disk to format. 如果可能,请使用此命令行选项,而不是 /t/n 命令行选项。When possible, use this command-line option instead of the /t and /n command-line options. Windows 可接受的大小值如下:Windows accepts the following values for size:
  • 1440或1440k 或1440kb1440 or 1440k or 1440kb
  • 1.44、1.44 m 或 1.44 mb1.44 or 1.44m or 1.44mb
  • 1.44-MB,双面,四密度,3.5-英寸磁盘1.44-MB, double-sided, quadruple-density, 3.5-inch disk
/t:<tracks>/t:<tracks> 指定磁盘上的磁道数。Specifies the number of tracks on the disk. 如果可能,请改用 /f 命令行选项。When possible, use the /f command-line option instead. 如果使用 /t 选项,则还必须使用 /n 选项。If you use the /t option, you must also use the /n option. 这些选项共同提供了指定正在格式化的磁盘大小的另一种方法。These options together provide an alternative method of specifying the size of the disk that is being formatted. 此选项对 /f 选项无效。This option is not valid with the /f option.
/n<sectors>/n:<sectors> 指定每个磁道的扇区数。如果可能,请使用 /f 命令行选项,而不是 /nSpecifies the number of sectors per track. When possible, use the /f command-line option instead of /n. 如果使用 /n,则还必须使用 /tIf you use /n, you must also use /t. 这两个选项共同提供了指定正在格式化的磁盘大小的另一种方法。These two options together provide an alternative method of specifying the size of the disk that is being formatted. 此选项对 /f 选项无效。This option is not valid with the /f option.
/p<passes>/p:<passes> 归零卷上的每个扇区的指定操作数量。Zeros every sector on the volume for the number of passes specified. 此选项对 /q 选项无效。This option is not valid with the /q option.
/c/c 仅限 NTFS。NTFS only. 默认情况下,将压缩在新卷上创建的文件。Files created on the new volume will be compressed by default.
/x/x 在格式化之前,如有必要,会卸除卷。Causes the volume to dismount, if necessary, before it's formatted. 针对卷的任何打开句柄将不再有效。Any open handles to the volume will no longer be valid.
/?/? 在命令提示符下显示帮助。Displays help at the command prompt.

注解Remarks

  • Format命令为磁盘创建新的根目录和文件系统。The format command creates a new root directory and file system for the disk. 它还可以检查磁盘上的坏区,并可以删除磁盘上的所有数据。It can also check for bad areas on the disk, and it can delete all data on the disk. 若要使用新磁盘,必须先使用此命令格式化磁盘。To be able to use a new disk, you must first use this command to format the disk.

  • 格式化软盘后, 格式 将显示以下消息:After formatting a floppy disk, format displays the following message:

    Volume label (11 characters, ENTER for none)?

    若要添加卷标签,请键入最多11个字符, (包括空格) 。To add a volume label, type up to 11 characters (including spaces). 如果你不想将卷标添加到磁盘,请按 ENTER。If you do not want to add a volume label to the disk, press ENTER.

  • 当使用 format 命令格式化硬盘时,会显示一条类似于下面的警告消息:When you use the format command to format a hard disk, a warning message similar to the following displays:

    WARNING, ALL DATA ON NON-REMOVABLE DISK
    DRIVE x: WILL BE LOST!
    Proceed with Format (Y/N)? _
    

    若要格式化硬盘,请按 Y;如果不想格式化磁盘,请按 NTo format the hard disk, press Y; if you do not want to format the disk, press N.

  • FAT 文件系统将群集数量限制为不超过65526。FAT file systems restrict the number of clusters to no more than 65526. FAT32 文件系统将分类数限制为介于65527和4177917之间。FAT32 file systems restrict the number of clusters to between 65527 and 4177917.

  • 大小超过 4096 的分配单元不支持 NTFS 压缩。NTFS compression is not supported for allocation unit sizes above 4096.

    备注

    如果使用指定的群集大小确定以前的要求无法满足,则Format会立即停止处理。Format will immediately stop processing if it determines that the previous requirements can't be met using the specified cluster size.

  • 格式化完成后, 格式 将显示显示总磁盘空间、标记为有缺陷的空格和文件可用空间的消息。When formatting is complete, format displays messages that show the total disk space, the spaces marked as defective, and the space available for your files.

  • 您可以使用 /q 命令行选项加速格式设置过程。You can speed up the formatting process by using the /q command-line option. 仅在硬盘上没有损坏扇区的情况下使用此选项。Use this option only if there are no bad sectors on your hard disk.

  • 不应在使用subst命令准备的驱动器上使用format命令。You shouldn't use the format command on a drive that was prepared by using the subst command. 不能通过网络对磁盘进行格式化。You can't format disks over a network.

  • 下表列出了每个退出代码以及其含义的简要说明。The following table lists each exit code and a brief description of its meaning.

    退出代码Exit code 说明Description
    00 格式化操作已成功。The format operation was successful.
    11 提供了不正确的参数。Incorrect parameters were supplied.
    44 出现错误, (是0、1或 5) 以外的任何错误。A fatal error occurred (which is any error other than 0, 1, or 5).
    55 用户按下了 N,以响应 "继续 (Y/N) 的格式?"The user pressed N in response to the prompt "Proceed with Format (Y/N)?" 以停止此进程。to stop the process.

    可以结合使用 ERRORLEVEL 环境变量和 if 批处理命令来检查这些退出代码。You can check these exit codes by using the ERRORLEVEL environment variable with the if batch command.

示例Examples

若要使用默认大小格式化驱动器 A 中的新软盘,请键入:To format a new floppy disk in drive A using the default size, type:

format a:

若要在驱动器 A 的以前格式化的软盘上执行快速格式化操作,请键入:To perform a quick format operation on a previously formatted floppy disk in drive A, type:

format a: /q

若要格式化驱动器 A 中的软盘,并为其分配卷标 数据,请键入:To format a floppy disk in drive A and assign it the volume label DATA, type:

format a: /v:DATA

其他参考Additional References