( self, fs_type: FilesystemType, path: Path, additional_parted_options: list[str] = [], )
| 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, |
no test coverage detected