From 57c8bea9a553501950c8f4b3e3407a8623311ed2 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Wed, 1 Jan 2020 03:05:21 -0800 Subject: [PATCH] storage: Make partition resizing work with parted 3.3 On Raspberry Pi 3B+ image, it was observed that resizing partition fails during initial setup. Due to this, Apache, SSH and Plinth become unavailable. This is due newer version of parted 3.3 (Debian testing/unstable) which does not work with ---pretend-input-tty option as previously expected of parted 3.2 (Debian buster). Fix the problem by sending answers to promoted questions via stdin instead of via command line. This solution works on both versions of parted, i.e., 3.2 and 3.3. Tests: - On a freshly built Raspberry Pi 3B+ unstable image the problem is reproducible. Running expand partition fails repeatedly. - Downgrade version of parted to 3.2 observe that the expanding operation runs fine. Upgrade to version parted 3.3 again. - Apply the patch on the action script. Re-run expanding partition and observe that the problem is resolved. The version of parted is 3.3. - Downgrade the version of parted to 3.2. Downsize the partition, re-run expanding partition. Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- actions/storage | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/actions/storage b/actions/storage index 95925708f..1147d5104 100755 --- a/actions/storage +++ b/actions/storage @@ -96,14 +96,15 @@ def _resize_partition(device, requested_partition, free_space): # https://debbugs.gnu.org/cgi/bugreport.cgi?bug=24215 fallback_command = [ 'parted', '--align=optimal', device, '---pretend-input-tty', 'unit', - 'B', 'resizepart', requested_partition['number'], 'yes', - str(free_space['end']) + 'B', 'resizepart', requested_partition['number'] ] try: subprocess.run(command, check=True) except subprocess.CalledProcessError: try: - subprocess.run(fallback_command, check=True) + input_text = 'yes\n' + str(free_space['end']) + subprocess.run(fallback_command, check=True, + input=input_text.encode()) except subprocess.CalledProcessError as exception: print('Error expanding partition:', exception, file=sys.stderr) sys.exit(5)