@@ -151,6 +151,8 @@ def _determine_fs_type(
151151 ) -> FilesystemType | None :
152152 try :
153153 if partition .fileSystem :
154+ if partition .fileSystem .type == FilesystemType .LinuxSwap .parted_value :
155+ return FilesystemType .LinuxSwap
154156 return FilesystemType (partition .fileSystem .type )
155157 elif lsblk_info is not None :
156158 return FilesystemType (lsblk_info .fstype ) if lsblk_info .fstype else None
@@ -259,6 +261,7 @@ def format(
259261 additional_parted_options : list [str ] = []
260262 ) -> None :
261263 mkfs_type = fs_type .value
264+ command = None
262265 options = []
263266
264267 match fs_type :
@@ -277,10 +280,15 @@ def format(
277280 options .append ('--fast' )
278281 case FilesystemType .Reiserfs :
279282 pass
283+ case FilesystemType .LinuxSwap :
284+ command = "mkswap"
280285 case _:
281286 raise UnknownFilesystemFormat (f'Filetype "{ fs_type .value } " is not supported' )
282287
283- cmd = [f'mkfs.{ mkfs_type } ' , * options , * additional_parted_options , str (path )]
288+ if not command :
289+ command = f'mkfs.{ mkfs_type } '
290+
291+ cmd = [command , * options , * additional_parted_options , str (path )]
284292
285293 debug ('Formatting filesystem:' , ' ' .join (cmd ))
286294
@@ -536,7 +544,8 @@ def _setup_partition(
536544 length = length_sector .value
537545 )
538546
539- filesystem = FileSystem (type = part_mod .safe_fs_type .value , geometry = geometry )
547+ fs_value = part_mod .safe_fs_type .parted_value
548+ filesystem = FileSystem (type = fs_value , geometry = geometry )
540549
541550 partition = Partition (
542551 disk = disk ,
@@ -549,7 +558,7 @@ def _setup_partition(
549558 partition .setFlag (flag .flag_id )
550559
551560 debug (f'\t Type: { part_mod .type .value } ' )
552- debug (f'\t Filesystem: { part_mod . safe_fs_type . value } ' )
561+ debug (f'\t Filesystem: { fs_value } ' )
553562 debug (f'\t Geometry: { start_sector .value } start sector, { length_sector .value } length' )
554563
555564 try :
@@ -723,6 +732,13 @@ def partition(
723732
724733 disk .commit ()
725734
735+ @staticmethod
736+ def swapon (path : Path ) -> None :
737+ try :
738+ SysCommand (['swapon' , str (path )])
739+ except SysCallError as err :
740+ raise DiskError (f'Could not enable swap { path } :\n { err .message } ' )
741+
726742 def mount (
727743 self ,
728744 dev_path : Path ,
0 commit comments