Skip to content

Commit

Permalink
Merge pull request #154 from pcahyna/el7-ext4-whole-disk-rebased
Browse files Browse the repository at this point in the history
Pass -F to mke2fs for whole disks in RHEL
  • Loading branch information
pcahyna authored Aug 23, 2020
2 parents a981d8f + c22e0c8 commit 81f30ab
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
23 changes: 22 additions & 1 deletion library/blivet.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
description:
- boolean indicating that we should fail rather than implicitly/automatically
removing devices or formatting
diskvolume_mkfs_option_map:
description:
- dict which maps filesystem names to additional mkfs options that should be used
when creating a disk volume (that is, a whole disk filesystem)
author:
- David Lehman ([email protected])
Expand Down Expand Up @@ -450,6 +454,19 @@ def _get_device_id(self):
def _type_check(self):
return self._device.raw_device.is_disk

def _get_format(self):
fmt = super(BlivetDiskVolume, self)._get_format()
# pass -F to mke2fs on whole disks in RHEL7
mkfs_options = diskvolume_mkfs_option_map.get(self._volume['fs_type'])
if mkfs_options:
if fmt.create_options:
fmt.create_options += " "
else:
fmt.create_options = ""
fmt.create_options += mkfs_options

return fmt

def _create(self):
self._reformat()

Expand Down Expand Up @@ -1111,7 +1128,8 @@ def run_module():
packages_only=dict(type='bool', required=False, default=False),
disklabel_type=dict(type='str', required=False, default=None),
safe_mode=dict(type='bool', required=False, default=True),
use_partitions=dict(type='bool', required=False, default=True))
use_partitions=dict(type='bool', required=False, default=True),
diskvolume_mkfs_option_map=dict(type='dict', required=False, default={}))

# seed the result dict in the object
result = dict(
Expand Down Expand Up @@ -1147,6 +1165,9 @@ def run_module():
global safe_mode
safe_mode = module.params['safe_mode']

global diskvolume_mkfs_option_map
diskvolume_mkfs_option_map = module.params['diskvolume_mkfs_option_map']

b = Blivet()
b.reset()
fstab = FSTab(b)
Expand Down
1 change: 1 addition & 0 deletions tasks/main-blivet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
use_partitions: "{{ storage_use_partitions }}"
disklabel_type: "{{ storage_disklabel_type }}"
safe_mode: "{{ storage_safe_mode }}"
diskvolume_mkfs_option_map: "{{ __storage_blivet_diskvolume_mkfs_option_map|d(omit) }}"
register: blivet_output

- debug:
Expand Down
5 changes: 5 additions & 0 deletions vars/CentOS_7.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@ blivet_package_list:
- libblockdev-lvm
- libblockdev-mdraid
- libblockdev-swap
# additional options for mkfs when creating a disk volume (whole disk fs)
__storage_blivet_diskvolume_mkfs_option_map:
ext2: '-F'
ext3: '-F'
ext4: '-F'
5 changes: 5 additions & 0 deletions vars/RedHat_7.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@ blivet_package_list:
- libblockdev-lvm
- libblockdev-mdraid
- libblockdev-swap
# additional options for mkfs when creating a disk volume (whole disk fs)
__storage_blivet_diskvolume_mkfs_option_map:
ext2: '-F'
ext3: '-F'
ext4: '-F'

0 comments on commit 81f30ab

Please sign in to comment.