multibootusb icon indicating copy to clipboard operation
multibootusb copied to clipboard

TypeError installing syslinux... usb_disk[:-1]

Open anthonymobile opened this issue 6 years ago • 11 comments

The following is an example of output that I receive either installing syslinux at the end of a distro install or installing syslinux independently (what is shown below). It appears to be a type mismatch on the usb_disk[:-1] expression?

This is a brand new Ubuntu 17 installation.

anthony@sanfrancisco:/usr/bin$ sudo multibootusb
Using python version  3.6.3 (default, Oct  3 2017, 21:45:48) 
[GCC 7.2.0] on platform Linux-4.13.0-38-generic-x86_64-with-Ubuntu-17.10-artful
Could not find resource 'data/tools/gdisk/gdisk.exe'.
Running multibootusb version 9.2.0 from installed system...
Starting multibootusb GUI...
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
Cleaning old multibootusb directory...
Syslinux exist in multibootusb directory...
Using pyudev for detecting USB drives...
	/dev/sdc
	/dev/sdc1
	/dev/sdc2
	/dev/sdc3
	/dev/sdc4
	/dev/sdc5
	/dev/sdb
	/dev/sdb1
	/dev/sdb2
	/dev/sdb3
Selected device /dev/sdb
Device /dev/sdb is a GPT disk...
USB disk is not mounted and can't update list widget...
Selected device /dev/sdc3
/media/root/kali
Device /dev/sdc3 is a GPT disk...
Installing default syslinux on /dev/sdc3
Using gptmbr.bin for mbr install.
Could not find resource 'data/tools/gptmbr.bin'.
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/scripts/mbusb_gui.py", line 387, in onInstall_syslinuxClick
    ret = syslinux_default(config.usb_disk)
  File "/usr/lib/python3/dist-packages/scripts/syslinux.py", line 107, in syslinux_default
    mbr_install_cmd = 'dd bs=440 count=1 conv=notrunc if=' + mbr_bin + ' of=' + usb_disk[:-1]
TypeError: must be str, not NoneType

anthonymobile avatar Apr 12 '18 18:04 anthonymobile

Somehow 'gptmbr.bin' is missing. Please download the file from

https://github.com/mbusb/multibootusb/tree/master/data/tools

and place it under /usr/share/multibootusb/data/tools or your current working directory (./data/tools/) and see if it resolves the problem.

shinji-s avatar Apr 13 '18 00:04 shinji-s

I have the same problem, and think it is a bug in the DEB file, because "dpkg -L python3-multibootusb" also does not show the gptmbr.bin, just the mbr.bin.

For googlers, on ver 9.1.0 the error was "dd: failed to open '/usr/share/multibootusb/data/tools/gptmbr.bin': No such file or directory".

Manually downloading it worked, thanks.

JakubFojtik avatar Apr 22 '18 13:04 JakubFojtik

Also broken in the Arch Linux package. PR https://github.com/mbusb/multibootusb/pull/364 should fix this for Arch and any others which build packages from the Python package.

nvllsvm avatar May 05 '18 01:05 nvllsvm

@shinji-s - if you're a n00b like me, use

https://github.com/mbusb/multibootusb/blob/master/data/tools/gptmbr.bin

and not

https://github.com/mbusb/multibootusb/tree/master/data/tools

And click the Download button. Otherwise it will save is as a HTML document.

However, after this I'm still getting the error after including the gptmbr.bin

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/scripts/mbusb_gui.py", line 352, in install_syslinux
    config.distro, config.persistence)
  File "/usr/lib/python3/dist-packages/scripts/update_cfg_file.py", line 166, in update_distro_cfg_files
    os.path.join(dirpath, f))
  File "/usr/lib/python3/dist-packages/scripts/update_cfg_file.py", line 97, in fix_abspath
    path_expression, string, install_dir, iso_name,  kept_paths)
  File "/usr/lib/python3/dist-packages/scripts/update_cfg_file.py", line 58, in fix_abspath_r
    os.path.join(install_dir, specified_path))
  File "/usr/lib/python3.6/genericpath.py", line 19, in exists
    os.stat(path)
ValueError: embedded null byte

It doesn't happen with all distros trying to install, but does appear to happen no matter which file system is used.

mang-design avatar Aug 11 '18 07:08 mang-design

Something is wrong with the ISO name, which is used as the distro-root name, or name of a file or dir stored in the iso and the resulting path contains a null char. Will you apply the patch below and tell us what you get? (An ISO name that contains non-ascii chars may not work.)

diff --git a/scripts/update_cfg_file.py b/scripts/update_cfg_file.py
index 2fbae8d..0fa274b 100644
--- a/scripts/update_cfg_file.py
+++ b/scripts/update_cfg_file.py
@@ -54,8 +54,12 @@ def fix_abspath_r(pattern, string, install_dir, iso_name, kept_paths):
     # See if a path that has 'boot/' prepended is a better choice.
     # E.g. Debian debian-live-9.4.0-amd64-cinnamon has a loopback.cfg
     # which contains "source /grub/grub.cfg".
-    specified_path_exists = os.path.exists(
-        os.path.join(install_dir, specified_path))
+    try:
+        specified_path_exists = os.path.exists(
+            os.path.join(install_dir, specified_path))
+    except:
+        log("Failed to stat '%s'." % os.path.join(install_dir, specified_path))
+        raise
     if specified_path_exists:
         # Confidently accept what is specified.
         selected_path, fixed = specified_path, False

shinji-s avatar Aug 11 '18 18:08 shinji-s

Apologies -- been very busy. I'm unsure how to apply the patch, terribly new to all this. I cloned the repo and attempted the patch but the diff command was giving me errors.

mang-design avatar Aug 26 '18 07:08 mang-design

There is no need to clone the repo. You can manually edit the source code already installed on your system if 'patch' command does not work. You should be able to find the file to patch in the following way.

C:\Users\shinj\Documents\src\multibootusb>python
Python 3.6.3 (v3.6.3:2c5fed8, Oct  3 2017, 18:11:49) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from scripts import update_cfg_file
>>> print (update_cfg_file.__file__)
C:\Users\shinj\Documents\src\multibootusb\scripts\update_cfg_file.py

And then open the file with your favorite editor, look for 'specified_path_exists = ' and bracket the statement with the try-except block.

shinji-s avatar Aug 30 '18 09:08 shinji-s

Gdisk.exe is missing here:

Using python version 3.6.6 (default, Jun 30 2018, 21:40:35) [GCC 7.3.0] on platform Linux-4.17.17-1-x86_64-with-glibc2.3.4 Could not find resource 'data/tools/gdisk/gdisk.exe'. Running multibootusb version 9.2.0 from installed system... Starting multibootusb GUI... qt.qpa.screen: QXcbConnection: Could not connect to display Could not connect to any X display.

ShalokShalom avatar Oct 03 '18 12:10 ShalokShalom

gdisk.exe is missing here as well:

Using python version 3.6.6 (default, Jun 30 2018, 21:40:35) [GCC 7.3.0] on platform Linux-4.17.17-1-x86_64-with-glibc2.3.4 Could not find resource 'data/tools/gdisk/gdisk.exe'. Running multibootusb version 9.2.0 from installed system... Starting multibootusb GUI... qt.qpa.screen: QXcbConnection: Could not connect to display Could not connect to any X display.

When I add both files, I still get an error:

Using python version 3.6.6 (default, Jun 30 2018, 21:40:35) [GCC 7.3.0] on platform Linux-4.17.17-1-x86_64-with-glibc2.3.4 Running multibootusb version 9.2.0 from installed system... Starting multibootusb GUI... qt.qpa.screen: QXcbConnection: Could not connect to display Could not connect to any X display.

ShalokShalom avatar Oct 03 '18 12:10 ShalokShalom

Another one with syslinux installing stuck after adding distro.

I tried same thing as https://github.com/mbusb/multibootusb/issues/336#issuecomment-412258469

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/scripts/mbusb_gui.py", line 352, in install_syslinux
    config.distro, config.persistence)
  File "/usr/lib/python3/dist-packages/scripts/update_cfg_file.py", line 402, in update_distro_cfg_files
    callback(dirpath, f)
  File "/usr/lib/python3/dist-packages/scripts/update_cfg_file.py", line 374, in fix_desktop_image_in_thema_callback
    for line in f.readlines():
  File "/usr/lib/python3.6/codecs.py", line 321, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa7 in position 3480: invalid start byte

Please any clues updated ticket!

xoxefdp avatar Aug 08 '20 23:08 xoxefdp

Project appears abandoned. I moved to Ventoy. Much simpler.

robotshateme avatar Aug 09 '20 01:08 robotshateme