Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/disk
diff options
context:
space:
mode:
authorcodefiles <11915375+codefiles@users.noreply.github.com>2023-09-23 20:51:20 -0400
committerGitHub <noreply@github.com>2023-09-24 10:51:20 +1000
commitab5de3e2e6f5afba81d441cc9a46ebadaad88732 (patch)
treefced4b2704d398d82daccc482545274efac191bd /archinstall/lib/disk
parentf078c74692e64e4316107175b3b0d8f021fff3ba (diff)
Add support for loop devices (#2097)
Diffstat (limited to 'archinstall/lib/disk')
-rw-r--r--archinstall/lib/disk/device_handler.py15
-rw-r--r--archinstall/lib/disk/device_model.py5
2 files changed, 17 insertions, 3 deletions
diff --git a/archinstall/lib/disk/device_handler.py b/archinstall/lib/disk/device_handler.py
index 494319a1..9646103f 100644
--- a/archinstall/lib/disk/device_handler.py
+++ b/archinstall/lib/disk/device_handler.py
@@ -10,7 +10,7 @@ from typing import List, Dict, Any, Optional, TYPE_CHECKING
from parted import ( # type: ignore
Disk, Geometry, FileSystem,
PartitionException, DiskLabelException,
- getAllDevices, freshDisk, Partition, Device
+ getDevice, getAllDevices, freshDisk, Partition, Device
)
from .device_model import (
@@ -45,7 +45,18 @@ class DeviceHandler(object):
def load_devices(self):
block_devices = {}
- for device in getAllDevices():
+ devices = getAllDevices()
+
+ try:
+ loop_devices = SysCommand(['losetup', '-a'])
+ except SysCallError as err:
+ debug(f'Failed to get loop devices: {err}')
+ else:
+ for ld_info in str(loop_devices).splitlines():
+ loop_device = getDevice(ld_info.split(':', maxsplit=1)[0])
+ devices.append(loop_device)
+
+ for device in devices:
if get_lsblk_info(device.path).type == 'rom':
continue
diff --git a/archinstall/lib/disk/device_model.py b/archinstall/lib/disk/device_model.py
index ad2628ae..b520ad1b 100644
--- a/archinstall/lib/disk/device_model.py
+++ b/archinstall/lib/disk/device_model.py
@@ -374,7 +374,10 @@ class _DeviceInfo:
@classmethod
def from_disk(cls, disk: Disk) -> _DeviceInfo:
device = disk.device
- device_type = parted.devices[device.type]
+ if device.type == 18:
+ device_type = 'loop'
+ else:
+ device_type = parted.devices[device.type]
sector_size = Size(device.sectorSize, Unit.B)
free_space = [DeviceGeometry(g, sector_size) for g in disk.getFreeSpaceRegions()]