diff --git a/lib/raw_format.py b/lib/raw_format.py index e5c1668..d3ea0a9 100755 --- a/lib/raw_format.py +++ b/lib/raw_format.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 -from subprocess import call +from subprocess import check_call import sys import argparse sys.path.append('/usr/lib/mintstick') @@ -9,8 +9,8 @@ def execute(command): syslog.syslog(str(command)) - call(command) - call(["sync"]) + check_call(command) + check_call(["sync"]) def raw_format(device_path, fstype, volume_label, uid, gid): @@ -36,6 +36,10 @@ def raw_format(device_path, fstype, volume_label, uid, gid): # If it starts at 0% or 0MB, it's not aligned to MB's and complains execute(["parted", device_path, "mkpart", "primary", partition_type, "1MiB", "100%"]) + # Make sure the kernel and udev see the new partition geometry before formatting it. + execute(["partprobe", device_path]) + execute(["udevadm", "settle", "--timeout=10", "--exit-if-exists=%s" % partition_path]) + # Call wipefs on the new partitions to avoid problems with old filesystem signatures execute(["wipefs", "-a", partition_path, "--force"])