community.general icon indicating copy to clipboard operation
community.general copied to clipboard

Add size argument support to filesystem task

Open ymartin59 opened this issue 5 years ago • 10 comments
trafficstars

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

ymartin59 avatar Aug 18 '20 19:08 ymartin59

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.

click here for bot help

ansibullbot avatar Aug 18 '20 19:08 ansibullbot

cc @MorrisA @abulimov @bcoca @d-little @flynn1973 @gforster @kairoaraujo @marvin-sinister @mator @molekuul @pilou- @ramooncamacho @wtcross click here for bot help

ansibullbot avatar Aug 18 '20 19:08 ansibullbot

+label waiting_on_contributor

aminvakil avatar May 01 '21 15:05 aminvakil

cc @quidame click here for bot help

ansibullbot avatar May 01 '21 15:05 ansibullbot

@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.

mator avatar May 02 '21 10:05 mator

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...

felixfontein avatar May 02 '21 11:05 felixfontein

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:

  • fstype is a filesystem type supported by the module.
  • resize is 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.
  • size is 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.

quidame avatar May 02 '21 23:05 quidame

Should the size parameter work only on filesystem creation, or should resizefs resize the filesystem at the given size, at any time ?

quidame avatar May 02 '21 23:05 quidame

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 :)

felixfontein avatar May 05 '21 20:05 felixfontein

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.

click here for bot help

ansibullbot avatar Nov 11 '22 02:11 ansibullbot