From 29a9fbddb27b00c98eae24782c5bec231e862f5c Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Sat, 30 Oct 2021 17:50:24 +0200 Subject: Failed to create directory structure on subvolume create. Only on subvolume mount. This fixes that. --- archinstall/lib/disk/btrfs.py | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'archinstall') diff --git a/archinstall/lib/disk/btrfs.py b/archinstall/lib/disk/btrfs.py index eaa73af8..ff0b7b58 100644 --- a/archinstall/lib/disk/btrfs.py +++ b/archinstall/lib/disk/btrfs.py @@ -24,8 +24,8 @@ def mount_subvolume(installation, subvolume_location :Union[pathlib.Path, str], target = installation_mountpoint / subvolume_location.relative_to(subvolume_location.anchor) - if not (target).exists(): - (target).mkdir(parents=True) + if not target.exists(): + target.mkdir(parents=True) if glob.glob(str(target/'*')) and force is False: raise DiskError(f"Cannot mount subvolume to {target} because it contains data (non-empty folder target)") @@ -39,13 +39,26 @@ def mount_subvolume(installation, subvolume_location :Union[pathlib.Path, str], return SysCommand(f"mount {mount_information['source']} {target} -o subvol=@{subvolume_location}").exit_code == 0 -def create_subvolume(installation, location :Union[pathlib.Path, str]) -> bool: +def create_subvolume(installation, subvolume_location :Union[pathlib.Path, str]) -> bool: """ This function uses btrfs to create a subvolume. @installation: archinstall.Installer instance - @location: a localized string or path inside the installation / or /boot for instance without specifying /mnt/boot + @subvolume_location: a localized string or path inside the installation / or /boot for instance without specifying /mnt/boot """ - log(f"Creating a subvolume on {installation.target}/{str(location)}", level=logging.INFO) - if (cmd := SysCommand(f"btrfs subvolume create {installation.target}/{str(location)}")).exit_code != 0: - raise DiskError(f"Could not create a subvolume at {installation.target}/{str(location)}: {cmd}") \ No newline at end of file + + installation_mountpoint = installation.target + if type(installation_mountpoint) == str: + installation_mountpoint = pathlib.Path(installation_mountpoint) + # Set up the required physical structure + if type(subvolume_location) == str: + subvolume_location = pathlib.Path(subvolume_location) + + target = installation_mountpoint / subvolume_location.relative_to(subvolume_location.anchor) + + if not target.exists(): + target.mkdir(parents=True) + + log(f"Creating a subvolume on {target}", level=logging.INFO) + if (cmd := SysCommand(f"btrfs subvolume create {target}")).exit_code != 0: + raise DiskError(f"Could not create a subvolume at {target}: {cmd}") \ No newline at end of file -- cgit v1.2.3-70-g09d2