From 1a039ea07ae7687e8d83ad12af57b98bde9ee4d2 Mon Sep 17 00:00:00 2001 From: Papoteur Date: Sat, 7 Sep 2019 16:54:02 +0200 Subject: Add exfat format --- lib/raw_format.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'lib/raw_format.py') diff --git a/lib/raw_format.py b/lib/raw_format.py index 0cce0e9..54e7bcb 100755 --- a/lib/raw_format.py +++ b/lib/raw_format.py @@ -97,7 +97,10 @@ def raw_format(device_path, fstype, volume_label, uid, gid): sys.exit(5) # fstype - fs = parted.FileSystem(type=fstype, geometry=geometry) + _fstype = fstype + if _fstype == "exfat": + _fstype = "ntfs" + fs = parted.FileSystem(type=_fstype, geometry=geometry) # Create partition partition = parted.Partition(disk=disk, type=parted.PARTITION_NORMAL, geometry=geometry, fs=fs) @@ -108,7 +111,9 @@ def raw_format(device_path, fstype, volume_label, uid, gid): # Format partition according to the fstype specified if fstype == "fat32": call(["mkdosfs", "-F", "32", "-n", volume_label, partition.path]) - if fstype == "ntfs": + elif fstype == "exfat": + call(["mkfs.exfat", "-n", volume_label, partition.path]) + elif fstype == "ntfs": call(["mkntfs", "-f", "-L", volume_label, partition.path]) elif fstype == "ext4": call(["mkfs.ext4", "-E", "root_owner=%s:%s" % (uid, gid), "-L", volume_label, partition.path]) @@ -140,8 +145,8 @@ def main(): elif o in ("-d"): device = a elif o in ("-f"): - if a not in [ "fat32", "ntfs", "ext4" ]: - print("Specify fat32, ntfs or ext4") + if a not in [ "fat32","exfat", "ntfs", "ext4" ]: + print("Specify fat32, exfat, ntfs or ext4") sys.exit(3) fstype = a elif o in ("-l"): -- cgit v1.2.1