mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-10-11 09:30:30 +00:00
Make fstab more generic
This commit is contained in:
parent
a3006fbe47
commit
854ab4f202
1 changed files with 22 additions and 14 deletions
|
@ -129,28 +129,36 @@ class FStab(Task):
|
||||||
|
|
||||||
def run(self, info):
|
def run(self, info):
|
||||||
import os.path
|
import os.path
|
||||||
# device = '/dev/sda'
|
|
||||||
# if info.manifest.virtualization == 'pvm':
|
|
||||||
# device = '/dev/xvda'
|
|
||||||
p_map = info.volume.partition_map
|
p_map = info.volume.partition_map
|
||||||
mount_points = [('/', p_map.root)]
|
mount_points = [{'path': '/',
|
||||||
|
'partition': p_map.root,
|
||||||
|
'dump': '1',
|
||||||
|
'pass_num': '1',
|
||||||
|
}]
|
||||||
if hasattr(p_map, 'boot'):
|
if hasattr(p_map, 'boot'):
|
||||||
mount_points.append(('/boot', p_map.boot))
|
mount_points.append({'path': '/boot',
|
||||||
|
'partition': p_map.boot,
|
||||||
|
'dump': '1',
|
||||||
|
'pass_num': '2',
|
||||||
|
})
|
||||||
if hasattr(p_map, 'swap'):
|
if hasattr(p_map, 'swap'):
|
||||||
mount_points.append(('none', p_map.swap))
|
mount_points.append({'path': 'none',
|
||||||
|
'partition': p_map.swap,
|
||||||
|
'dump': '1',
|
||||||
|
'pass_num': '0',
|
||||||
|
})
|
||||||
|
|
||||||
fstab_lines = []
|
fstab_lines = []
|
||||||
for mount_point, partition in mount_points:
|
for mount_point in mount_points:
|
||||||
|
partition = mount_point['partition']
|
||||||
mount_opts = ['defaults']
|
mount_opts = ['defaults']
|
||||||
if partition.filesystem in ['ext2', 'ext3', 'ext4']:
|
fstab_lines.append('UUID={uuid} {mountpoint} {filesystem} {mount_opts} {dump} {pass_num}'
|
||||||
mount_opts.append('barrier=0')
|
|
||||||
if partition.filesystem == 'xfs':
|
|
||||||
mount_opts.append('nobarrier')
|
|
||||||
fstab_lines.append('UUID={uuid} {mountpoint} {filesystem} {mount_opts} 1 1'
|
|
||||||
.format(uuid=partition.get_uuid(),
|
.format(uuid=partition.get_uuid(),
|
||||||
mountpoint=mount_point,
|
mountpoint=mount_point['path'],
|
||||||
filesystem=partition.filesystem,
|
filesystem=partition.filesystem,
|
||||||
mount_opts=','.join(mount_opts)))
|
mount_opts=','.join(mount_opts),
|
||||||
|
dump=mount_point['dump'],
|
||||||
|
pass_num=mount_point['pass_num']))
|
||||||
|
|
||||||
fstab_path = os.path.join(info.root, 'etc/fstab')
|
fstab_path = os.path.join(info.root, 'etc/fstab')
|
||||||
with open(fstab_path, 'w') as fstab:
|
with open(fstab_path, 'w') as fstab:
|
||||||
|
|
Loading…
Add table
Reference in a new issue