mirror of
https://github.com/flatcar/scripts.git
synced 2025-11-28 22:12:10 +01:00
build_library/disk_util: Add btrfs UUID randomizing
This is necessary if we want to mount a copy of the production image.
This commit is contained in:
parent
e6700fcc5c
commit
706356c459
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user