MCPcopy Index your code
hub / github.com/archlinux/archinstall / mount

Function mount

archinstall/lib/disk/utils.py:139–173  ·  view source on GitHub ↗
(
	dev_path: Path,
	target_mountpoint: Path,
	mount_fs: str | None = None,
	create_target_mountpoint: bool = True,
	options: list[str] = [],
)

Source from the content-addressed store, hash-verified

137
138
139def mount(
140 dev_path: Path,
141 target_mountpoint: Path,
142 mount_fs: str | None = None,
143 create_target_mountpoint: bool = True,
144 options: list[str] = [],
145) -> None:
146 if create_target_mountpoint and not target_mountpoint.exists():
147 target_mountpoint.mkdir(parents=True, exist_ok=True)
148
149 if not target_mountpoint.exists():
150 raise ValueError('Target mountpoint does not exist')
151
152 lsblk_info = get_lsblk_info(dev_path)
153 if target_mountpoint in lsblk_info.mountpoints:
154 info(f'Device already mounted at {target_mountpoint}')
155 return
156
157 cmd = ['mount']
158
159 if len(options):
160 cmd.extend(('-o', ','.join(options)))
161 if mount_fs:
162 cmd.extend(('-t', mount_fs))
163
164 cmd.extend((str(dev_path), str(target_mountpoint)))
165
166 command = ' '.join(cmd)
167
168 debug(f'Mounting {dev_path}: {command}')
169
170 try:
171 SysCommand(command)
172 except SysCallError as err:
173 raise DiskError(f'Could not mount {dev_path}: {command}\n{err.message}')
174
175
176def umount(mountpoint: Path, recursive: bool = False) -> None:

Callers 8

_mount_partitionMethod · 0.90
_mount_lvm_volMethod · 0.90
_mount_luks_partitionMethod · 0.90
_mount_luks_volumeMethod · 0.90
_mount_btrfs_subvolMethod · 0.90
get_btrfs_infoMethod · 0.90
create_btrfs_volumesMethod · 0.90

Calls 6

infoFunction · 0.90
debugFunction · 0.90
SysCommandClass · 0.90
DiskErrorClass · 0.90
get_lsblk_infoFunction · 0.85
existsMethod · 0.45

Tested by

no test coverage detected