mirror of
https://github.com/flatcar/scripts.git
synced 2025-11-30 15:02:06 +01:00
disk_util: differentiate between partition and FS labels
This commit is contained in:
parent
e23d10223a
commit
08ed31d70d
@ -11,6 +11,7 @@
|
|||||||
"base":{
|
"base":{
|
||||||
"1":{
|
"1":{
|
||||||
"label":"EFI-SYSTEM",
|
"label":"EFI-SYSTEM",
|
||||||
|
"fs_label":"EFI-SYSTEM",
|
||||||
"type":"efi",
|
"type":"efi",
|
||||||
"blocks":"262144",
|
"blocks":"262144",
|
||||||
"fs_type":"vfat",
|
"fs_type":"vfat",
|
||||||
@ -47,6 +48,7 @@
|
|||||||
},
|
},
|
||||||
"6":{
|
"6":{
|
||||||
"label":"OEM",
|
"label":"OEM",
|
||||||
|
"fs_label":"OEM",
|
||||||
"type":"data",
|
"type":"data",
|
||||||
"blocks":"262144",
|
"blocks":"262144",
|
||||||
"fs_type":"ext4",
|
"fs_type":"ext4",
|
||||||
@ -64,6 +66,7 @@
|
|||||||
},
|
},
|
||||||
"9":{
|
"9":{
|
||||||
"label":"ROOT",
|
"label":"ROOT",
|
||||||
|
"fs_label":"ROOT",
|
||||||
"type":"coreos-resize",
|
"type":"coreos-resize",
|
||||||
"blocks":"4427776",
|
"blocks":"4427776",
|
||||||
"fs_type":"ext4",
|
"fs_type":"ext4",
|
||||||
@ -90,30 +93,35 @@
|
|||||||
},
|
},
|
||||||
"9":{
|
"9":{
|
||||||
"label":"ROOT",
|
"label":"ROOT",
|
||||||
|
"fs_label":"ROOT",
|
||||||
"blocks":"12943360"
|
"blocks":"12943360"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"vm":{
|
"vm":{
|
||||||
"9":{
|
"9":{
|
||||||
"label":"ROOT",
|
"label":"ROOT",
|
||||||
|
"fs_label":"ROOT",
|
||||||
"blocks":"12943360"
|
"blocks":"12943360"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"azure":{
|
"azure":{
|
||||||
"9":{
|
"9":{
|
||||||
"label":"ROOT",
|
"label":"ROOT",
|
||||||
|
"fs_label":"ROOT",
|
||||||
"blocks":"58875904"
|
"blocks":"58875904"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"vagrant":{
|
"vagrant":{
|
||||||
"9":{
|
"9":{
|
||||||
"label":"ROOT",
|
"label":"ROOT",
|
||||||
|
"fs_label":"ROOT",
|
||||||
"blocks":"33845248"
|
"blocks":"33845248"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"onmetal":{
|
"onmetal":{
|
||||||
"7":{
|
"7":{
|
||||||
"label":"config-2",
|
"label":"config-2",
|
||||||
|
"fs_label":"config-2",
|
||||||
"type":"data",
|
"type":"data",
|
||||||
"fs_type":"ext2"
|
"fs_type":"ext2"
|
||||||
}
|
}
|
||||||
@ -145,6 +153,7 @@
|
|||||||
},
|
},
|
||||||
"9":{
|
"9":{
|
||||||
"label":"ROOT",
|
"label":"ROOT",
|
||||||
|
"fs_label":"ROOT",
|
||||||
"type":"4f68bce3-e8cd-4db1-96e7-fbcaf984b709",
|
"type":"4f68bce3-e8cd-4db1-96e7-fbcaf984b709",
|
||||||
"blocks":"6291456"
|
"blocks":"6291456"
|
||||||
}
|
}
|
||||||
@ -152,6 +161,7 @@
|
|||||||
"secure_demo":{
|
"secure_demo":{
|
||||||
"1":{
|
"1":{
|
||||||
"label":"EFI-SYSTEM",
|
"label":"EFI-SYSTEM",
|
||||||
|
"fs_label":"EFI-SYSTEM",
|
||||||
"type":"efi",
|
"type":"efi",
|
||||||
"blocks":"2097152",
|
"blocks":"2097152",
|
||||||
"fs_type":"vfat",
|
"fs_type":"vfat",
|
||||||
@ -186,6 +196,7 @@
|
|||||||
"interoute":{
|
"interoute":{
|
||||||
"9":{
|
"9":{
|
||||||
"label":"ROOT",
|
"label":"ROOT",
|
||||||
|
"fs_label":"ROOT",
|
||||||
"blocks":"33845248"
|
"blocks":"33845248"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -45,7 +45,7 @@ def LoadPartitionConfig(options):
|
|||||||
valid_layout_keys = set((
|
valid_layout_keys = set((
|
||||||
'_comment', 'type', 'num', 'label', 'blocks', 'block_size', 'fs_blocks',
|
'_comment', 'type', 'num', 'label', 'blocks', 'block_size', 'fs_blocks',
|
||||||
'fs_block_size', 'fs_type', 'features', 'uuid', 'part_alignment', 'mount',
|
'fs_block_size', 'fs_type', 'features', 'uuid', 'part_alignment', 'mount',
|
||||||
'binds', 'fs_subvolume', 'fs_bytes_per_inode', 'fs_inode_size'))
|
'binds', 'fs_subvolume', 'fs_bytes_per_inode', 'fs_inode_size', 'fs_label'))
|
||||||
integer_layout_keys = set((
|
integer_layout_keys = set((
|
||||||
'blocks', 'block_size', 'fs_blocks', 'fs_block_size', 'part_alignment',
|
'blocks', 'block_size', 'fs_blocks', 'fs_block_size', 'part_alignment',
|
||||||
'fs_bytes_per_inode', 'fs_inode_size'))
|
'fs_bytes_per_inode', 'fs_inode_size'))
|
||||||
@ -388,9 +388,10 @@ def FormatBtrfs(part, device):
|
|||||||
part: dict defining the partition
|
part: dict defining the partition
|
||||||
device: name of the block device to format
|
device: name of the block device to format
|
||||||
"""
|
"""
|
||||||
Sudo(['mkfs.btrfs', '--byte-count', part['fs_bytes'],
|
cmd = ['mkfs.btrfs', '--byte-count', part['fs_bytes']]
|
||||||
'--label', part['label'],
|
if 'fs_label' in part:
|
||||||
device])
|
cmd += ['--label', part['fs_label']]
|
||||||
|
Sudo(cmd + [device])
|
||||||
|
|
||||||
if part.get('fs_subvolume', None):
|
if part.get('fs_subvolume', None):
|
||||||
btrfs_mount = tempfile.mkdtemp()
|
btrfs_mount = tempfile.mkdtemp()
|
||||||
@ -420,7 +421,10 @@ def FormatExt(part, device):
|
|||||||
device,
|
device,
|
||||||
part['fs_blocks']])
|
part['fs_blocks']])
|
||||||
|
|
||||||
tune_cmd = ['tune2fs', '-L', part['label'], '-e', 'remount-ro']
|
tune_cmd = ['tune2fs', '-e', 'remount-ro']
|
||||||
|
|
||||||
|
if 'fs_label' in part:
|
||||||
|
tune_cmd += ['-L', part['fs_label']]
|
||||||
|
|
||||||
if part['type'] == 'coreos-usr':
|
if part['type'] == 'coreos-usr':
|
||||||
tune_cmd += ['-U', 'clear',
|
tune_cmd += ['-U', 'clear',
|
||||||
@ -442,10 +446,10 @@ def FormatFat(part, device):
|
|||||||
vfat_block_size = 1024
|
vfat_block_size = 1024
|
||||||
vfat_blocks = part['bytes'] // vfat_block_size
|
vfat_blocks = part['bytes'] // vfat_block_size
|
||||||
|
|
||||||
Sudo(['mkfs.vfat', '-n', part['label'],
|
cmd = ['mkfs.vfat']
|
||||||
device,
|
if 'fs_label' in part:
|
||||||
vfat_blocks],
|
cmd += ['-n', part['fs_label']]
|
||||||
stdout_null=True)
|
Sudo(cmd + [device, vfat_blocks], stdout_null=True)
|
||||||
|
|
||||||
if 'syslinux' in part.get('features', []):
|
if 'syslinux' in part.get('features', []):
|
||||||
# Install using extlinux so we can operate on the mounted filesystem and
|
# Install using extlinux so we can operate on the mounted filesystem and
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user