community.windows.win_format 模块 – 格式化 Windows 上现有卷或现有分区上的新卷

注意

此模块是 community.windows 集合 (版本 2.3.0) 的一部分。

如果您使用的是 ansible 软件包,则可能已安装此集合。它不包含在 ansible-core 中。要检查它是否已安装,请运行 ansible-galaxy collection list

要安装它,请使用:ansible-galaxy collection install community.windows

要在 playbook 中使用它,请指定:community.windows.win_format

概要

参数

参数

注释

allocation_unit_size

整数

指定格式化卷时要使用的集群大小。

如果格式化分区时未指定集群大小,则会根据分区的尺寸选择默认值。

此值必须是磁盘物理扇区大小的倍数。

compress

布尔值

在生成的 NTFS 卷上启用压缩。

当 *allocation_unit_size* 大于 4096 时,不支持 NTFS 压缩。

选项

  • false

  • true

drive_letter

字符串

用于指定要格式化的卷的驱动器号。

file_system

字符串

用于指定格式化目标卷时要使用的文件系统。

选项

  • "ntfs"

  • "refs"

  • "exfat"

  • "fat32"

  • "fat"

force

布尔值

指定是否应强制格式化未从新分区创建的卷,或者源文件系统和目标文件系统是否不同。

选项

  • false ← (默认)

  • true

full

布尔值

完全格式化会写入磁盘的每个扇区,比默认(快速)格式化花费的时间长得多,并且不建议在稀疏配置的存储上使用。

指定 true 进行完全格式化。

选项

  • false ← (默认)

  • true

integrity_streams

布尔值

在生成的 ReFS 卷上启用完整性流。

选项

  • false

  • true

label

字符串

用于指定要格式化的卷的标签。

large_frs

布尔值

指定应使用大型文件记录系统 (FRS)。

选项

  • false

  • true

new_label

字符串

用于指定格式化卷的新文件系统标签。

path

字符串

用于指定要格式化的卷的路径。

备注

注意

另请参阅

另请参阅

community.windows.win_disk_facts

显示目标主机的已连接磁盘和磁盘信息。

community.windows.win_partition

在 Windows Server 上创建、更改和删除分区。

示例

- name: Create a partition with drive letter D and size 5 GiB
  community.windows.win_partition:
    drive_letter: D
    partition_size: 5 GiB
    disk_number: 1

- name: Full format the newly created partition as NTFS and label it
  community.windows.win_format:
    drive_letter: D
    file_system: NTFS
    new_label: Formatted
    full: true

作者

  • Varun Chopra (@chopraaa)