community.general
community.general copied to clipboard
Add size argument support to filesystem task
From @ymartin59 on September 20, 2016 8:51 Migrated from https://github.com/ansible/ansible/issues/18893
SUMMARY
filesystem task does not allow to pass "size" last argument of mkfs command
It would enable to format a filesystem without using 100% of underlying block device. When LVM is not used, it is a way to reserve free space for "urgency" when file system becomes full.
It may allow to reduce filesystem on device or lvm volume if resizefs is set.
ISSUE TYPE
- Feature Idea
COMPONENT NAME
Module filesystem https://docs.ansible.com/ansible/latest/modules/filesystem_module.html
https://github.com/ansible-collections/community.general/blob/main/plugins/modules/system/filesystem.py
It is not possible to use opts to pass file system size in blocks.
ADDITIONAL INFORMATION
Example if size is made available
filesystem:
fstype="ext4"
dev="/dev/drbd0"
size="2048"
will invoke mkfs -t ext4 /dev/drbd0 2048
Files identified in the description:
If these files are inaccurate, please update the component name section of the description or use the !component bot command.
cc @MorrisA @abulimov @bcoca @d-little @flynn1973 @gforster @kairoaraujo @marvin-sinister @mator @molekuul @pilou- @ramooncamacho @wtcross click here for bot help
+label waiting_on_contributor
cc @quidame click here for bot help
@ymartin59 i'm not sure how to proceed here... since not all filesystems (looked at xfs and ext4) support creating fs with a given size, instead of creating fs on whole block device. I.e. mkfs.ext4 does support size argument, but mkfs.xfs does not.
I guess the module could either fail, or ignore the size parameter (and issue a warning) depending on the type. Not sure what the best behavior would be...
Currently, the module accepts a resizefs option (bool), that is not supported by all filesystems. IMHO, it doesn't make sense to support a size option for filesystems that don't support resizefs. Given that a size argument is not supported by all mkfs-like commands, we get this table, where:
fstypeis a filesystem type supported by the module.resizeis the ability of the module to resize the filesystem to fill the whole (new) size of the device.no?means a resizing operation is doable for this fstype, but not yet implemented in the module.sizeis the ability of the mkfs-like command to create a filesystem with a specified size.
| fstype | resize | size |
|---|---|---|
| ext2/3/4 | yes | yes |
| reiserfs | no? | yes |
| swap | no | yes |
| lvm | yes | yes |
| f2fs | yes | yes |
| ocfs2 | no? | yes |
| btrfs | no? | yes |
| xfs | yes | no |
| vfat | yes | yes |
(based on manpages on Debian testing)
What is shown here is that almost all fstypes supported by the module may be set with a specific size at creation. But IMO, we should first implement the resizefs feature when doable, i.e. for reiserfs, ocfs2 and btrfs. Fail, rather than warn the user, when the size parameter is not supported for a given filesystem seems fair.
Should the size parameter work only on filesystem creation, or should resizefs resize the filesystem at the given size, at any time ?
I guess size should work both on filesystem creation, and when resizefs: true is specified. But I don't use this module and I don't maintain it, so I won't insist :)
Files identified in the description:
If these files are incorrect, please update the component name section of the description or use the !component bot command.