Skip to content

Commit 81f30ab

Browse files
authored
Merge pull request #154 from pcahyna/el7-ext4-whole-disk-rebased
Pass -F to mke2fs for whole disks in RHEL
2 parents a981d8f + c22e0c8 commit 81f30ab

File tree

4 files changed

+33
-1
lines changed

4 files changed

+33
-1
lines changed

library/blivet.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@
3535
description:
3636
- boolean indicating that we should fail rather than implicitly/automatically
3737
removing devices or formatting
38+
diskvolume_mkfs_option_map:
39+
description:
40+
- dict which maps filesystem names to additional mkfs options that should be used
41+
when creating a disk volume (that is, a whole disk filesystem)
3842
3943
author:
4044
- David Lehman ([email protected])
@@ -450,6 +454,19 @@ def _get_device_id(self):
450454
def _type_check(self):
451455
return self._device.raw_device.is_disk
452456

457+
def _get_format(self):
458+
fmt = super(BlivetDiskVolume, self)._get_format()
459+
# pass -F to mke2fs on whole disks in RHEL7
460+
mkfs_options = diskvolume_mkfs_option_map.get(self._volume['fs_type'])
461+
if mkfs_options:
462+
if fmt.create_options:
463+
fmt.create_options += " "
464+
else:
465+
fmt.create_options = ""
466+
fmt.create_options += mkfs_options
467+
468+
return fmt
469+
453470
def _create(self):
454471
self._reformat()
455472

@@ -1111,7 +1128,8 @@ def run_module():
11111128
packages_only=dict(type='bool', required=False, default=False),
11121129
disklabel_type=dict(type='str', required=False, default=None),
11131130
safe_mode=dict(type='bool', required=False, default=True),
1114-
use_partitions=dict(type='bool', required=False, default=True))
1131+
use_partitions=dict(type='bool', required=False, default=True),
1132+
diskvolume_mkfs_option_map=dict(type='dict', required=False, default={}))
11151133

11161134
# seed the result dict in the object
11171135
result = dict(
@@ -1147,6 +1165,9 @@ def run_module():
11471165
global safe_mode
11481166
safe_mode = module.params['safe_mode']
11491167

1168+
global diskvolume_mkfs_option_map
1169+
diskvolume_mkfs_option_map = module.params['diskvolume_mkfs_option_map']
1170+
11501171
b = Blivet()
11511172
b.reset()
11521173
fstab = FSTab(b)

tasks/main-blivet.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
use_partitions: "{{ storage_use_partitions }}"
109109
disklabel_type: "{{ storage_disklabel_type }}"
110110
safe_mode: "{{ storage_safe_mode }}"
111+
diskvolume_mkfs_option_map: "{{ __storage_blivet_diskvolume_mkfs_option_map|d(omit) }}"
111112
register: blivet_output
112113

113114
- debug:

vars/CentOS_7.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,8 @@ blivet_package_list:
66
- libblockdev-lvm
77
- libblockdev-mdraid
88
- libblockdev-swap
9+
# additional options for mkfs when creating a disk volume (whole disk fs)
10+
__storage_blivet_diskvolume_mkfs_option_map:
11+
ext2: '-F'
12+
ext3: '-F'
13+
ext4: '-F'

vars/RedHat_7.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,8 @@ blivet_package_list:
66
- libblockdev-lvm
77
- libblockdev-mdraid
88
- libblockdev-swap
9+
# additional options for mkfs when creating a disk volume (whole disk fs)
10+
__storage_blivet_diskvolume_mkfs_option_map:
11+
ext2: '-F'
12+
ext3: '-F'
13+
ext4: '-F'

0 commit comments

Comments
 (0)