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
。
概要
community.windows.win_format 模块格式化 Windows 上的现有卷或现有分区上的新卷
参数
参数 |
注释 |
---|---|
指定格式化卷时要使用的集群大小。 如果格式化分区时未指定集群大小,则会根据分区的尺寸选择默认值。 此值必须是磁盘物理扇区大小的倍数。 |
|
在生成的 NTFS 卷上启用压缩。 当 *allocation_unit_size* 大于 4096 时,不支持 NTFS 压缩。 选项
|
|
用于指定要格式化的卷的驱动器号。 |
|
用于指定格式化目标卷时要使用的文件系统。 选项
|
|
指定是否应强制格式化未从新分区创建的卷,或者源文件系统和目标文件系统是否不同。 选项
|
|
完全格式化会写入磁盘的每个扇区,比默认(快速)格式化花费的时间长得多,并且不建议在稀疏配置的存储上使用。 指定 选项
|
|
在生成的 ReFS 卷上启用完整性流。 选项
|
|
用于指定要格式化的卷的标签。 |
|
指定应使用大型文件记录系统 (FRS)。 选项
|
|
用于指定格式化卷的新文件系统标签。 |
|
用于指定要格式化的卷的路径。 |
备注
注意
需要 Microsoft Windows Server 2012 或 Microsoft Windows 8 或更高版本才能使用此模块。要检查您的系统是否兼容,请参见 https://docs.microsoft.com/en-us/windows/desktop/sysinfo/operating-system-version。
三个参数(*drive_letter*、*path* 和 *label*)中必须有一个来标识目标卷,但不能同时指定多个参数。
如果未指定 *force* 且文件系统标签保持不变,则此模块是幂等的。
有关更多信息,请参见 https://docs.microsoft.com/en-us/previous-versions/windows/desktop/stormgmt/format-msft-volume
另请参阅
另请参阅
- 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