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

Method format

archinstall/lib/disk/device_handler.py:233–274  ·  view source on GitHub ↗
(
		self,
		fs_type: FilesystemType,
		path: Path,
		additional_parted_options: list[str] = [],
	)

Source from the content-addressed store, hash-verified

231 return subvol_infos
232
233 def format(
234 self,
235 fs_type: FilesystemType,
236 path: Path,
237 additional_parted_options: list[str] = [],
238 ) -> None:
239 mkfs_type = fs_type.value
240 command = None
241 options = []
242
243 match fs_type:
244 case FilesystemType.BTRFS | FilesystemType.XFS:
245 # Force overwrite
246 options.append('-f')
247 case FilesystemType.F2FS:
248 options.append('-f')
249 options.extend(('-O', 'extra_attr'))
250 case FilesystemType.EXT2 | FilesystemType.EXT3 | FilesystemType.EXT4:
251 # Force create
252 options.append('-F')
253 case _ if fs_type.is_fat():
254 mkfs_type = 'fat'
255 # Set FAT size
256 options.extend(('-F', fs_type.value.removeprefix(mkfs_type)))
257 case FilesystemType.LINUX_SWAP:
258 command = 'mkswap'
259 case _:
260 raise UnknownFilesystemFormat(f'Filetype "{fs_type.value}" is not supported')
261
262 if not command:
263 command = f'mkfs.{mkfs_type}'
264
265 cmd = [command, *options, *additional_parted_options, str(path)]
266
267 debug('Formatting filesystem:', ' '.join(cmd))
268
269 try:
270 SysCommand(cmd)
271 except SysCallError as err:
272 msg = f'Could not format {path} with {fs_type.value}: {err.message}'
273 error(msg)
274 raise DiskError(msg) from err
275
276 def encrypt(
277 self,

Callers 15

format_encryptedMethod · 0.95
_share_log_commandFunction · 0.80
preview_textMethod · 0.80
select_seat_accessFunction · 0.80
__exit__Method · 0.80
_create_bls_entriesMethod · 0.80
save_configFunction · 0.80
_prev_disk_configMethod · 0.80
_prev_pacman_configMethod · 0.80

Calls 6

debugFunction · 0.90
SysCommandClass · 0.90
errorFunction · 0.90
DiskErrorClass · 0.90
is_fatMethod · 0.80

Tested by

no test coverage detected