[elbe-devel] [PATCH 2/4] finetuning: set_partition_type: ignore reread ptable error
Torben Hohn
torben.hohn at linutronix.de
Mon Mar 29 13:03:12 CEST 2021
When fdisk writes a new partition table, it tries to make the
kernel reread it. This does not work for loop devices and
makes fdisk return a non-zero return code.
-----------------------------------------------------------------------------------------------------------------------------
[CMD] losetup --find --show --partscan "/var/cache/elbe/4f553e2f-e976-426d-8c40-69cfe5ad47fd/sda.img"
[CMD] fdisk /dev/loop0
Welcome to fdisk (util-linux 2.33.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): Partition number (1,2, default 2): Hex code (type L to list all codes):
Changed type of partition 'Linux' to 'Hidden FAT16 <32M'.
Command (m for help): The partition table has been altered.
Calling ioctl() to re-read partition table.
Re-reading the partition table failed.: Device or resource busy
The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8).
[CMD] losetup --detach "/dev/loop0"
[ERROR] ProjectFinetuning Error, trying to continue anyways
Traceback (most recent call last):
File "/var/cache/elbe/devel/elbepack/finetuning.py", line 790, in do_prj_finetuning
action.execute_prj(buildenv, target, builddir)
File "/var/cache/elbe/devel/elbepack/finetuning.py", line 559, in execute_prj
action.execute_img(buildenv, target, builddir, loop_dev)
File "/var/cache/elbe/devel/elbepack/finetuning.py", line 716, in execute_img
do(cmd, stdin=inp)
File "/var/cache/elbe/devel/elbepack/shellhelper.py", line 258, in do
raise CommandError(cmd, p.returncode)
elbepack.shellhelper.CommandError: Error: 1 returned from Command fdisk /dev/loop0
-----------------------------------------------------------------------------------------------------------------------------
However, the next thing elbe does, is clear the loop mount and
the partition layout was not changed anyways. So this error
can be safely ignored.
Ignore it.
Signed-off-by: Torben Hohn <torben.hohn at linutronix.de>
---
elbepack/finetuning.py | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/elbepack/finetuning.py b/elbepack/finetuning.py
index 16d07ea8c..d3968bb68 100644
--- a/elbepack/finetuning.py
+++ b/elbepack/finetuning.py
@@ -713,7 +713,15 @@ class SetPartitionTypeAction(ImageFinetuningAction):
cmd = f'fdisk {loop_dev}'
inp = f't\n{part_nr}\n{part_type}\nw\n'
- do(cmd, stdin=inp)
+ try:
+ do(cmd, stdin=inp)
+ except CommandError as e:
+ # At the end, fdisk tries to reread the partitiontable
+ # and fails. This makes it return 1.
+ #
+ # When it returns 1, we can just continue.
+ if e.returncode != 1:
+ raise
@FinetuningAction.register("unit-tests")
--
2.20.1
More information about the elbe-devel
mailing list