Partitioning of sdcard occasionally fails
Quite frequently, when running pmbootstrap install --sdcard /dev/sdX
, partitioning with parted will fail with the following error. I tried modifying partition.py
to call partprobe
between calls to parted
, but that didn't help at all. If I re-run the install
enough times, sometimes replugging the SD card reader (or card), it'll succeed. Sometimes it takes half a dozen tries to get the install
to successfully partition the SD card. I've tried with multiple cards. It could be my card reader, but I wonder if there's anything we could do in partition.py
to make it more robust since there are SO many crappy SD card readers out there.
[17:51:27] EVERYTHING ON /dev/sdc WILL BE ERASED! CONTINUE? (y/n) [n] y
(020023) [17:51:28] (native) mount /dev/install (host: /dev/sdc)
(020023) [17:51:28] % sudo mount --bind /dev/sdc /home/clayton/src/pmbootstrap-out/chroot_native/dev/install
(020023) [17:51:28] (native) partition /dev/install (boot: 46M, root: the rest)
(020023) [17:51:28] (native) % parted -s /dev/install mktable msdos
(020023) [17:51:29] (native) % parted -s /dev/install mkpart primary ext2 2048s 46M
Error: Partition(s) 1 on /dev/install have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes.
(020023) [17:51:29] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(020023) [17:51:29] NOTE: The failed command's output is above the ^^^ line in the logfile: /home/clayton/src/pmbootstrap-out/log.txt
(020023) [17:51:29] ERROR: Command failed: (native) % parted -s /dev/install mkpart primary ext2 2048s 46M
(020023) [17:51:29] Run 'pmbootstrap log' for details.
(020023) [17:51:29] See also: <https://postmarketos.org/troubleshooting>
(020023) [17:51:29] Traceback (most recent call last):
File "/media/data/clayton/src/pmbootstrap/pmb/helpers/run.py", line 45, in core
stderr=args.logfd)
File "/usr/lib/python3.6/subprocess.py", line 291, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', '/usr/bin/sh', '-c', "env -i CHARSET=UTF-8 PATH=/usr/lib/ccache/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin SHELL=/bin/ash HISTFILE=~/.ash_history /usr/bin/chroot /home/clayton/src/pmbootstrap-out/chroot_native sh -c 'cd /;parted -s /dev/install mkpart primary ext2 2048s 46M'"]' returned non-zero exit status 1.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "./pmbootstrap.py", line 53, in main
getattr(pmb.helpers.frontend, args.action)(args)
File "/media/data/clayton/src/pmbootstrap/pmb/helpers/frontend.py", line 113, in install
pmb.install.install(args)
File "/media/data/clayton/src/pmbootstrap/pmb/install/install.py", line 285, in install
install_system_image(args)
File "/media/data/clayton/src/pmbootstrap/pmb/install/install.py", line 165, in install_system_image
pmb.install.partition(args, size_boot)
File "/media/data/clayton/src/pmbootstrap/pmb/install/partition.py", line 72, in partition
command)
File "/media/data/clayton/src/pmbootstrap/pmb/chroot/root.py", line 86, in root
return_stdout, check)
File "/media/data/clayton/src/pmbootstrap/pmb/helpers/run.py", line 58, in core
raise RuntimeError("Command failed: " + log_message) from exc
RuntimeError: Command failed: (native) % parted -s /dev/install mkpart primary ext2 2048s 46M