commit
7e096e4f6d
|
|
@ -252,7 +252,7 @@ class BlockDevice:
|
||||||
# I'm placing the encryption password on a BlockDevice level.
|
# I'm placing the encryption password on a BlockDevice level.
|
||||||
|
|
||||||
def __repr__(self, *args, **kwargs):
|
def __repr__(self, *args, **kwargs):
|
||||||
return f"BlockDevice({self.device}, size={self.size}GB, free_space={'+'.join(part[2] for part in self.free_space)}, bus_type={self.bus_type})"
|
return f"BlockDevice({self.device_or_backfile}, size={self.size}GB, free_space={'+'.join(part[2] for part in self.free_space)}, bus_type={self.bus_type})"
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
for partition in self.partitions:
|
for partition in self.partitions:
|
||||||
|
|
@ -293,23 +293,33 @@ class BlockDevice:
|
||||||
return device['pttype']
|
return device['pttype']
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device(self):
|
def device_or_backfile(self):
|
||||||
"""
|
"""
|
||||||
Returns the actual device-endpoint of the BlockDevice.
|
Returns the actual device-endpoint of the BlockDevice.
|
||||||
If it's a loop-back-device it returns the back-file,
|
If it's a loop-back-device it returns the back-file,
|
||||||
If it's a ATA-drive it returns the /dev/X device
|
For other types it return self.device
|
||||||
And if it's a crypto-device it returns the parent device
|
|
||||||
"""
|
"""
|
||||||
if "type" not in self.info:
|
|
||||||
raise DiskError(f'Could not locate backplane info for "{self.path}"')
|
|
||||||
|
|
||||||
if self.info['type'] == 'loop':
|
if self.info['type'] == 'loop':
|
||||||
for drive in json.loads(SysCommand(['losetup', '--json']).decode('UTF_8'))['loopdevices']:
|
for drive in json.loads(SysCommand(['losetup', '--json']).decode('UTF_8'))['loopdevices']:
|
||||||
if not drive['name'] == self.path:
|
if not drive['name'] == self.path:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
return drive['back-file']
|
return drive['back-file']
|
||||||
elif self.info['type'] == 'disk':
|
else:
|
||||||
|
return self.device
|
||||||
|
|
||||||
|
@property
|
||||||
|
def device(self):
|
||||||
|
"""
|
||||||
|
Returns the device file of the BlockDevice.
|
||||||
|
If it's a loop-back-device it returns the /dev/X device,
|
||||||
|
If it's a ATA-drive it returns the /dev/X device
|
||||||
|
And if it's a crypto-device it returns the parent device
|
||||||
|
"""
|
||||||
|
if "type" not in self.info:
|
||||||
|
raise DiskError(f'Could not locate backplane info for "{self.path}"')
|
||||||
|
|
||||||
|
if self.info['type'] in ['disk','loop']:
|
||||||
return self.path
|
return self.path
|
||||||
elif self.info['type'][:4] == 'raid':
|
elif self.info['type'][:4] == 'raid':
|
||||||
# This should catch /dev/md## raid devices
|
# This should catch /dev/md## raid devices
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,7 @@ class Boot:
|
||||||
self.session = SysCommandWorker([
|
self.session = SysCommandWorker([
|
||||||
'/usr/bin/systemd-nspawn',
|
'/usr/bin/systemd-nspawn',
|
||||||
'-D', self.instance.target,
|
'-D', self.instance.target,
|
||||||
|
'--timezone=off',
|
||||||
'-b',
|
'-b',
|
||||||
'--machine', self.container_name
|
'--machine', self.container_name
|
||||||
])
|
])
|
||||||
|
|
|
||||||
|
|
@ -674,7 +674,7 @@ def manage_new_and_existing_partitions(block_device :BlockDevice) -> dict:
|
||||||
if input(f"{block_device} contains queued partitions, this will remove those, are you sure? y/N: ").strip().lower() in ('', 'n'):
|
if input(f"{block_device} contains queued partitions, this will remove those, are you sure? y/N: ").strip().lower() in ('', 'n'):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
block_device_struct["partitions"] = suggest_single_disk_layout(block_device)[block_device]
|
block_device_struct.update( suggest_single_disk_layout(block_device)[block_device.path] )
|
||||||
elif task is None:
|
elif task is None:
|
||||||
return block_device_struct
|
return block_device_struct
|
||||||
else:
|
else:
|
||||||
|
|
@ -730,7 +730,10 @@ def manage_new_and_existing_partitions(block_device :BlockDevice) -> dict:
|
||||||
block_device_struct["partitions"][block_device_struct["partitions"].index(partition)]['boot'] = not block_device_struct["partitions"][block_device_struct["partitions"].index(partition)].get('boot', False)
|
block_device_struct["partitions"][block_device_struct["partitions"].index(partition)]['boot'] = not block_device_struct["partitions"][block_device_struct["partitions"].index(partition)].get('boot', False)
|
||||||
|
|
||||||
elif task == "Set desired filesystem for a partition":
|
elif task == "Set desired filesystem for a partition":
|
||||||
if (partition := generic_select(block_device_struct["partitions"], 'Select which partition to set a filesystem on: ', options_output=False)):
|
if not block_device_struct["partitions"]:
|
||||||
|
log("No partitions found. Create some partitions first", level=logging.WARNING, fg='yellow')
|
||||||
|
continue
|
||||||
|
elif (partition := generic_select(block_device_struct["partitions"], 'Select which partition to set a filesystem on: ', options_output=False)):
|
||||||
if not block_device_struct["partitions"][block_device_struct["partitions"].index(partition)].get('filesystem', None):
|
if not block_device_struct["partitions"][block_device_struct["partitions"].index(partition)].get('filesystem', None):
|
||||||
block_device_struct["partitions"][block_device_struct["partitions"].index(partition)]['filesystem'] = {}
|
block_device_struct["partitions"][block_device_struct["partitions"].index(partition)]['filesystem'] = {}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue