From 854ab4f20230aa386e6939e2d1d832012e4860af Mon Sep 17 00:00:00 2001 From: Anders Ingemann Date: Sun, 6 Oct 2013 13:40:27 +0200 Subject: [PATCH] Make fstab more generic --- common/tasks/filesystem.py | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/common/tasks/filesystem.py b/common/tasks/filesystem.py index 76e7604..80288a7 100644 --- a/common/tasks/filesystem.py +++ b/common/tasks/filesystem.py @@ -129,28 +129,36 @@ class FStab(Task): def run(self, info): import os.path - # device = '/dev/sda' - # if info.manifest.virtualization == 'pvm': - # device = '/dev/xvda' 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'): - 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'): - mount_points.append(('none', p_map.swap)) + mount_points.append({'path': 'none', + 'partition': p_map.swap, + 'dump': '1', + 'pass_num': '0', + }) fstab_lines = [] - for mount_point, partition in mount_points: + for mount_point in mount_points: + partition = mount_point['partition'] mount_opts = ['defaults'] - if partition.filesystem in ['ext2', 'ext3', 'ext4']: - mount_opts.append('barrier=0') - if partition.filesystem == 'xfs': - mount_opts.append('nobarrier') - fstab_lines.append('UUID={uuid} {mountpoint} {filesystem} {mount_opts} 1 1' + fstab_lines.append('UUID={uuid} {mountpoint} {filesystem} {mount_opts} {dump} {pass_num}' .format(uuid=partition.get_uuid(), - mountpoint=mount_point, + mountpoint=mount_point['path'], 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') with open(fstab_path, 'w') as fstab: