Move swapon() to disk.utils (#4233)

This commit is contained in:
codefiles 2026-02-15 22:43:10 -05:00 committed by GitHub
parent 8148b1d9bf
commit 35c2ff3ef5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 9 deletions

View File

@ -763,13 +763,6 @@ class DeviceHandler:
if filtered_part:
self.udev_sync()
@staticmethod
def swapon(path: Path) -> None:
try:
SysCommand(['swapon', str(path)])
except SysCallError as err:
raise DiskError(f'Could not enable swap {path}:\n{err.message}')
def detect_pre_mounted_mods(self, base_mountpoint: Path) -> list[DeviceModification]:
part_mods: dict[Path, list[PartitionModification]] = {}

View File

@ -163,3 +163,10 @@ def umount(mountpoint: Path, recursive: bool = False) -> None:
for path in lsblk_info.mountpoints:
debug(f'Unmounting mountpoint: {path}')
SysCommand(cmd + [str(path)])
def swapon(path: Path) -> None:
try:
SysCommand(['swapon', str(path)])
except SysCallError as err:
raise DiskError(f'Could not enable swap {path}:\n{err.message}')

View File

@ -16,7 +16,7 @@ from typing import Any, Self
from archinstall.lib.disk.device_handler import device_handler
from archinstall.lib.disk.fido import Fido2
from archinstall.lib.disk.utils import get_lsblk_by_mountpoint, get_lsblk_info, mount
from archinstall.lib.disk.utils import get_lsblk_by_mountpoint, get_lsblk_info, mount, swapon
from archinstall.lib.models.application import ZramAlgorithm
from archinstall.lib.models.device import (
DiskEncryption,
@ -371,7 +371,7 @@ class Installer:
part_mod.mount_options,
)
elif part_mod.is_swap():
device_handler.swapon(part_mod.dev_path)
swapon(part_mod.dev_path)
def _mount_lvm_vol(self, volume: LvmVolume) -> None:
if volume.fs_type != FilesystemType.Btrfs: