Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/disk/helpers.py
diff options
context:
space:
mode:
authorWerner Llácer <wllacer@gmail.com>2021-12-31 13:47:41 +0100
committerGitHub <noreply@github.com>2021-12-31 13:47:41 +0100
commit7f9b7991e902489efb3501a98a7d6998ca15a0a5 (patch)
tree96766f566987f7cb042e7a7a2a132182d3fc1018 /archinstall/lib/disk/helpers.py
parentc3e2b993160930f7f74f1e822199914b0eeeead9 (diff)
Btrfs2 (#787)
* All the changes needed to make btrfs subvolumes work. It boils down to two points; the handling of the addressing of subvolumes re. physical partitions, and the small changes at the bootloader level * We added a new script only_hd for testing purposes. It only handles hadrd drive management * restoring an escape hatch during subvolume processing * hipercommented manage_btrfs_subvolumes * Ready to be able to select and process options in subvolume mounting * Separte nodatacow processing * Solving a flake8 complain * Use of bind names @ get_filesystem_type * compress mount option bypass * Preparations for encryption handling * Compatibility to master version re. encrypted btrfs volumes * Now we can create subvolumes and mountpoints inside an encrypted btrfs partition * changes for entries file generation with systemd-bootctl * flake8 corrections plus some comments Co-authored-by: Anton Hvornum <anton@hvornum.se>
Diffstat (limited to 'archinstall/lib/disk/helpers.py')
-rw-r--r--archinstall/lib/disk/helpers.py24
1 files changed, 20 insertions, 4 deletions
diff --git a/archinstall/lib/disk/helpers.py b/archinstall/lib/disk/helpers.py
index 8e6a79e4..ba29744f 100644
--- a/archinstall/lib/disk/helpers.py
+++ b/archinstall/lib/disk/helpers.py
@@ -123,9 +123,19 @@ def harddrive(size=None, model=None, fuzzy=False):
return collection[drive]
+def split_bind_name(path :Union[pathlib.Path, str]) -> list:
+ # we check for the bind notation. if exist we'll only use the "true" device path
+ if '[' in str(path) : # is a bind path (btrfs subvolume path)
+ device_path, bind_path = str(path).split('[')
+ bind_path = bind_path[:-1].strip() # remove the ]
+ else:
+ device_path = path
+ bind_path = None
+ return device_path,bind_path
def get_mount_info(path :Union[pathlib.Path, str], traverse=False, return_real_path=False) -> dict:
- for traversal in list(map(str, [str(path)] + list(pathlib.Path(str(path)).parents))):
+ device_path,bind_path = split_bind_name(path)
+ for traversal in list(map(str, [str(device_path)] + list(pathlib.Path(str(device_path)).parents))):
try:
log(f"Getting mount information for device path {traversal}", level=logging.INFO)
output = SysCommand(f'/usr/bin/findmnt --json {traversal}').decode('UTF-8')
@@ -141,6 +151,10 @@ def get_mount_info(path :Union[pathlib.Path, str], traverse=False, return_real_p
raise DiskError(f"Could not get mount information for device path {path}")
output = json.loads(output)
+ # for btrfs partitions we redice the filesystem list to the one with the source equals to the parameter
+ # i.e. the subvolume filesystem we're searching for
+ if 'filesystems' in output and len(output['filesystems']) > 1 and bind_path is not None:
+ output['filesystems'] = [entry for entry in output['filesystems'] if entry['source'] == str(path)]
if 'filesystems' in output:
if len(output['filesystems']) > 1:
raise DiskError(f"Path '{path}' contains multiple mountpoints: {output['filesystems']}")
@@ -180,8 +194,9 @@ def get_partitions_in_use(mountpoint) -> list:
def get_filesystem_type(path):
+ device_name, bind_name = split_bind_name(path)
try:
- return SysCommand(f"blkid -o value -s TYPE {path}").decode('UTF-8').strip()
+ return SysCommand(f"blkid -o value -s TYPE {device_name}").decode('UTF-8').strip()
except SysCallError:
return None
@@ -217,12 +232,13 @@ def partprobe():
time.sleep(5)
def convert_device_to_uuid(path :str) -> str:
+ device_name, bind_name = split_bind_name(path)
for i in range(storage['DISK_RETRY_ATTEMPTS']):
partprobe()
-
+
# TODO: Convert lsblk to blkid
# (lsblk supports BlockDev and Partition UUID grabbing, blkid requires you to pick PTUUID and PARTUUID)
- output = json.loads(SysCommand(f"lsblk --json -o+UUID {path}").decode('UTF-8'))
+ output = json.loads(SysCommand(f"lsblk --json -o+UUID {device_name}").decode('UTF-8'))
for device in output['blockdevices']:
if (dev_uuid := device.get('uuid', None)):