diff --git a/build_library/disk_util b/build_library/disk_util index f5fdd6d6fd..e47f0932a2 100755 --- a/build_library/disk_util +++ b/build_library/disk_util @@ -743,18 +743,29 @@ def Tune(options): config, partitions = LoadPartitionConfig(options) GetPartitionTableFromImage(options, config, partitions) part = GetPartition(partitions, options.partition) + action_done = False if not part['image_compat']: raise InvalidLayout("Disk layout is incompatible with existing image") if options.disable2fs_rw is not None: + action_done = True if part.get('fs_type', None) in ('ext2', 'ext4'): Tune2fsReadWrite(options, part, options.disable2fs_rw) elif part.get('fs_type', None) == 'btrfs': ReadWriteSubvol(options, part, options.disable2fs_rw) else: raise Exception("Partition %s is not a ext2 or ext4 or btrfs" % options.partition) - else: + + if options.randomize_uuid is not None: + action_done = True + if part.get('fs_type', None) == 'btrfs': + with PartitionLoop(options, part) as loop_dev: + Sudo(['btrfstune', '-m', loop_dev]) + else: + raise Exception("Partition %s is not btrfs" % options.partition) + + if not action_done: raise Exception("No options specified!") @@ -1059,6 +1070,8 @@ def main(argv): help='disable mounting ext2 filesystems read-write') a.add_argument('--enable2fs_rw', action='store_false', dest='disable2fs_rw', help='re-enable mounting ext2 filesystems read-write') + a.add_argument('--randomize_uuid', action='store_true', default=None, + help='randomize btrfs UUIDs in the partition') a.add_argument('disk_image', help='path to disk image file') a.add_argument('partition', help='number or label of partition to edit') a.set_defaults(func=Tune)